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.

4
  • 1
    See the answer to tex.stackexchange.com/q/108224/3954 Apr 12, 2013 at 0:30
  • Trying to change that code to adjust it to my needs gives me errors by compiler. I started learnig Latex this evening and it is rather difficult to me at this point, could you provide any sample?
    – polmarex
    Apr 12, 2013 at 0:38
  • Please post your attempt as a fully compilable (if the syntax errors were corrected) document. Apr 12, 2013 at 0:55
  • @user1091733 sure! Please see my answer. Apr 12, 2013 at 0:58

2 Answers 2

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

0
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

You must log in to answer this question.

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