1
$\begingroup$

This question already has an answer here:

Bug introduced in V11.1 or earlier and persists through V11.3

[CASE:4061571], confirmed

Consider the following three examples of a cell:

CellPrint@Cell["i", "Section"]
CellPrint@Cell[BoxData@InterpretationBox[Cell@"i", 2], "Section"]
CellPrint@Cell[BoxData@InterpretationBox[Cell@"i", 2], "Section", "Section"]

which yields:

Mathematica graphics

Notice how the second cell has some strange mixture of styles applied. According to the documentation of Cell:

Cell[contents,"style1","style2",…] represents a cell with multiple styles applied to it.

So there should be nothing special about the third line.

While I am pretty sure that this is a bug, I have noticed that the documentation pages all do the same thing for their heading cells:

Cell[
  TextData[{…,"Basic Examples",…}],
  "ExampleSection",
  "ExampleSection",
  WholeCellGroupOpener->True
]

So I'm not so sure anymore where the issue lies. This brings me to the purpose of this question:

  • What is happening in the second/third example?
  • Why are only some styles applied, but not others?
  • Why is the reasoning behind applying the same style twice? (and why does it make a difference?)
  • Is this behavior documented anywhere?
$\endgroup$

marked as duplicate by Lukas Lang, MarcoB, Kuba May 5 '18 at 17:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ I'd report this one too. Are you planning to do so with those 3 topics? $\endgroup$ – Kuba May 1 '18 at 19:48
  • $\begingroup$ @Kuba already did (I'll update the posts once I get an answer) - I know that this is not the place to post bug reports, but I figured I'd post them anyway in the hopes of getting more insight and possibly a workaround. Also, I'm still not too used to working with Cell and Box expressions, so I assumed there's a significant chance that I've simply missed something in the docs ;) $\endgroup$ – Lukas Lang May 2 '18 at 7:42
  • 1
    $\begingroup$ You can kinda think of your multi-style specification as more like {"Section", styles dictated by the FrontEnd, "Section", ...}. An example of a style that the FrontEnd can inject is "StandardForm"/"TraditionalForm". It's not that simple, but that is the general gist. $\endgroup$ – ihojnicki May 2 '18 at 20:08
  • 1
    $\begingroup$ @ihojnicki and Mathe172 I'd say it is explicitly against StylesAndTheInheritanceOfOptionSettings which sets the hierarchy quite clearly. I can live with 'hidden' styles (for DocekdCells/InlineCells) and the fact that they are inserted between Cell's and Notebook's options but in this case they are inserted between Cell's styles making the first style very special. The discussion about documenting all those exceptions is not new. Maybe there is no huge demand, or maybe there is no demand because people are discouraged by apparent randomness? $\endgroup$ – Kuba May 3 '18 at 10:30
  • 1
    $\begingroup$ @Kuba Interesting... I didn't know about that post by John. Which by the way is the answer to this question. In the example above, its step two that causes the difference in appearance. $\endgroup$ – ihojnicki May 3 '18 at 11:36

Browse other questions tagged or ask your own question.