I want to code this equation in LaTeX:
I'd like to know how to code the equation and the description below it with a reference as well.
equationsmath-mode
I want to code this equation in LaTeX:
I'd like to know how to code the equation and the description below it with a reference as well.
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}
A regular align
with some macro-involvement would obtain the desired result:
\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\newcommand{\alignmath}[2]{\makebox[0pt][#1]{$\displaystyle#2$}}
\newcommand{\lmath}[1]{\alignmath{l}{#1}}
\newcommand{\rmath}[1]{\alignmath{r}{#1}}
\newcommand{\cmath}[1]{\alignmath{c}{#1}}
\begin{document}
\begin{align}
& \text{this is my first equation:} & \cmath{z=x} & \\
& \text{this is my second equation:} & \cmath{z=x+y} & \\
& \text{this is my third equation:} & \lmath{z=x+y} & \\
& \text{this is my fourth equation:} & \rmath{z=x+y} & \\
& \text{this is my last equation:} & z &= x+y
\end{align}
\end{document}
\cmath
inserts a zero-width box that is c
entred. The advantage here is that you maintain the align
-like vertical spacing.
I've added \lmath
and \rmath
for completeness, since \makebox
allows for l
eft- and r
ight-aligned boxes. Also, the vertical rule indicates the horizontal alignment with respect to the default align
- also supported in the above syntax.
Best Answer
Even though your question was thoroughly answered here's my solution, it differs only in not using a table but a list:
Which produces the following result: