![第一种方法](https://linux22.com/image/469218/%E7%AC%AC%E4%B8%80%E7%A7%8D%E6%96%B9%E6%B3%95.png)
此外沃纳的回答,我还希望我的列表标签使用表格数字。
我原本认为下面的第一种方法可行,但列表标签稍微位于左边距。
但是,第二种更麻烦的方法似乎有效。就好像直到测量完最后一个标签的宽度后才应用表格数字一样。
有没有办法让第一种方法奏效,而无需诉诸第二种方法?或者有更好的方法来实现这一点?
第一种方法
\documentclass{article}
\usepackage{showframe}
\usepackage{calc}
\usepackage{fontspec}
\setmainfont{EBGaramond-Regular}[
Numbers={Proportional, OldStyle},
]
\usepackage{enumitem}
\setlist[enumerate]{font=\normalfont\addfontfeatures{Numbers=Tabular}}
\begin{document}
\begin{enumerate}[
labelindent=0pt,
labelwidth=\widthof{\ref{last-item}},
label={\arabic*.},
leftmargin=!,
]
\item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\item Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\item Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \addtocounter{enumi}{9997}
\item Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \label{last-item}
\end{enumerate}
\end{document}
第二种方法
\documentclass{article}
\usepackage{showframe}
\usepackage{calc}
\usepackage{fontspec}
\setmainfont{EBGaramond-Regular}[
Numbers={Proportional, OldStyle},
]
\usepackage{enumitem}
\setlist[enumerate]{font=\normalfont\addfontfeatures{Numbers=Tabular}}
\begin{document}
\begin{enumerate}[
labelindent=0pt,
labelwidth=\widthof{\ref{last-item}},
label={\addfontfeatures{Numbers=Tabular}\arabic*.},
leftmargin=!,
]
\item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\item Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\item Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \addtocounter{enumi}{9997}
\item Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \label{last-item}
\end{enumerate}
\end{document}
答案1
您还想在要测量的框中说明字体。
相反\addfontfeatures
,我建议定义一个字体系列。
\documentclass{article}
\usepackage{fontspec}
\usepackage{enumitem}
\usepackage{calc}
\usepackage{showframe}
\setmainfont{EBGaramond}[
Numbers={Proportional, OldStyle},
]
\newfontfamily{\ebgaramondtabular}{EBGaramond}[
Numbers={Tabular,OldStyle}
]
\setlist[enumerate]{font=\normalfont\ebgaramondtabular}
\begin{document}
\begin{enumerate}[
labelindent=0pt,
labelwidth=\widthof{\ebgaramondtabular\ref{last-item}},
label=\arabic*.,
leftmargin=!,
]
\item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\item Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
\item Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.
\addtocounter{enumi}{9997}
\item Excepteur sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est laborum.\label{last-item}
\end{enumerate}
\noindent{\ebgaramondtabular 10001}
\noindent 10001
\end{document}