7

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.

  • 1
    See the answer to tex.stackexchange.com/q/108224/3954 – Gonzalo Medina Apr 12 '13 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? – user1091733 Apr 12 '13 at 0:38
  • Please post your attempt as a fully compilable (if the syntax errors were corrected) document. – Peter Grill Apr 12 '13 at 0:55
  • @user1091733 sure! Please see my answer. – Gonzalo Medina Apr 12 '13 at 0:58
11
\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

5

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.