04.01.08

Add Explanation to LaTeX Formulas (Equations)

Posted in LaTex at 8:28 pm by Guy

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.

\newcommand{\explain}[2]{\underset{\mathclap{\overset{\uparrow}{#2}}}{#1}}
\newcommand{\explainup}[2]{\overset{\mathclap{\underset{\downarrow}{#2}}}{#1}}

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

\documentclass{article}
\usepackage{mathtools}
\makeatletter
 
\newcommand{\explain}[2]{\underset{\mathclap{\overset{\uparrow}{#2}}}{#1}}
\newcommand{\explainup}[2]{\overset{\mathclap{\underset{\downarrow}{#2}}}{#1}}
 
\makeatother
\begin{document}
 
\[
	U_x\explain{=}{\textrm{C.-R.}}V_y\explainup{\geq}{V(x,y)=ye^x}0
\]
 
\end{document}

Will result in

explain-macro.png

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

1 Comment »

  1. Kiran SIngh said,

    April 17, 2008 at 2:15 am

    Nice one, txs for this.

Leave a Comment