1

In addition to Werner's answer, I would also like my list labels to use tabular numbers.

I would have thought that the first approach below would work, but the list labels are slightly in the left margin.

However, the second more cumbersome approach seems to work. It is as if the tabular numbers aren't applied until after the width of the last label has been measured.

Is there some way to make the first approach work without resorting to the second? Or is there a better way to achieve this?

First approach

\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}

First approach

Second approach

\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}

Second approach

1 Answer 1

3

You want to state the font also in the box to measure.

Instead of \addfontfeatures, I suggest defining a font family.

\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}

enter image description here

4
  • Why do you suggest defining a font family instead of adding a feature?
    – Fredrik P
    Sep 24 at 16:57
  • @FredrikP Efficiency.
    – egreg
    Sep 24 at 19:26
  • In typing? Or in font loading? Or something else? (To me personally, \addfontfeatures gives mental order.)
    – Fredrik P
    Sep 24 at 20:16
  • 1
    @FredrikP Font loading: nothing needs to be recomputed on the fly.
    – egreg
    Sep 24 at 20:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .