105

Equation's symbols or parameters description are shown below, however, the = and the details of parameter are not aligned.

enter image description here

I want to make a parameters list for a equation like this, in which symbols, = and detail information are aligned in terms of vertical position.

where
   ...
   P   =   notional permeability factor
   N   =   number of waves
   Sd  =   damage level
   ...

A tabular environment will produce more spacing before and after text. So how to make the = vertical aligned?

The codes is provided:

\begin{equation}
\frac{H_s}{\Delta D_{n50} } = 1.0~ P^{0.13}~ \left(\frac{S_d}{N} \right)^{0.2} \xi_m^P~ \sqrt{\cot \alpha}
\end{equation}
where: 

$H_s$ = significant wave height, equal to the average of the highest 1/3 of the waves

$\Delta$  = relative buoyant density, equal to $\rho_r / \rho_w - 1$, where     $\rho_w$ is the water density

$D_{n50}$ = nominal  diameter defined in Equation (2)

$P$ = notional permeability factor

$S_d$ = damage level 

$N$ = number of waves

$\xi_m$ = breaker parameter based on mean wave period $T_m$

$\alpha$ = slope angle
5
  • 1
    There is a package for that: nomencl. Actually two I know of: nomentbl. Or you could even try glossaries. It really depends on how much effort you are willing to invest (i.e. writing a book vs short paper).
    – Count Zero
    Jan 29, 2013 at 10:34
  • 5
    I'd just use align* and \text for the stuff after the =
    – daleif
    Jan 29, 2013 at 10:34
  • 1
    @daleif, but how to align = in a fixed vertical position
    – KOF
    Jan 29, 2013 at 10:37
  • Not understood, don't you know align? &=
    – daleif
    Jan 29, 2013 at 11:13
  • 1
    @Count Zero what is the advantage of using Glossaries? I thought this is only use at the end of the book. Please correct me if wrong. May 24, 2019 at 21:05

8 Answers 8

125

Define your own environment for this; here I realize it as a two column alignment; the first column is typeset in math mode, the second one in text mode; the = is added automatically, with the correct spacing.

\documentclass{article}
\usepackage{array}

\newenvironment{conditions}
  {\par\vspace{\abovedisplayskip}\noindent\begin{tabular}{>{$}l<{$} @{${}={}$} l}}
  {\end{tabular}\par\vspace{\belowdisplayskip}}

\begin{document}
An equation just to start
\begin{equation}
P+N=S_{d}
\end{equation}
where:
\begin{conditions}
 P     &  notional permeability factor \\
 N     &  number of waves \\   
 S_{d} &  damage level
\end{conditions}

\end{document}

enter image description

If your conditions are overlong, then you can use a different environment, that I call conditions*, based on tabularx:

\documentclass{article}
\usepackage{tabularx}

\newenvironment{conditions*}
  {\par\vspace{\abovedisplayskip}\noindent
   \tabularx{\columnwidth}{>{$}l<{$} @{${}={}$} >{\raggedright\arraybackslash}X}}
  {\endtabularx\par\vspace{\belowdisplayskip}}

\begin{document}
An equation just to start
\begin{equation}
P+N=S_{d}
\end{equation}
where:
\begin{conditions*}
 P    &  notional permeability factor and something 
          longer that needs to be taken at the next line\\
N     &  number of waves \\
S_{d} &  damage level
\end{conditions*}

\end{document}

enter image description here


Variant for variable symbols

If different symbols are needed instead of = in each line, here's how.

\documentclass{article}
\usepackage{array,tabularx}

\newenvironment{conditions}
  {\par\vspace{\abovedisplayskip}\noindent
   \begin{tabular}{>{$}l<{$} @{} >{${}}c<{{}$} @{} l}}
  {\end{tabular}\par\vspace{\belowdisplayskip}}

\newenvironment{conditions*}
  {\par\vspace{\abovedisplayskip}\noindent
   \tabularx{\columnwidth}{>{$}l<{$} @{}>{${}}c<{{}$}@{} >{\raggedright\arraybackslash}X}}
  {\endtabularx\par\vspace{\belowdisplayskip}}

