我正在编写一个文档,需要指定一些数学方程式中不同变量的含义。我正在处理我在论坛中找到的这段代码(该帖子实际上已有 8 年历史),无论如何我都找不到将变量居中的方法。
以下是代码示例:
\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 \\
N & number of waves \\
S_{d} & damage level
\end{conditions*}
\end{document}
我想要获得一个居中的列表。
谢谢你!
回复@Bernard
\documentclass{article}
\usepackage{mathtools}
\begin{document}
An equation just to start
\begin{gather}
P+N=S_{d} \\
\shortintertext{\indent where:}
\begin{aligned}
P & = \text{This is an example where the variable or the parameter could require a longer definition. The width exceed the margins and the linebreak doesn't work.} \\
N & = \text{number of waves} \\
S_{d} & = \text{damage level}
\end{aligned}\notag
\end{gather}
\end{document}
这就是结果:
最好的情况是这种对齐方式:
但更加居中,从而减少了断线的空间。
答案1
我建议使用以下其中一种解决方案,其aligned
环境嵌套在gather
:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
An equation just to start
\begin{gather}
P+N=S_{d} \\
\shortintertext{where:}
\begin{aligned}
P & = \text{notional permeability factor} \\
N & = \text{number of waves} \\
S_{d} & = \text{damage level}
\end{aligned}\notag
\end{gather}
\begin{gather}
P+N=S_{d} \\
\begin{aligned}
& \text{where:}\qquad & P & = \text{notional permeability factor} \\
& & N & = \text{number of waves} \\
& & S_{d} & = \text{damage level}
\end{aligned}\notag
\end{gather}
\end{document}