I am using Grid to document a demo I have. i.e. I am writing the documentation of the demo as a help option, which will display information when clicked on.

Everything is working well. I am using the following pattern to do that:

help=Block[{a,b,c,.....}, (*Block is needed to prevent $nnn in symbols showing*)


    {"some text here, all in string"},
    {equation here using symbols a,b,c, as in  a=b+c},
  ]], FontFamily -> "Times"]


Then later on, when I want to display information, I simply display the help symbol. The nice thing also about this, is that I typeset these all once, in the initialization section. So that it is fast to display before as the help is typeset once and stored in the symbol.

The final result is really nice. The same as Latex. I see no difference at all.

The only glitch, is when I have long text, I'd like it to be full justified. Using normal Grid Alignments does not help here, and so I have to use TextCell, with the TextJustification->1 for it to work.

But the only problem is that some of the text I have might include subscript, like this one example:

enter image description here

And you can see that the TextCell does not like that one part (I understand also why it is not happy). I am trying to see if I can use TextCell (as it seems the only way to have text justified in a grid) and at the same time use little bit of subscript and such in the string. If there is such a trick.

For the actual math part of the documentation, I can split the math from the text like I show above in the rest of the grid. But there are some parts, where I need to write all the text in one place, and use little bit of subscript and such in there. But also be able to text justify everything so it looks nice.

In a way, this is like I do in Latex, where the main equations go as centered form, and the description around them has very little math. I am trying to emulate this with the help of Grid.

If I do not use textCell, this is the result:

enter image description here

So it works now, but text is not justified inside the grid. It does not look as nice.

Here is the code, if someone wants to try something. I tried many things, but so far, no luck. below is small example, left many things out. I have to keep the ContentSize fixed there since the overall size is fixed for display.

     {"let \!\(\*SubscriptBox[\(u\), \(n\)]\) be the outward normal \
derivative on the boundary"}
     }, Frame -> All]
   ], FontFamily -> "Times"],
 ContentSize -> {300, 475}

I do not want to use GraphisGrid and rasterize things and such.

And this will be used for a demo that runs in CDF plugin, so the following symbols can't be used :

SetOptions, ToExpression, Symbol , $Context, SetAttributes, Clear, Unprotect, DownValues, UpValues, OwnValues and packages not allowed to be used or created also. Also, Manipulate[] has to be the most outside construct.

Thank you,

Note: TextJustification -> 1 does alignment on BOTH ends. Using LineIndent->0 only does it on one side. Below is an example of the difference.

enter image description here

  • $\begingroup$ see below. You just need to fix the line indenting. For some reason the default is not zero within Grid. $\endgroup$ Jan 31, 2012 at 7:04

2 Answers 2


You can also supply a Row to the TextCell where the elements in the row can be a mix of strings and other expressions, so you could split the whole text into string fragments and bits of maths like this

TextCell[Row[{"This is some text ",
  HoldForm[Subscript[a, b]], 
  ". This is more text"}], TextJustification -> 1]

To show that it works:

    {"Boundary Conditions", SpanFromLeft},
       Row[{"This is some text, this is some text, this is some text ", 
       HoldForm[Subscript[a, b]], " this is more text."}], 
      TextJustification -> 1], SpanFromLeft},
    {"West", HoldForm[u = \[Alpha][y]], HoldForm[Subscript[u, n] = \[Alpha][y]]}},
   Frame -> All]],
  15, FontFamily -> "Times"], 
 ImageSize -> 250]

Mathematica graphics

  • $\begingroup$ Nice. +1 I have overlooked that use of TextCell even though it is in More information... $\endgroup$
    – Mr.Wizard
    Feb 1, 2012 at 1:48

Add the following to your Style options:

     }, Frame -> All]
FontFamily -> "Times",
TextJustification -> 1,
LinebreakAdjustments -> {1, 12, 12, 1, 1}],

ContentSize -> {300, 475}]

LineIndent->0 fixes the left indenting of the 2nd and subsequent lines which is due to the default indenting being set to 1. To get everything else exactly how you want it you will probably have to play around with LinebreakAdjustments.

  • $\begingroup$ you can add TextJustification to your Style options but I suspect you will also need to play around with LinebreakAdjustments $\endgroup$ Jan 31, 2012 at 7:28

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.