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 Answers2

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 = *]%&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; changed
    \item 
    \item   
    \item
    \item 
    \item 
    \item   
    \item
    \item
    \item 
    \item   
\end{enumerate}

\end{document}

a

Simon Dispa
  • 39,141
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

egreg
  • 1,121,712