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}