33

Say I have an equation:

x = R + E

What's the best way to provide a definition for R and E? Is there a way to include a line under the equation saying what the variables mean (i.e. a "where" clause)? Example:

x = R + E
where R is Racoon, E is Elephant

migrated from stackoverflow.com Nov 29 '11 at 11:46

This question came from our site for professional and enthusiast programmers.

27

Since mathematics (in general) should form part of the textual flow, one can follow an equation with symbol explanations. This would even include proper punctuation in the equation itself:

enter image description here

\documentclass{article}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac velit dolor. 
Nulla nunc dolor, commodo sed consectetur ac, dapibus malesuada odio. 
Mauris porta libero eget nisi placerat quis bibendum tellus fermentum. It is therefore
possible to define the relationship
\[
  x = R + E,
\]
where~$R$ is a racoon and~$E$ is an elephant. Sed suscipit tristique laoreet. 
Nulla mi orci, rutrum sed dapibus sed, elementum nec lacus. 
Phasellus id tellus mi, at rutrum justo. Nullam eget turpis justo, ullamcorper 
pretium mauris.
\end{document}

This, in my opinion, is the best way to declare variables or symbols used in an equation. However, if need be, it is possible "to include a line under the equation saying what the variables mean." I'm not sure whether this is the "best way" though:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac velit dolor. 
Nulla nunc dolor, commodo sed consectetur ac, dapibus malesuada odio. 
Mauris porta libero eget nisi placerat quis bibendum tellus fermentum. It is therefore
possible to define the relationship
\begin{gather*}
  x = R + E, \\
  \text{where~$R$ is Racoon,~$E$ is Elephant}
\end{gather*}
Sed suscipit tristique laoreet. 
Nulla mi orci, rutrum sed dapibus sed, elementum nec lacus. 
Phasellus id tellus mi, at rutrum justo. Nullam eget turpis justo, ullamcorper 
pretium mauris.  It is therefore
possible to define the relationship
\begin{align*}
  x &= R + E, \\
  \text{where}~R &= \text{Racoon,} \\
  E &= \text{Elephant}
\end{align*}
\end{document}

amsmath provides the mathematical alignment environments (align* and gather).

  • Thanks, exactly what I was looking for. Kudos to you for providing multiple examples. – user963396 Nov 29 '11 at 8:21
  • How would I adapt this to make this equation numbered, unlike what align* does? If I do \text{where}~R &= \text{Racoon,} \` in an align` environment, the description would be added as a new equation which is not what I want. – Dhruv Ghulati Aug 24 '16 at 21:02
  • 1
    @DhruvGhulati: You can use align and add \nonumber to each equation you don't want numbered. – Werner Aug 24 '16 at 21:17
  • Although this is the traditional approach, I do strongly object. I find it problematic to have the definitions follow the equation in an undefined manner. Sometimes they're missing, sometimes there is a sentence about something different inserted before. And in both cases you do not know whether you will find them if you read on, but are in a state of uncertainty. A constant way of putting the definitions in a place where you can see them at first glance (or see that they're missing), will make reading mathematical texts much easier. – ziggystar Dec 15 '17 at 7:36
  • @ziggystar: Okay...? Nothing in the question nor my answer puts any length of content between the definition and their symbol explanation. – Werner Dec 15 '17 at 17:01
8

Although I think Werner's answer is the best guideline in general terms, sometimes I need to define variables of an equation in cases that are not publishing papers (i.e. making a presentation with slides or writing a course handbook). In those cases I tend to use the description environment, customizing its label so that it acts as inline math.

In the article class you could redefine the description label using:

\renewcommand*\descriptionlabel[1]{\hspace\leftmargin$#1$}

and then use the description environment to define the variables, such as in the following example:

\documentclass{article}
\renewcommand*\descriptionlabel[1]{\hspace\leftmargin$#1$}
\begin{document}
It is very unusual to characterize some unknown variable $x$ in terms of animal species,
such as the following:
\[x = R + E\]
where:
\begin{description}
\item[R] is Racoon
\item[E] is Elephant
\end{description}
\end{document}

which yields the following output:

Description environment for variables of an equation

I don't know if its the 'correct' way, but it's very easy to implement, suits my needs and doesn't use the usual itemize environment, which I prefer to leave out for regular text.

3

I´m new to latex but I think you can do it using itemize:

\[x = R + E\]
where:
\begin{itemize}
\item[R=] is Racoon
\item[E=] is Elephant
\end{itemize}

I don´t know if itemize is supposed to be used like this, but it works very well for this purpose, particularly if you have a long list of variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.