Equation's symbols or parameters description are shown below, however, the =
and the details of parameter are not aligned.
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
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}
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}
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}
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:”.
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}
\noindent
is a little bit right aligned, when using \indent
it has more spacing compared to the original \indent
value. - KOF
@{\hspace{\parindent}}
at the start of the argument to tabular
(or tabularx
): \begin{tabular}{@{\hspace{\parindent}>{$}l...}
- egreg
\renewcommand{\arraystretch}{1.3}
for Table
entries, so how to make it as default in this cae, 'cause I dont wanna change it. - KOF
\renewcommand{\arraystretch}{1}
to the definition of the environment; you can put it between \par
and \noindent
. - egreg
=
the most used symbol for this? - kiss my armpit
\sim
awhile others =
(see this mixture model) - Amelio Vazquez-Reina
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
\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 box
and an unwanted indent - Fiztban
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
conditions
environment. How can I change this? - Dhruv Ghulati
ltablex
- maetra
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:
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\flushleft
though - KOF
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}
.
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
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:
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:
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.
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
Project on GitHub [2] and brief documentation [3]
[1] https://ctan.org/pkg/eqexpleqexpl
package is already included in texlive 2016? - KOF
CTAN
- Dr Krishnakumar Gopalakrishnan
\eqexplSetItemAlign{l}
in the beginning of the document like this. Briefly described in docs. - Konstantin Morenko
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
=
sign are much too small. - Hendrik Vogt
alignat
doesn't add space between the columns. - Pouya
&{}={}&
instead af &=&
each time to fix the spacing. - Andrew Swann
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
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
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:
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
nomencl
. Actually two I know of:nomentbl
. Or you could even tryglossaries
. It really depends on how much effort you are willing to invest (i.e. writing a book vs short paper). - Count Zeroalign*
and\text
for the stuff after the=
- daleif=
in a fixed vertical position - KOFalign
?&=
- daleif