9

How to make enumerate list format numbers like this:

REG/001 (content)

REG/002 (content)

REG/003 (content)

I already managed to do the following:

\begin{enumerate}[label=\textbf{REG/\arabic*},leftmargin=*]
\item content
\end{enumerate}

using

\usepackage{enumitem}

but I don't know how to add leading zeros.

cmhughes
  • 100,947
polmarex
  • 235

2 Answers2

13
\documentclass{article}
\usepackage{enumitem}

\def\threedigits#1{%
  \ifnum#1<100 0\fi
  \ifnum#1<10 0\fi
  \number#1}

\begin{document}

\begin{enumerate}[label={\textbf{REG/\protect\threedigits{\theenumi}}},leftmargin=*]
\item content
\item content
\item content
\end{enumerate}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
6

Here is another variant of the same concept that makes use of \AddEnumerateCounter

\documentclass[10pt]{article}

\usepackage{enumitem}

\makeatletter
\def\threedigits#1{\expandafter\@threedigits\csname c@#1\endcsname}
\def\@threedigits#1{%
  \ifnum#1<100 0\fi
  \ifnum#1<10 0\fi
  \number#1}
\makeatother
\AddEnumerateCounter{\threedigits}{\@threedigits}{100}

\begin{document}

\begin{enumerate}[label=REG/\threedigits*,leftmargin=*]
\item This is an  item.
\item Another item.
\item Here is another item.
\item 
\item 
\item 
\item 
\item 
\item 
\item 
\end{enumerate}

\end{document}

enter image description here

hpesoj626
  • 17,282