# Creating centered inline cell in text cell

The cell corresponds to the textual form

Cell[TextData[{
"The ", StyleBox["average rate of change", FontWeight->"Bold"],
" in ",
" on the interval ",
Cell[BoxData[FormBox[
RowBox[{"[", RowBox[{"a", ",", RowBox[{"a", "+", "h"}]}], "]"}], TraditionalForm]]],
" is the slope of the corresponding secant line: \n",
Cell[BoxData[FormBox[GridBox[{
{GridBox[{{
RowBox[{SubscriptBox["m", "sec"], "=", FractionBox[
RowBox[{RowBox[{"f", "(", RowBox[{"a", "+", "h"}], ")"}], "-",
RowBox[{"f", "(", "a", ")"}]}], "h"]}]}
},
GridBoxAlignment->{"Columns" -> {{"="}}}]}},
GridBoxItemSize->{"Columns" -> {{
"\nThe ", StyleBox["instantaneous rate of change", FontWeight->"Bold"],
" in ",
" at ",
" is "
}], "Definition",
CellChangeTimes->{{3.454944654993936*^9, 3.45494474976772*^9}, {
3.4549518777111692*^9, 3.454951884742343*^9}, {
3.460806271054368*^9, 3.4608062731390657*^9}, {
3.478189589239235*^9, 3.478189591304613*^9}, {3.487447061963195*^9,
3.487447061963235*^9}}]


I can't figure out how to enter this in the Mathematica user interface. It seems as though the displayed equation on the second line is an inline cell that is aligned using GridBox, but I don't see how to create that effect.

-
Are you sure it was created in the front end? Maybe it was imported from TeX, MathML or something. Or it was modified manually, adding GridBoxItemSize option there. –  swish Apr 12 at 20:52
Well, that's always possible. I doubt it was modified manually, but it could have been imported from TeX. So you think there's no way of doing this in the front end? –  rogerl Apr 12 at 21:03
Maybe there is, I just tried to do this and didn't find anything. –  swish Apr 12 at 21:13
Use the palette Writing Assistant available in the Palettes menu. See the options under Math Cells drop-down menu in the Writing and Formatting section of the palette. –  kguler Apr 12 at 21:38
@kguler Yes, that kind of works. It adds a new cell, which can then be merged with the text cells above and/or below and gives me pretty much what I want. However, it does seem to use inline styling rather than display styling (for example, limits on sums are to the right of the summation sign rather than above and below). –  rogerl Apr 12 at 21:55

It turns out, after lots of poking around, that the fact that the cell is inline is not really the relevant thing. What is relevant is that each stylesheet has a property, LimitsPositioningTokens, that specifies which symbols should use the off-to-the-side limits positioning by default. For the Text style, that list includes all the usual things, including lim, $\Sigma$, and $\Pi$. Removing those symbols from the list produces the positioning that I wanted.

Additionally, it turns out that the portion of the book quoted in the original question was not imported --- it was all hand entered. There is a useful video here that describes the process of putting the interactive book together. It is only 30 minutes long, so it does not go into great detail, but there was a lot of useful information there if you are planning any kind of real doc-writing project in Mathematica.

-

This is different but you may find it useful. The second line will be evaluated in place code with panel, just Ctrl+9 to create an inline cell and type:

select this and evaluate in place with Ctrl+Shift+Enter

-
The code can also be Pane[HoldForm[\[Placeholder]], Full, Alignment -> Center], which can then be edited, in case the expression to be centered cannot be put into Mathematica code. (+1) –  Michael E2 Apr 14 at 0:09

The nested single-element GridBoxes make it likely that this format was generated by code. In fact, the inline cell expression matches exactly that generated by the Equal Symbol Aligned Math Cell from the Writing Assistant palette (in V9, at least):

-
Yes, I noticed that as well. What I don't understand is that the palette element inserts an inline cell, so that constructs are built with inline visuals (for example, the limits on a sum are below and to the side, rather than above and below, the summation sign). And if I try to convert this to an equation style, either manually by editing the text in the notebook file or visually in the front end, the equal sign alignment is lost. I find document construction with Mathematica to be really difficult and not well documented. Is there a good discussion somewhere of how to do this? –  rogerl Apr 13 at 15:37
Oops, I somehow missed the comments to this effect under the question. I'm afraid I am not aware of a good resource for this. Judging from the source that ships with Mathematica, it would seem that WRI frequently writes box language directly to obtain finicky formatting -- bypassing not only the UI but also functions like Grid, etc. –  WReach Apr 13 at 15:48