1

I've been trying to make an enumerate environment with this format: "N09 P###.", where ### is a list of zero-padded items from 1 to 200 (001-200). I was using this answer to help me with this, but it puts a space between "P" and "###". While trying to find another solution, I found this answer that allows for 2 zero-padded digits, but it doesn't work when I try to convert it to three digits. If anyone can help me with this, it would be greatly appreciated.

Image of what my PDF currently looks like:

Current Output, "N09 P ###." format

2 Answers 2

0

This is based on your first link.

\documentclass[12pt, a4paper]{article}

\usepackage{enumitem}

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

\begin{document}    
    
    \begin{enumerate}[label={\textbf{N09\ P\protect\threedigits{\theenumi}}}, leftmargin = *]%<<<<<<<<<< changed
        \item 
        \item   
        \item
        \item 
        \item 
        \item   
        \item
        \item
        \item 
        \item   
    \end{enumerate}
    
\end{document}

a

1
0

I'd register a new numeric representation and define a new environment.

\documentclass[12pt, a4paper]{article}

\usepackage{enumitem}

\makeatletter
\newcommand{\arabicthreedigits}[1]{\expandafter\@arabicthreedigits\csname c@#1\endcsname}
\newcommand{\@arabicthreedigits}[1]{%
  \ifnum#1<100 0\fi
  \ifnum#1<10 0\fi
  \number#1%
}
\AddEnumerateCounter{\arabicthreedigits}{\@arabicthreedigits}{000}
\makeatother

\newenvironment{doubleenumerate}[1]
 {\begin{enumerate}[label=\bfseries N#1 P\arabicthreedigits*,leftmargin=7em]}
 {\end{enumerate}}

\begin{document}    

Some text before the enumerate environment
some text before the enumerate environment
some text before the enumerate environment
\begin{doubleenumerate}{09}
  \item\label{x} abc
  \item 
  \item 
  \item 
  \item 
  \item 
  \item 
  \item 
  \item 
  \item 
  \item
\end{doubleenumerate}
    
\end{document}

enter image description here

If the first part is to have a progressive number, you can do as follows.

\documentclass[12pt, a4paper]{article}

\usepackage{enumitem}

\makeatletter
\newcommand{\arabicthreedigits}[1]{\expandafter\@arabicthreedigits\csname c@#1\endcsname}
\newcommand{\@arabicthreedigits}[1]{%
  \ifnum#1<100 0\fi
  \ifnum#1<10 0\fi
  \number#1%
}
\newcommand{\arabictwodigits}[1]{\expandafter\@arabictwodigits\csname c@#1\endcsname}
\newcommand{\@arabictwodigits}[1]{%
  \ifnum#1<10 0\fi
  \number#1%
}
\AddEnumerateCounter{\arabicthreedigits}{\@arabicthreedigits}{000}
\AddEnumerateCounter{\arabictwodigits}{\@arabictwodigits}{00}
\makeatother

\newcounter{doubleenumerate}
\newenvironment{doubleenumerate}
 {%
  \stepcounter{doubleenumerate}%
  \begin{enumerate}[
    label=\bfseries N\arabictwodigits{doubleenumerate} P\arabicthreedigits*,
    leftmargin=7em
  ]%
 }
 {\end{enumerate}}

\begin{document}    

Some text before the enumerate environment
some text before the enumerate environment
some text before the enumerate environment
\begin{doubleenumerate}
  \item\label{x} abc
  \item 
  \item 
  \item 
  \item 
  \item 
  \item 
  \item 
  \item 
  \item 
  \item
\end{doubleenumerate}
Some text before the enumerate environment
some text before the enumerate environment
some text before the enumerate environment
\begin{doubleenumerate}
  \item
  \item 
\end{doubleenumerate}
    
\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.