如何才能使下列按字母顺序列出的项目右侧的“标签”(对称性)、(可加性)等在其左侧对齐,如箭头所示?
\documentclass{memoir}
\usepackage{enumitem}
\newenvironment{alphenum}
{\begin{enumerate}[label= \sffamily\upshape(\alph*)]}
{\end{enumerate}}
\begin{document}
\begin{alphenum}
\item
$\langle x, y\rangle = \langle y, x\rangle$ for all $x, y$. (symmetry)
\item
$\langle x + y, z\rangle = \langle x, z\rangle + \langle y, z\rangle$ for all $x, y, z$. (additivity)
\item
$\langle\lambda x, y\rangle = \lambda \langle x, y\rangle$ for all $\lambda$ and all $x, y$.
(homogeneity)
\end{alphenum}
\end{document}
这是类似问题的一个更简单的版本如何对齐枚举列表中项目的“标签”?。
答案1
这是使用该eqparbox
软件包的解决方案:我定义了一个\eqmathbox
命令,其内容为数学模式,使用标签作为可选参数。所有共享相同标签的框的长度都是这些框中最长的一个。当然,这需要两次编译。
\documentclass{memoir}
\usepackage{amsmath}
\usepackage{enumitem}
\newenvironment{alphenum}
{\begin{enumerate}[label= \sffamily\upshape(\alph*)]}
{\end{enumerate}}
\usepackage{eqparbox}
\newcommand{\eqmathbox}[2][M]{\eqmakebox[#1][l]{$#2$}}
\begin{document}
\begin{alphenum}
\item
\eqmathbox{\langle x, y\rangle = \langle y, x\rangle \text{ for all } x, y.} (symmetry)
\item
\eqmathbox{\langle x + y, z\rangle = \langle x, z\rangle + \langle y, z\rangle \text{ for all } x, y, z.\qquad} (additivity)
\item
\eqmathbox{\langle\lambda x, y\rangle = \lambda \langle x, y\rangle\text{ for all }\lambda \text{ and all }x, y.}
(homogeneity)
\end{alphenum}
\end{document}
答案2
像这样吗?
\documentclass{memoir}
\usepackage{enumitem,calc}
\newenvironment{alphenum}%
{\begin{enumerate}[label= \sffamily\upshape(\alph*),left=0pt]}%
{\end{enumerate}}
\newcommand\RHSbox[1]{\hfill\parbox{\widthof{(homogeneity)}}{#1}}
\begin{document}
\begin{alphenum}
\item
$\langle x, y\rangle = \langle y, x\rangle$
for all $x$ and $y$. \RHSbox{(symmetry)}
\item
$\langle x + y, z\rangle = \langle x, z\rangle + \langle y, z\rangle$
for all $x$, $y$, and $z$. \RHSbox{(additivity)}
\item
$\langle\lambda x, y\rangle = \lambda \langle x, y\rangle$
for all $\lambda$ and all $x$ and $y$. \RHSbox{(homogeneity)}
\end{alphenum}
\end{document}