0
$\begingroup$

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:

enter image description here

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:

enter image description here

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:

enter image description here

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.

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – B flat
    Commented Nov 23, 2016 at 21:49
  • 1
    $\begingroup$ 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. $\endgroup$
    – Kuba
    Commented Nov 24, 2016 at 7:11
  • $\begingroup$ 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. $\endgroup$
    – B flat
    Commented Jul 30, 2017 at 8:50

1 Answer 1

1
$\begingroup$

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.

enter image description here

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.

$\endgroup$
4
  • $\begingroup$ 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. $\endgroup$
    – B flat
    Commented Nov 28, 2016 at 4:41
  • $\begingroup$ 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? $\endgroup$
    – B flat
    Commented Nov 28, 2016 at 4:42
  • 1
    $\begingroup$ @ Michael McCain I do not know. I always thought that they are the same, but now that you pointed it out, I doubt. $\endgroup$ Commented Nov 28, 2016 at 9:29
  • $\begingroup$ Related... mathematica.stackexchange.com/questions/132632/… $\endgroup$
    – B flat
    Commented Dec 3, 2016 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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