更改文本样式中的方程背景颜色

发布于 2024-12-12 08:01:44 字数 114 浏览 1 评论 0原文

在 Mathematica 中,当您写入文本样式的单元格时,如果您创建格式化方程,例如按“x ctrl_a”,则在选择方程时背景颜色会发生变化。有谁知道这个方程格式区域叫什么,以及具体如何在选择方程时更改背景颜色。

In Mathematica when your writing to a Text styled cell, if you create an formatted equation, for example pressing "x ctrl_ a", the background color changes while the equation is selected. Does anyone know what this equation format area is called, and specifically how to change the background color when the equation is selected.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦年海沫深 2024-12-19 08:01:44

一般来说,如果您在单元格中按 Cmd-Shift-E,它会显示底层的低级语法,构成了您所看到的漂亮格式。就我而言,对于 x_a foo bar,其中 x_a 被排版为下标,它显示:

 Cell[TextData[{
 Cell[BoxData[
  FormBox[
   SubscriptBox["x", "a"], TraditionalForm]]],
 " foo bar "
}], "Text",
 CellChangeTimes->{{3.528581300759695*^9, 3.5285813422683*^9}, {
  3.528581510346758*^9, 3.5285815118015013`*^9}}]

现在,要访问您想要的信息,请打开样式表 Core.nb 并查看 Mathematica 系统特定元素的样式 >格式类型样式>内联单元格编辑。使用上面的组合键查看底层代码,其中显示:

Cell[StyleData["InlineCellEditing"],
 StyleMenuListing->None,
 Background->RGBColor[0.964706, 0.929412, 0.839216]]

This is the back color that is used.要确认:

Graphics[{RGBColor[0.964706, 0.929412, 0.839216], Disk[]}]

在此处输入图像描述

是的!要进行更改,您只需使用更改的定义创建自己的样式表,并将其用作笔记本的默认样式表。


示例:

要仅为此笔记本创建自定义样式定义,请转至 Format >编辑样式表,在显示的私有样式定义的新窗口中,按 Enter 键启动一个新单元格,使用上面的组合键并替换其中的文本与上述相同(将 RGB 值更改为您想要的值),然后按相同的组合键退出 CellExpression 模式。例如:

Cell[StyleData["InlineCellEditing"],
 StyleMenuListing->None,
 Background->RGBColor[0.3, 0.9, 0.8]]

给我一个水绿色背景:

在此处输入图像描述

然后您可以保存此样式笔记本并重复使用它如果你愿意的话。

In general, if you press Cmd-Shift-E when you're in the cell, it shows you the underlying low-level syntax that makes up the pretty formatting that you see. In my case, for x_a foo bar, where x_a is typeset as a subscript, it shows:

 Cell[TextData[{
 Cell[BoxData[
  FormBox[
   SubscriptBox["x", "a"], TraditionalForm]]],
 " foo bar "
}], "Text",
 CellChangeTimes->{{3.528581300759695*^9, 3.5285813422683*^9}, {
  3.528581510346758*^9, 3.5285815118015013`*^9}}]

Now, to access the information you want, open up the stylesheet Core.nb and look at Styles for Mathematica System-specific Elements > FormatType Styles > InlineCellEditing. Use the above key combination to see the underlying code, which shows:

Cell[StyleData["InlineCellEditing"],
 StyleMenuListing->None,
 Background->RGBColor[0.964706, 0.929412, 0.839216]]

This is the background color that is used. To confirm:

Graphics[{RGBColor[0.964706, 0.929412, 0.839216], Disk[]}]

enter image description here

Yep! To change, you simply need to create your own stylesheet with an altered definition and use that as the default for the notebook.


Example:

To create a custom style definition for just this notebook, go to Format > Edit Stylesheet and in the new window that says Private style definitions for <filename.nb>, hit enter to start a new cell, use the key combo above and replace the text in there with the above (with RGB values changed to what you want) and then press the same combo to exit the CellExpression mode. So for example:

Cell[StyleData["InlineCellEditing"],
 StyleMenuListing->None,
 Background->RGBColor[0.3, 0.9, 0.8]]

gives me a aqua-greenish background:

enter image description here

You can then save this style notebook and reuse it if you wish.

川水往事 2024-12-19 08:01:44

而不是使用菜单 Format >编辑样式表,可以直接修改笔记本的样式定义。例如,只需运行以下代码:

SetOptions[EvaluationNotebook[], 
 StyleDefinitions -> 
  Notebook[{
    Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
    Cell[StyleData["InlineCellEditing"], 
         Background -> RGBColor[0.9, 0.6, 0.6]]}]]

它将样式表设置为默认样式表,并对内联单元格进行单一修改。

Instead of using the menu Format > Edit Stylesheet, you can modify the notebook's style definitions directly. For example, just run the following code:

SetOptions[EvaluationNotebook[], 
 StyleDefinitions -> 
  Notebook[{
    Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
    Cell[StyleData["InlineCellEditing"], 
         Background -> RGBColor[0.9, 0.6, 0.6]]}]]

Which sets the stylesheet to the default one with the single modification to the inline cells.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文