邮件样式问题 [英] Problem with Message styling

查看:118
本文介绍了邮件样式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下内容:

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继承了先前打印的Cell的样式.为什么会这样?以及如何防止这种情况?

One can see that the auto-generated Message inherits the style of the previous printed Cell. Why this happens? And how to prevent this?

推荐答案

此错误的一种解决方法似乎是将"Message"移动到Cell选项中的另一位置:

It seems that one workaround for this bug is to move "Message" to another place in the Cell options:

printMessage[cellexpr_]:=CellPrint@Cell[cellexpr,CellLabel->"(slave Kernel)",
                         "Message", 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];

编辑

但是随着打印的Cell外观的改变:

But as the result appearance of the printed Cell is changed:

print := printMessage[
  BoxData[RowBox[{RowBox[{"NIntegrate", "::", "\"slwcon\""}], ": ", 
     "\"Numerical integration converging too slowly; suspect one of \
the following: singularity, value of the integration being 0, \
oscillatory integrand, or insufficient WorkingPrecision. If your \
integrand is oscillatory try using the option Method->Oscillatory in \
NIntegrate.\""}], StandardForm]]

编辑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.

这篇关于邮件样式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