Message Boards Message Boards

Variable Styles inside Text not supported any more?


In teaching Mathematica, I frequently annotate code with text cells that include System names and other small bits of code. Until now, if you were writing something like "The name for the number pi is Pi." you could highlight Pi, and covert it to Input style. In version 11.2, it I do this, the whole cell is converted to Input. Is there a new setting that overrides this behavior?

Ken Levasseur UMass Lowell

POSTED BY: Ken Levasseur
12 days ago

I seem to be able to do it like this:

  • Select Pi
  • Control-9 (create inline cell)
  • convert to Input
  • Cell > Convert To > StandardForm Display

For the text "to enter pi, type Pi", the cell expression should be something like this:

 "To enter pi, type ",
 Cell[BoxData["Pi"], "Input"]
}], "Text",
 CellChangeTimes->{{3.716552891901293*^9, 3.716552931558848*^9}}]

I don't know whether there is a shorter way.

POSTED BY: Michael Rogers
12 days ago

For now, you can work around it by using Cmd+0 (Mac) or Alt+0 (others) to set the style.

What happened:

Last year, we floated a proposal internally to tweak the behavior of named style application. In 11.1 (and for years earlier), if you type, say, Alt+7 (for Text style) in an empty cell, it converts the entire cell to Text. But if you do it in a non-empty cell, it only converts the things you are about to type to a Text StyleBox. The proposal was to make it consistent so that, at any point, if you have a blinking caret selection in a cell and apply a named style, it applies to the whole cell.

This would be an inconvenience to few cases where people might wish to apply named styles as they're typing inline, but it would be a convenience in other cases where one has accidentally started typing several characters or words into a cell without realizing that the wrong style had been selected. The proposal included the possibility of selecting a range of text and applying a style to that range specifically just as always had been possible, so the legacy usage would still have an easy way to be applied.

Unfortunately, we made a mistake and ended up causing named style application to always promote to the entire cell even if you have a range of text selected. This is already resolved in our internal nightly build, but did not get resolved in time for 11.2. My apologies for that.

In the mean time, the same change didn't get applied to the "Other..." style dialog, and so you can use that as a workaround.

POSTED BY: John Fultz
12 days ago

Thanks John

I’ll look forward to the fix.


POSTED BY: Ken Levasseur
11 days ago

Group Abstract Group Abstract