65

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
  • 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 '13 at 10:34
  • 2
    I'd just use align* and \text for the stuff after the = – daleif Jan 29 '13 at 10:34
  • @daleif, but how to align = in a fixed vertical position – KOF Jan 29 '13 at 10:37
  • Not understood, don't you know align? &= – daleif Jan 29 '13 at 11:13
  • @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. – Jose Enrique Calderon May 24 at 21:05
86

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{array,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

  • The \noindent is a little bit right aligned, when using \indent it has more spacing compared to the original \indent value. – KOF Jan 29 '13 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 '13 at 14:17
  • Besides, how to make the line spacing same as the text line spacing? – KOF Jan 29 '13 at 15:14
  • @KOF It is the same line spacing as in the text. – egreg Jan 29 '13 at 15:17
  • 1
    @Fiztban I added it. – egreg Jan 29 '15 at 13:05
15

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.

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

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}.

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

  • 2
    Note that the spaces around the = sign are much too small. – Hendrik Vogt Jan 29 '13 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 '13 at 11:33
  • Just write &{}={}& instead af &=& each time to fix the spacing. – Andrew Swann Feb 6 '13 at 11:03
3

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

  • The eqexpl package is already included in texlive 2016? – KOF Apr 9 '17 at 1:59
  • No. I've finished it just a month ago. – Konstantin Morenko Apr 9 '17 at 5:16
  • As of today (14/Nov/2018), the package is now available from CTAN – Krishna Nov 14 '18 at 15:56
1

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

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.