share
TeX - LaTeXHow to write a perfect equation parameters description?
[+108] [8] KOF
[2013-01-29 10:30:41]
[ equations lists ]
[ https://tex.stackexchange.com/questions/95838/how-to-write-a-perfect-equation-parameters-description ]

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
(5) I'd just use align* and \text for the stuff after the = - daleif
(1) @daleif, but how to align = in a fixed vertical position - KOF
Not understood, don't you know align? &= - daleif
(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. - Jose Enrique Calderon
[+128] [2013-01-29 10:55:49] egreg [ACCEPTED]

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


The \noindent is a little bit right aligned, when using \indent it has more spacing compared to the original \indent value. - KOF
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
Besides, how to make the line spacing same as the text line spacing? - KOF
@KOF It is the same line spacing as in the text. - egreg
I forgot I have defined \renewcommand{\arraystretch}{1.3} for Table entries, so how to make it as default in this cae, 'cause I dont wanna change it. - KOF
@KOF Just add \renewcommand{\arraystretch}{1} to the definition of the environment; you can put it between \par and \noindent. - egreg
What is the proper symbol between the variable and the first character of the variable description? Is = the most used symbol for this? - kiss my armpit
@Karl'sstudents I'd say so. - egreg
This is great. Thanks @egreg. I wonder, how could one mix operators in the definitions? I need some lines to use \sim awhile others = (see this mixture model) - Amelio Vazquez-Reina
@user815423426 You need to add another column. I added it to my answer. - egreg
@egreg thank you for your solution, it's neat and user friendly. I was wondering if there is a way to have the where: on the same line as the first defined parameter and allow the width of the word define the indent for the tabular? Or maybe have the where: in a further column preceding the current tabular without it repeating on every line? - Fiztban
(1) @Fiztban I added it. - egreg
@egreg thank you ever so much have a good day! - Fiztban
@egreg sorry to be a bother again, I tried to adapt your command to my situation (I am using \doublespace for my text) and I would like the parameters to be defined in \singlespace when I write it as follows the where: becomes unwantedly indented \newenvironment{conditions}[1][where:]{\singlespace#1 \begin{tabular}[t]{>{$}l<{$} @{${}:{}$} l}}{\doublespace\end{tabular}\\[\belowdisplayskip]}. I similarly tried to adapt conditions* to do the same but encountered errors of overfull boxand an unwanted indent - Fiztban
@Fiztban Please, make a new question - egreg
my adaptation of the conditions* command was \newenvironment{conditions*}[1][where:]{#1 \begin{tabular}[t]{>{$}l<{$} @{}>{${}}c<{{}$}@{} l}}{\end{tabular}\\[\belowdisplayskip]}. Thank you in advance if you are able to indulge my lack of expertise with LaTeX commands. - Fiztban
@egreg I will do - Fiztban
@egreg please find the question here thank you. - Fiztban
Hi, @egreg, if I have a definition longer than a line it goes beyond the margins of my page with the conditions environment. How can I change this? - Dhruv Ghulati
@DhruvGhulati Sure you can! See the edit. :) - egreg
@egreg, nice solution, but not compatible with ltablex - maetra
1
[+21] [2013-01-29 10:55:21] Dave

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

[1] https://tex.stackexchange.com/questions/14080/use-flalign-or-alignat-or-align-or-similar-environment-to-align-to-the-left

thanks Dave, the symbols should be \flushleft though - KOF
2
[+13] [2013-01-29 11:03:22] Count Zero

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
[+6] [2020-01-23 21:30:09] user30471

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 [1] package.

[1] https://www.ctan.org/pkg/etoolbox

I very much liked your idea, but it doesnt work with KOMA classes, see here: tex.stackexchange.com/questions/367418/… I'd be happy if you find a solution for this :) - Felix Phl
4
[+5] [2017-04-06 13:57:47] Konstantin Morenko

When I've faced this problem, I wrote the package eqexpl [1] (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 [2] and brief documentation [3]

[1] https://ctan.org/pkg/eqexpl
[2] https://github.com/konstantin-morenko/latex-equation-explanation
[3] https://konstantin-morenko.github.io/latex-equation-explanation/

The eqexpl package is already included in texlive 2016? - KOF
No. I've finished it just a month ago. - Konstantin Morenko
As of today (14/Nov/2018), the package is now available from CTAN - Dr Krishnakumar Gopalakrishnan
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
(1) @Katatonia, set \eqexplSetItemAlign{l} in the beginning of the document like this. Briefly described in docs. - Konstantin Morenko
5
[+3] [2013-01-29 11:06:28] Pouya

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
@HendrikVogt, You are right! I noticed and searched for the reason. Based on this answer, alignat doesn't add space between the columns. - Pouya
Just write &{}={}& instead af &=& each time to fix the spacing. - Andrew Swann
6
[+2] [2013-08-06 12:10:21] Tsathoggua

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


(2) Isn't this basically the same as @egreg's solution? - cgnieder
7
[+2] [2020-01-06 13:13:18] JohnShape

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


8