考虑以下:
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
的继承了之前printed的样式Cell
。为什么会发生这种情况?以及如何防止这种情况?