\begin{document}
An equation just to start
\begin{equation}
P+N=S_{d}
\end{equation}
where:
\begin{conditions}
 P     & =       &  notional permeability factor \\
 N     & \sim    &  number of waves \\
 S_{d} & \propto & damage level
\end{conditions}

An equation just to start
\begin{equation}
P+N=S_{d}
\end{equation}
where:
\begin{conditions*}
 P     & =       & notional permeability factor and something 
                   longer that needs to be taken at the next line\\
 N     & \sim    & number of waves \\
 S_{d} & \propto & damage level
\end{conditions*}

\end{document}

enter image description here


In order to have no break after “where:”, here's a variant of the first solution:

\documentclass{article}
\usepackage{array}

\newenvironment{conditions}[1][where:]
  {#1 \begin{tabular}[t]{>{$}l<{$} @{${}={}$} l}}
  {\end{tabular}\\[\belowdisplayskip]}

\begin{document}
An equation just to start
\begin{equation}
P+N=S_{d}
\end{equation}
\begin{conditions}
 P     &  notional permeability factor \\
 N     &  number of waves \\
 S_{d} &  damage level
\end{conditions}
Some text after the equation.

\end{document}

The conditions environment has an optional argument for changing the fixed where:; so, for instance, \begin{conditions}[with:] will use “with:”.

enter image description here

A different version that allows for longer descriptions that needs to be wrapped across lines:

\documentclass{article}
\usepackage{array,tabularx,calc}

\newlength{\conditionwd}
\newenvironment{conditions}[1][where:]
  {%
   #1\tabularx{\textwidth-\widthof{#1}}[t]{
     >{$}l<{$} @{${}={}$} X@{}
   }%
  }
  {\endtabularx\\[\belowdisplayskip]}

\begin{document}
An equation just to start
\begin{equation}
P+N=S_{d}
\end{equation}
\begin{conditions}
 P     &  notional permeability factor with some more text
          so this ends up to break across lines blah blah
          blah blah\\
 N     &  number of waves \\
 S_{d} &  damage level
\end{conditions}
Some text after the equation.

\end{document}

enter image description here

