![关于枚举和标签扩展的困惑](https://linux22.com/image/352600/%E5%85%B3%E4%BA%8E%E6%9E%9A%E4%B8%BE%E5%92%8C%E6%A0%87%E7%AD%BE%E6%89%A9%E5%B1%95%E7%9A%84%E5%9B%B0%E6%83%91.png)
documentclass{article}
\usepackage{enumitem}
\begin{document}
\newcounter{entry}
\setcounter{entry}{1000}
\newcommand{\xlistformat}[1]{\theentry.~(#1)} % This is the interesting part
\newlist{xlist}{enumerate}{1}
\setlist[xlist]{
label = {\xlistformat{\alph*}},
leftmargin = *,
align = left
}
\begin{xlist}
\item Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna.
\end{xlist}
\end{document}
我可以通过改变来让它工作
\newcommand{\xlistformat}[1]{\theentry.~(#1)}
到
\makeatletter
\newcommand{\xlistformat}[1]{\number\c@entry.~(#1)}
\makeatother
但这还引发了许多其他问题。
我不确定我需要改变什么才能让它工作。我试过用 键format
代替label
,但结果基本相同。我猜是 的扩展出了问题\theentry
,但我在这方面的实验没有结果。
答案1
使用widest
密钥:
\documentclass{article}
\usepackage{enumitem, fmtcount, siunitx}
\usepackage[showframe]{geometry}
\begin{document}
\newcounter{entry}
\setcounter{entry}{100000000}
\newlength\entrylg\settowidth{\entrylg}{\theentry.}
\newcommand{\xlistformat}[1]{\theentry.~(#1)} % This is the interesting part
\newlist{xlist}{enumerate}{1}
\setlist[xlist]{
label = {\xlistformat{\alph*}},
widest = \makebox[\entrylg]{},
align=left,
leftmargin =*,
}
\begin{xlist}
\item Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna.
\setcounter{xlisti}{12}
\item Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget,
consectetuer id, vulputate a, magna.
\end{xlist}
\end{document}