如何在Mathematica Notebook Styles中填写CellFrameLabels?
我一直在按照这些其他答案中的伟大建议来获取编号的单元格标签
如何在 Mathematica 笔记本中自动编号单元格标签?
我几乎那里。我想将部分编号添加到创意/柔和颜色样式表中的部分样式。我创建了一个新笔记本(这是我的公共保管箱上的副本)
http://dl. dropbox.com/u/1997638/CellFrameMargins.nb
转到“格式”菜单,选择“样式表 \ Creative \ 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}}
信息。好的,回到笔记本的 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 *) } } ]
The CellFrameMargins ->;我通过反复试验发现的 4 规则需要将单元格框架的顶部和底部与右侧部分样式的其余部分对齐。我很遗憾地报告说它几乎有效。 CellFrameLabels 的文本和框架之间存在间隙,我想填充这些间隙。就好像 CellFrameLabels 中的字体没有上下拉伸得足够远,即使它们与部分单元格中的字体完全相同。我找不到一种方法来填充标签后面的背景。我尝试了
背景 -> RGBColor[...]
,我尝试放入显式字体,我尝试设置 CellFrameMargins 和 CellFrameLabelMargins,以多种组合,但无济于事。
我很困惑,希望得到任何建议。
I have been working on getting numbered cell-frame labels following the great advice in these other answers
Extending cell definition to CellFrameLabels definition
How to Autonumber Cell Tags in Mathematica Notebooks?
and I'm almost there. I wanted to add section numbers to section styles in the Creative / Pastel colors stylesheet. I created a new notebook (here's a copy on my public dropbox)
http://dl.dropbox.com/u/1997638/CellFrameMargins.nb
went to "Format" menu, chose "Stylesheet \ Creative \ PastelColor," then
"Format" "Edit Stylesheet", "Choose a style: Section", then click on Creative\Pastelcolor.nb at the top of the stylesheet-editing dialog.
That opens another stylesheet editor, and I go to the fourth item down "Styles for Title and Section Cells," then the second item in there "Section." Put mouse crosshairs in there and click, then choose "Cell" menu, "Show Expression" item, which reveals the following expression:
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]]
GREAT! Reveals all the details, or so I thought. In particular, the CellFrame item gives me the {{0, 0}, {1, 3}}
info I need to line up my cell frame labels with the Section style. Ok, so back to the steylsheet editor dialog for my notebook, and following the aforementioned answers, I type
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 *) } } ]
The CellFrameMargins -> 4
rule I found by trial-and-error is needed to line up the top and bottom of the cell frame with the rest of the Section style to the right. I'm sad to report that it only almost works. There are gaps between the text of the CellFrameLabels and the frames, and I want to fill in those gaps. It's as though the fonts in the CellFrameLabels don't stretch up and down far enough, even though they're exactly the same as the fonts in the Section cells. I can't find a way to fill in the background behind the labels. I tried Background -> RGBColor[...]
, I tried putting in explict fonts, I tried setting the CellFrameMargins, and the CellFrameLabelMargins, in many many combinations, but to no avail.
I'm stumped and would appreciate any advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎适用于柔和的风格。其作用是将标签放入框架内。我必须稍微调整一下
FrameBox
的ImageMargins
和FrameMargins
才能使所有内容对齐。截屏:
This seems to work for the pastel style. What this does is putting the label inside a frame. I had to fiddle a bit with the
ImageMargins
andFrameMargins
of theFrameBox
to make everything align.Screenshot: