Hi,
I think I've found a better solution for adding explanation to formulas
problem, I asked about a month ago. I thought it might be useful to others
as well.
On Nov 15, 2007 6:36 AM, Eran Tromer <[log in to unmask]> wrote:
> Hi Guy,
>
> 2007-11-14 14:55, Guy Rutenberg wrote:
> > I want to add an explanation to a formula/equality (e.g. stating the
> > theorem used). I'm looking for something like the second formula in the
> > attached image. But the closest I've got is the first formula. The latex
> > code for the first formula is:
> >
> > \[ |a+b|\begin{array}[t]{c}\leq \\\ \uparrow \\\ \textrm{triangle
> > inequality}\end{array}|a|+|b| \leq bla bla bla\]
> >
> > I'm looking for a way to make it look like the second formula (the
> > correct way). I know it might be possible to use negative spaces, but
> > I'm looking for a cleaner solution.
> >
>
> Try this on:
> [...snipped...]
> % \explain{foo}{bar} --- puts bar centered below foo with an arrow
> pointing up
> \newcommand{\explain}[2]{\mathop{\vtop{\m@th\ialign{##\crcr
> $\hfil\displaystyle{#1}\hfil$\crcr
> $\hfil\displaystyle{\uparrow}\hfil$\crcr
> $\hfil\displaystyle{\mathclap{#2}}\hfil$\crcr}}}}
[...snipped...]
>
> Eran
\documentclass{article}
\usepackage{mathtools}
\makeatletter
% \explain{foo}{bar} --- puts bar centered below foo with an arrow pointing
up
\newcommand{\explain}[2]{\underset{\mathclap{\overset{\uparrow}{#2}}}{#1}}
\makeatother
\begin{document}
\[ |a+b|
\explain{\leq}{\textrm{triangle inequality}}
|a|+|b| \leq bla bla bla
\]
\end{document}
I thing the output looks more correct this way. Also the size of the
explanation and the arrow is more suitable.
Eran, many thanks for your help.
Regards,
Guy