# Stylesheet code for limitspositioning option of InlineCell inside a “Text” vs “DisplayFormula” cell

I am attempting to build a stylesheet to emulate the underoverscripts in a textbook.

First some background... When I come to place in a "Text" cell where I need to write some math notation I use an "InlineCell". The code in my stylesheet for "InlineCell" is:

Cell[StyleData["InlineCell"],
ScriptSizeMultipliers->{0.7, 0.7142857, 1.},
ScriptLevel->1,
NumberSeparator->",",
FontSize->12,
UnderoverscriptBoxOptions->{LimitsPositioning->True},
FractionBoxOptions->{BaseStyle->{ScriptSizeMultipliers -> {1., 0.7, 0.7142857, 1.}}}]


The option UnderoverscriptBoxOptions->{LimitsPositioning->True} makes sure that underoverscripts are written on the side (not above and below), as you can see in the summation notation below:

This seems to be standard practice in a textbook when the math is located inside a textual paragraph. I believe the reason for this is so that the line spacing looks more consistent in the paragraph. However, there are times when underoverscripts are written above and below as you can see below:

In general, I want the overunderscipts to appear this way when the math notation is located on its own line outside of a paragraph. The pic below illustrates this:

I would like to emulate this by using an "InlineCell" inside a "DisplayFormula" cell.

This means that for an "InlineCell", I would need to have UnderoverscriptBoxOptions->{LimitsPositioning->False} only when the "InlineCell" is inside a "DisplayFormula" cell. But would need to be true when the "InlineCell" is inside a "Text" cell.

I hope this makes sense. You can see both types of limitspositioning in the pic above.

• I'm thinking that maybe I should create a function inside my stylesheet that that sets the limitspositining to true or false dependent on whether I am currently in a "Text" or "DisplayFormula" cell. Not sure how to do this. Or I could create two InlineCell definitions in my stylesheet... one that I call while inside a "Text" cell and one that I call while inside a "DisplayFormula" cell. But this doesn't seem efficient as all other information is identical. – Michael McCain Nov 23 '16 at 21:49
• This probably can be done with dynamic reference to ParentCell[] but I am not sure it will be efficient or a proper way to do. It really seems like you need two styles e.g. InlineFormula and StandaloneFormula, one can inherit from another with adjustments you need, that gives you more flexibility. – Kuba Nov 24 '16 at 7:11
• I was able to solve the problem easily. I took out all reference to limits positioning in the for "InlineCell" in my private stylesheet. It turns out "InlineCell" adopts the limitpositioning of any cell it is inside. So I set limitspositioning of "Text" to True. Then created a new style and set limitspositioning to False. Now anytime I call an inline cell within each it adopts whats in the parent cell. I guess "InlineCell" is built like this on purpose. – Michael McCain Jul 30 '17 at 8:50

If I understand you right I have the answer to your need, and it is simple. Below you see the screen shot where I show different formats created by my custom-made StyleSheet.

The first line is just the use of the inline formula inside a text cell, where the upper and lower limits are written on the side of the symbol, as you wish.

The second line is the cell DisplayFormulaNumbered. There I placed two sums one with the limits on side and one - above and below just for the purpose of the demonstration of such a possibility. Here the sum with the limits on side is done within the InlineFormula placed inside the DisplayFormulaNumbered cell. The second sum (with the indices above and below) is in contrast typed in the DisplayFormulaNumbered cell.

The code for the Inline formula is as follows:

Cell[StyleData["InlineFormula"],
ScriptSizeMultipliers->{0.7, 0.7142857, 1.},
ScriptLevel->1,
FontFamily->"TimesNewRoman",
FontSize->12,
FontWeight->"Plain",
FontSlant->"Italic",
FontVariations->{"StrikeThrough"->False,
"Underline"->False},
UnderoverscriptBoxOptions->{LimitsPositioning->True},
FractionBoxOptions->{BaseStyle->{ScriptSizeMultipliers -> {1., 0.7, 0.7142857, 1.}}}]


where I inserted your definitions, but kept few of my own. I also recommend to add the following cell into the StyleSheet:

Cell[StyleData["InlineCellEditing"],
FontFamily->"Constantia",
FontColor->RGBColor[0.502, 0., 0.502],
Background->RGBColor[0.896, 1, 0.951]]


This is not necessary, but helps during editing the inline cell.

Now to operate:

you call the inline cell just by pressing Ctrl+9. This can be done from the text cell as well as from the DisplayFormulaNumbered cell. Then the slot of the InlineFormula opens. If you included the definition of the InlineCellEditing (given above), this slot will have a different color and font, which helps during editing. Now you can simply type the formula in the slot. For example, for the sum underscript you simply type Ctrl+_ and so on. It will appear in the right place.

If in the DisplayFormulaNumbered cell you need to insert the under/overscripts below and above the symbol, you do it outside the InlineFormula cell. Close it, if it has been open. Just use the palette template: Menu/Palettes/Other/BasicMathInput.

I hope it helps.

• It does thank you. This is helpful. I was creating an InlineCell whenever I wrote an equation even when inside a DisplayFormulaCell. But there is no reason to do this I realized after reading your response. – Michael McCain Nov 28 '16 at 4:41
• I have a question... why do we have "InlineCell" and "InlineFormula" as two different Styles? In what situations should I use each? I'm confused. And why is InlineCell important enough to a shortcut but InlineFormula is not? – Michael McCain Nov 28 '16 at 4:42
• @ Michael McCain I do not know. I always thought that they are the same, but now that you pointed it out, I doubt. – Alexei Boulbitch Nov 28 '16 at 9:29
• – Michael McCain Dec 3 '16 at 4:21