21
  • The \noindent is a little bit right aligned, when using \indent it has more spacing compared to the original \indent value.
    – KOF
    Jan 29, 2013 at 13:54
  • I did it on purpose; if you want to have the same indentation, add @{\hspace{\parindent}} at the start of the argument to tabular (or tabularx): \begin{tabular}{@{\hspace{\parindent}>{$}l...}
    – egreg
    Jan 29, 2013 at 14:17
  • Besides, how to make the line spacing same as the text line spacing?
    – KOF
    Jan 29, 2013 at 15:14
  • @KOF It is the same line spacing as in the text.
    – egreg
    Jan 29, 2013 at 15:17
  • 1
    @Fiztban I added it.
    – egreg
    Jan 29, 2015 at 13:05
21

As daleif suggested you could use the align* environment. You get the alignment just like in tables with '&'. Here is an example:

\documentclass{article}
\usepackage[fleqn]{amsmath}
\begin{document}

\begin{align*}
    H_s &= \text{significant wave height, equal to the average of the highest 1/3 of
    the waves}\\
    \Delta &= \text{relative buoyant density, equal to }\rho_r\text{ / }\rho_w - 
    1\text{, where }\rho_w\text{ is the water density}\\
    D_{n50} &= \text{nominal  diameter defined in Equation \eqref{eq:dn50g50}}\\
    P &= \text{notional permeability factor}\\
    S_d &= \text{damage level}\\
    N &= \text{number of waves}\\
    \xi_m &= \text{breaker parameter based on mean wave period }T_m\\
    \alpha &= \text{slope angle}
\end{align*}
\end{document}

This should work for you. This is the output: Output

If you don't want all equations to be aligned left, you can use the flalign* environment, like suggested here.

1
  • thanks Dave, the symbols should be \flushleft though
    – KOF
    Jan 29, 2013 at 11:30
13

Another option is to use the tabbing environmnent:

\begin{equation}
\frac{H_s}{\Delta D_{n50} } = 1.0~ P^{0.13}~ \left(  \frac{S_d}{N} \right)^{0.2}  \xi_m^P~ \sqrt{\cot \alpha}
\end{equation}
where: 
\begin{tabbing}
\phantom{$D_{n50}\ $}\= \kill
$H_s$\> = significant wave height, equal to the average of the highest 1/3 of the waves\\
$\Delta$\> = relative buoyant density, equal to $\rho_r / \rho_w - 1$, where     $\rho_w$ is the water density\\
$D_{n50}$\> = nominal  diameter defined in Equation \eqref{eq:dn50g50}\\
$P$\> = notional permeability factor\\
$S_d$\> = damage level\\
$N$\> = number of waves\\
$\xi_m$\> = breaker parameter based on mean wave period $T_m$\\
$\alpha$\> = slope angle\\
\end{tabbing}

The first line in the tabbing environment will set the spacing (i.e. tabstop). The \kill command suppresses the line it precedes, otherwise you would have an extra space between 'where:' and the first definition.

Alternatively, instead of \phantom{$D_{n50}\ $} (the longest item on your list), you can use a fixed width: \hspace{3cm}.

0
6

This is an old post but all of the solutions require the equation and the explanations to be given separately. I prefer to have a single environment that combines the equation and the explanation of its variables.

The code below defines a new formula environment where you specify the formula as the first argument and give the explanation of the variables as a comma separated list in the body of the environment. For example, the code,

\begin{formula}{P+N=S_{d}}
 P    : notional permeability factor,
 N    : number of waves,
 S_{d}: damage level
\end{formula}

produces

enter image description here

Inspired by egreg's nice answer, there are additional arguments. You can use an exclamation mark if you want a line break after the where: and you can change the where: into anything you like using the (second) optional argument. So

\begin{formula}![where the wonderful notation we are using is:]{P+N=S_{d}}
 P    : notional permeability factor,
 N    : number of waves,
 S_{d}: damage level
\end{formula}

produces:

enter image description here

Additionally, there is a formula* variant that works in exactly the same way except that it does not print an equation number. For example, to display the formula in the OP we could use:

\begin{formula*}!{
   \frac{H_s}{\Delta D_{n50} } = 1.0~ P^{0.13}~ \left(\frac{S_d}{N} \right)^{0.2}
                \xi_m^P~ \sqrt{\cot \alpha}
  }
  H_s: {significant wave height, equal to the average of the highest 1/3 of the waves},
  \Delta:  {relative buoyant density, equal to $\rho_r / \rho_w - 1$, where
             $\rho_w$ is the water density},
  D_{n50}: nominal  diameter defined in Equation (2),
  P: notional permeability factor,
  S_d: damage level,
  N: number of waves,
  \xi_m: breaker parameter based on mean wave period $T_m$,
  \alpha: slope angle,
\end{formula*}

produces:

enter image description here

Notice that it is necessary to enclose the variable explanations that contain commas inside braces.

Here is the full code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}
\usepackage{xparse}

% add a single explanation line - #3 gobbles any extra garbage
\def\ExplainVariable#1:#2:#3!!!{$#1$ &$\;\;=$ #2 \\}

