我一直在努力按照这些其他答案中的好建议来获取编号的单元格框架标签
Extending cell definition to CellFrameLabels definition
How to Autonumber Cell Tags in Mathematica Notebooks?
我快到了。我想在 Creative/Pastel 颜色样式表中将部分编号添加到部分样式中。我创建了一个新笔记本(这是我的公共(public)保管箱上的副本)
http://dl.dropbox.com/u/1997638/CellFrameMargins.nb
转到“格式”菜单,选择“样式表\创意\PastelColor”,然后
“格式”“编辑样式表”,“选择样式:部分”,然后单击样式表编辑对话框顶部的 Creative\Pastelcolor.nb。
这将打开另一个样式表编辑器,然后我转到第四项“标题和部分单元格的样式”,然后是第二项“部分”。将鼠标十字准线放在那里并单击,然后选择“单元格”菜单,“显示表达式”项,显示如下表达式:
Cell[StyleData["Section"],
CellFrame->{{0, 0}, {1, 3}},
CellFrameColor->RGBColor[1., 0.819608, 0.658824],
FontFamily->"Helvetica",
FontSize->18,
FontWeight->"Bold",
FontColor->RGBColor[0.882353, 0.419608, 0.0784314],
Background->RGBColor[1., 0.886275, 0.741176]]
伟大的!揭示所有细节,至少我是这么认为的。特别是,CellFrame 项目给了我
{{0, 0}, {1, 3}}
info 我需要将单元格框架标签与 Section 样式对齐。好的,回到我的笔记本的 steylsheet 编辑器对话框,按照上述答案,我输入Cell[
StyleData["Section"],
CellFrameLabelMargins -> 0,
CellFrameLabels-> { {
Cell[
TextData[{ "§", CounterBox["Section"], ": " }],
"SectionLabel",
CellFrame -> {{0, 0}, {1, 3}},
CellFrameMargins -> 4
] (* left label *),
Inherited (* right label *) },
{Inherited (* bottom label *),
Inherited (* top label *) } } ]
CellFrameMargins -> 4
我通过反复试验找到的规则需要将单元格框架的顶部和底部与右侧的部分样式的其余部分对齐。我很遗憾地报告它几乎只能工作。 CellFrameLabels 的文本和框架之间存在空白,我想填补这些空白。就好像 CellFrameLabels 中的字体没有向上和向下拉伸(stretch)足够远,即使它们与 Section 单元格中的字体完全相同。我找不到填充标签背后背景的方法。我试过Background -> RGBColor[...]
,我尝试放入显式字体,我尝试设置 CellFrameMargins 和 CellFrameLabelMargins,在许多组合中,但无济于事。我很难过,不胜感激任何建议。
最佳答案
这似乎适用于柔和的风格。这样做是将标签放在框架内。我不得不摆弄一下 ImageMargins
和 FrameMargins
的FrameBox
使一切对齐。
Cell[StyleData["Section"],
CellFrameLabels->{{
Cell[
BoxData[
FrameBox[
TemplateBox[{"§", CounterBox["Section"], ": "},
"Row",
DisplayFunction->(RowBox[{#, " ", #2}]& )
],
ImageMargins->-1,
Background->RGBColor[1., 0.886275, 0.741176],
FrameStyle->RGBColor[1., 0.886275, 0.741176],
FrameMargins->2
]
],
"SectionLabel", CellFrame -> {{0, 0}, {1, 3}},
CellFrameMargins->0
], Inherited},
{Inherited, Inherited}},
CellFrameLabelMargins->0
]
截屏:
关于wolfram-mathematica - 如何在 Mathematica Notebook Styles 中填写 CellFrameLabels?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8996938/