Minimal example:

Let's establish a notebook's stylesheet with additional TestStyle which has a FormatType->"CellExpression":

 StyleDefinitions -> Notebook[{
    Cell[StyleData[StyleDefinitions -> "Default.nb"]],
    Cell[StyleData["Notebook"], Background -> LightBlue],
    Cell[StyleData["TestStyle"], FormatType -> "CellExpression"]

and let's create couple of examples:

CellPrint[Cell[BoxData["TestStyle"], "TestStyle"]]

CellPrint[Cell[TextData["TestStyle"], "TestStyle"]]

CellPrint[Cell["TestStyle", "TestStyle"]]


The first one doesn't respect FormatType (Background should be White). I can imagine it is to be expected but I failed to explain it to myself.

enter image description here


What exactly do I have to keep in mind about interference between Cell contents and FormatType or other options. Background inherited from CellExpression shouldn't care about the content so there is probably something more general to remember.


Cell[TextData["string"]] is completely equivalent to Cell["string"]. There's no reason to expect the two to behave differently. TextData is a required wrapper when the contents are more complex than a string, but when it's a string, it changes nothing. And TextData cells have only a single way of determining the format type...from the FormatType option.

While TextData must rely on the FormatType option for its notion of format type, BoxData relies instead on the FormBox wrapper. You can see evidence of this by evaluating...


If you convert the output cell to TraditionalForm, you'll see the dynamic update. But note that nowhere in the underlying cell expression is FormatType->TraditionalForm set. Nor is it set in the "TraditionalForm" style in Core.nb. This is the FE trying to keep the FormBox and option forms of FormatType in sync.

When a BoxData cell has no FormBox, then it's StandardForm. Always. This is hard-coded and cannot be overridden.

  • $\begingroup$ Good to know, thanks for the answer. Could you also tell me what decides if TextData or BoxData appears when one starts typing in an empty cell? $\endgroup$
    – Kuba
    Mar 15 '16 at 7:39
  • 1
    $\begingroup$ @Kuba the DefaultFormatType option. $\endgroup$
    – John Fultz
    Mar 15 '16 at 15:11
  • 2
    $\begingroup$ What determines if TextData or BoxData appears in an inline cell? I am trying to get inline cells to use TextData, but I am unable to convince it to do that by setting the DefaultInlineFormatType option. $\endgroup$
    – Szabolcs
    Sep 26 '17 at 10:15
  • $\begingroup$ If you're talking about creating inline cells using Ctrl+9, then it's always toggling. If the cell you're in is TextData, then it will insert a BoxData cell and vice versa. Because this is 99% of what people use inline cells for. If you want something else, you have to programmatically create the cell, or insert it in Show Cell Expression mode, or a few other tech-y options. $\endgroup$
    – John Fultz
    Sep 30 '17 at 17:54
  • $\begingroup$ @JohnFultz so there's no way to force an inline cell inside a block of text (e.g. when I want to have $ a_b $ in a "Text" cell) use TextData instead outside of some hideous hack...? That seems wrong. $\endgroup$
    – b3m2a1
    Oct 25 '18 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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