Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get a Cell to appear in TraditionalForm when using NotebookWrite. Here is the closest I can get:

nb = CreateDocument[];
NotebookWrite[nb, Cell["Hello", "Section"]];
NotebookWrite[nb, Cell[BoxData@ToBoxes@TraditionalForm@"HI", "Text"]];

I get the following:

nb output

What do I need to do to get "HI" to appear in TraditionalForm?


Here's a better example:

nb = CreateDocument[];
NotebookWrite[nb, Cell[BoxData[ToBoxes[Sin[x]^2]], "Output"]];


whereas I'd like the output to look like

Is there a specific option I need?

share|improve this question
up vote 5 down vote accepted

ToBoxes takes a second argument where you can specify the form that you desire. In your case, use TraditionalForm:

nb = CreateDocument[];
NotebookWrite[nb, Cell[BoxData[ToBoxes[Sin[x]^2, TraditionalForm]], "Text"]];

Note that the styling will also depend on how the cell style treats TraditionalForm text. For instance, change the cell style from "Text" to "Output" in the above and you get:

enter image description here

share|improve this answer

I'm not quite sure what TraditionalForm has to look like, but maybe setting the type to "Output" does what you want:

nb = CreateDocument[];
NotebookWrite[nb, Cell["Hello", "Section"]];
Cell[BoxData@ToBoxes@TraditionalForm@"HI", "Output"]];
share|improve this answer
Thanks, this is better but not quite what I'm after. I'd prefer it to look like TraditionalForm["HI"] instead of "HI". – Chip Hurst Jan 18 '13 at 23:16
@RiemannZeta you should try to be clearer as to what you want that is not satisfied by tis answer. I am not understanding. Maybe posting images even if necessary. Or the cell expression of a cell that shows like you intend – Rojo Jan 18 '13 at 23:38
@Rojo see my edit above. Thanks. – Chip Hurst Jan 18 '13 at 23:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.