\NewDocumentEnvironment{formula}{ t! O{where:} m b }{%
 \begin{equation}#3\end{equation}
  #2 \IfBooleanT{#1}{\\[1ex]}
  \renewcommand*\do[1]{\ExplainVariable##1::!!!}%
  \tabular[t]{r@{}l}\docsvlist{#4}\endtabular
}{}
\NewDocumentEnvironment{formula*}{ t! O{where:} m b }{%
 \begin{equation*}#3\end{equation*}
  #2 \IfBooleanT{#1}{\\[1ex]}
  \renewcommand*\do[1]{\ExplainVariable##1::!!!}%
  \tabular[t]{r@{}l}\docsvlist{#4}\endtabular
}{}

\begin{document}

  \begin{formula}{P+N=S_{d}}
     P    : notional permeability factor,
     N    : number of waves,
     S_{d}: damage level
  \end{formula}

  \bigskip

  \begin{formula}![where the wonderful notation we are using is:]{P+N=S_{d}}
     P    : notional permeability factor,
     N    : number of waves,
     S_{d}: damage level
  \end{formula}

  \bigskip

  \begin{formula*}{
     \frac{H_s}{\Delta D_{n50} } = 1.0~ P^{0.13}~ \left(\frac{S_d}{N} \right)^{0.2}
                  \xi_m^P~ \sqrt{\cot \alpha}
    }
    H_s: {significant wave height, equal to the average of the highest 1/3 of the waves},
    \Delta:  {relative buoyant density, equal to $\rho_r / \rho_w - 1$, where
               $\rho_w$ is the water density},
    D_{n50}: nominal  diameter defined in Equation (2),
    P: notional permeability factor,
    S_d: damage level,
    N: number of waves,
    \xi_m: breaker parameter based on mean wave period $T_m$,
    \alpha: slope angle,
  \end{formula*}

\end{document}

The basic idea to parse the body of the formula environment using \docsvlist from the etoolbox package.

1
5

When I've faced this problem, I wrote the package eqexpl (since 14 Nov 2018 it is available on CTAN). With it you could add in preamble

\usepackage{eqexpl}
\eqexplSetIntro{where:} % set parenthesis in the left of the first item
\eqexplSetDelim{=} % set delimiter to "="

and then in document

\begin{eqexpl}
  \item{P} notional permeability factor
  \item{N} number of waves
  \item{$S_d$} damage level
\end{eqexpl}

With this in preamble

\usepackage{eqexpl}
\eqexplSetDelim{=}

and this in the document

\begin{eqexpl}[25mm]
  \item{$H_s$} significant wave height, equal to the average of the
    highest 1/3 of the waves
  \item{$\Delta$} relative buoyant density, equal to $\rho_r / \rho_w - 1$,
    where $\rho_w$ is the water density
  \item{$D_{n50}$} nominal diameter defined in Equation (2)
\end{eqexpl}

you'll get

result

Project on GitHub and brief documentation

5
  • The eqexpl package is already included in texlive 2016?
    – KOF
    Apr 9, 2017 at 1:59
  • No. I've finished it just a month ago. Apr 9, 2017 at 5:16
  • As of today (14/Nov/2018), the package is now available from CTAN Nov 14, 2018 at 15:56
  • Here, the notations are aligned from the right side. How is it possible to start all notations from the left side (all notations are left-aligned) and all definitions are also left-aligned?
    – Amin
    Jan 16, 2022 at 1:00
  • 1
    @Katatonia, set \eqexplSetItemAlign{l} in the beginning of the document like this. Briefly described in docs. Jan 21, 2022 at 8:37
3

I think you can try fairly easy to use alignat environment:

\documentclass{minimal}
\usepackage{amsmath}
\begin{document}

    \begin{alignat*}{3}
      &A   &= &e^{\pi}  \\
      &AB  &= &\sqrt{x} \\
      &ABC &= & \text{An equation with three letters on the left!}
    \end{alignat*}

\end{document}

Resulting in

enter image description here

3
  • 2
    Note that the spaces around the = sign are much too small. Jan 29, 2013 at 11:25
  • @HendrikVogt, You are right! I noticed and searched for the reason. Based on this answer, alignat doesn't add space between the columns.
    – Pouya
    Jan 29, 2013 at 11:33
  • Just write &{}={}& instead af &=& each time to fix the spacing. Feb 6, 2013 at 11:03
2

In this case, where there are lots of text on the right, tabular with symbol separation would have been sufficient (and simpler):

\begin{tabular}{l @{ $=$ } l}
$P$ & notional permeability factor\\
$N$ & number of waves\\
$S_d$ & damage level \\
$f(x,y,z)$ & distribution
\end{tabular}

Resulting in

enter image description here

It should be possible to replace @{ $=$ } with !{=} since the ! adds space before and after the separator but I can't get it work.

Ps: thanks to siteduzero.com

1
2

I created an Excel based solution to maintain symbols definitions, units and equations in an Excel worksheet. This Excel workbook generates LaTeX code to use in your document.

The Excel sheet automatically generates the right code for parameter definitions when you enter an equation.

This sheet can help you with a pleasant workflow in creating the parameter descriptions and saves manual work.

I chose a layout in which symbol units are also added. Here's an example:

enter image description here

I created a Github project to maintain this Excelsheet and accompanying .tex files and make it available to others: https://github.com/johanf85/Symbollist-maintain-Excel

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .