消息样式问题
考虑以下几点:
printMessage[cellexpr_]:=CellPrint@Cell[cellexpr,"Message",
CellLabel->"(slave Kernel)",ShowCellLabel->True,
CellFrameMargins->0,Background->LightBrown,
CellLabelAutoDelete->False];
printMessage[BoxData[RowBox[{RowBox[{"Sin", "::", "\"argx\""}], ": ",
"\"\\!\\(Sin\\) called with \\!\\(2\\) arguments; 1 argument is expected.\""}],
StandardForm]]
Sin[1,1];
-->
(slave Kernel) Sin::argx: Sin called with 2 arguments; 1 argument is expected.
During evaluation of In[1]:= Sin::argx: Sin called with 2 arguments;
1 argument is expected. >>
可以看到自动生成的Message
继承了之前的样式打印单元格
。为什么会出现这种情况?以及如何防止这种情况发生?
Consider the following:
printMessage[cellexpr_]:=CellPrint@Cell[cellexpr,"Message",
CellLabel->"(slave Kernel)",ShowCellLabel->True,
CellFrameMargins->0,Background->LightBrown,
CellLabelAutoDelete->False];
printMessage[BoxData[RowBox[{RowBox[{"Sin", "::", "\"argx\""}], ": ",
"\"\\!\\(Sin\\) called with \\!\\(2\\) arguments; 1 argument is expected.\""}],
StandardForm]]
Sin[1,1];
-->
(slave Kernel) Sin::argx: Sin called with 2 arguments; 1 argument is expected.
During evaluation of In[1]:= Sin::argx: Sin called with 2 arguments;
1 argument is expected. >>
One can see that the auto-generated Message
inherits the style of the previous printed Cell
. Why this happens? And how to prevent this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎此错误的一种解决方法是将
"Message"
移动到Cell
选项中的另一个位置:编辑
但结果出现打印的
Cell
已更改:EDIT 2
上述解决方法仅在第一个新会话期间有效。保存并重新打开笔记本后,问题再次出现。
目前唯一的解决方法是不使用样式,而是指定明确的选项集。
It seems that one workaround for this bug is to move
"Message"
to another place in theCell
options:EDIT
But as the result appearance of the printed
Cell
is changed:EDIT 2
The above workaround works only during the first fresh session. After saving and reopening of the Notebook the problem appears again.
The only working workaround a this moment is do not use Styles but to specify explicit set of options.