我想在使用时更改间距\align
。我当前的代码是:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
These are defined as:
\begin{align}
&\text{(Identity)} &d(p,q) &= 0\\
&\text{(Positivity)} &d(p,q) &\geq 0\\
&\text{(Symmetry)} &d(p,q) &= d(q,p)\\
&\text{(Triangle Inequality)} &d(p,r) &\leq d(p,q)
\end{align}
\end{document}
基本上,我希望方程式位于页面的中心,而括号中的描述则更多地位于左侧(但不完全位于左侧)。
答案1
使用alignat
并在左侧列中最长的条目后添加所需的间距:
\documentclass{article}
\usepackage{amsmath}
\usepackage[showframe]{geometry}
\usepackage{eqparbox}
\begin{document}
These are defined as:
\begin{align}
&\text{(Identity)} &d(p,q) &= 0\\
&\text{(Positivity)} &d(p,q) &\geq 0\\
&\text{(Symmetry)} &d(p,q) &= d(q,p)\\
&\text{(Triangle Inequality)} &d(p,r) &\leq d(p,q)
\end{align}
\begin{alignat}{2}
&\text{(Identity)} &d(p,q) &= 0\\
&\text{(Positivity)} &d(p,q) &\geq 0\\
&\text{(Symmetry)} &d(p,q) &= d(q,p)\\
&\text{(Triangle Inequality)} &\qquad d(p,r) &\leq d(p,q)
\end{alignat}
\begin{alignat}{2}
&\llap{\eqmakebox[B][l]{(Identity)}} &d(p,q) &= 0\\
&\llap{\eqmakebox[B][l]{(Positivity)}} &d(p,q) &\geq 0\\
&\llap{\eqmakebox[B][l]{(Symmetry)}} &d(p,q) &= d(q,p)\\
&\llap{\eqmakebox[B][l]{(Triangle Inequality)}} &\qquad d(p,r) &\leq d(p,q)
\end{alignat}
\end{document}
答案2
我只是在注释最长的行上创建另一个字段,并添加该长注释的幻像。在本例中,这意味着在最后一行添加&\phantom{\text{(Triangle Inequality)}}
。
随后我展示了它是如何居中的(减去方程编号)
\documentclass{article}
\usepackage{amsmath}
\begin{document}
These are defined as:
\begin{align}
&\text{(Identity)} &d(p,q) &= 0\\
&\text{(Positivity)} &d(p,q) &\geq 0\\
&\text{(Symmetry)} &d(p,q) &= d(q,p)\\
&\text{(Triangle Inequality)} &d(p,r) &\leq d(p,q)
&\phantom{\text{(Triangle Inequality)}}
\end{align}
\noindent\hfill x\hfill(x)
\end{document}