# Guy Rutenberg

Keeping track of what I do

## Add Explanation to LaTeX Formulas (Equations)

When writing a document that contains mathematics, many time the need to add an explanation (e.g. stating the theorem used) is raised. To answer this need I wrote two short LaTeX macros: \explain and \explainup.


This macros add the explanation below and above the formula.
The first argument is the relation (actually it can be anything) that needs be explained, for example =. The second argument is the actual explanation.

The macros depend on the mathtools package by

#### Example


Will result in

Written by Guy

January 4th, 2008 at 8:28 pm

Posted in LaTeX

Tagged with

### 4 Responses to 'Add Explanation to LaTeX Formulas (Equations)'

1. Nice one, txs for this.

Kiran SIngh

17 Apr 08 at 02:15

2. That’s grate, Thanks!

But, do you know how I do the following:
\left(\explain{\frac{a}{b}}{\mbox{{\rm The brace wont expand!}}}+c\right)

Here, the () Don’t take the width of the “math” part (without the text in the “explain”) but.. the hight of the explain block (the arrow and the text). Except the ugliness, it make the text unreadable – He intersect with the ( ).
Do you know how I prevent the () to raise?

Thanks,
Ronen.

Ronen

15 Feb 09 at 09:26

3. Hi Ronen,

A quick solution would be to use manual brace size

\bigg(\explain{\frac{a}{b}}{\mbox{{\rm The brace wont expand!}}}+c\bigg)

I currently don’t have a better solution, as the explain environment must be have its full size (or else multiple lines will be clamped together), but the width of the description must be declared as zero (so no extra space will be introduced).

Guy

15 Feb 09 at 10:02

4. Thanks.

Ronen

16 Feb 09 at 22:14