2

My organization has developed a template for formal correspondence. The rules states that each line / paragraph has to be numbered. Some of the rules are given below:

  1. Paragraphs. Arabic numerals are used for paragraphs. The numerals are followed by a full stop.

  2. Sub-paragraphs. Small alphabets in brackets the alphabets (i) and (o) are used for numbering sub-paragraphs.

I have created a new environment mylist for numbering paragraphs and sub-paragraphs. But I do not know how to skip (i) and (o) in the nested lists. I have basic idea of how to achieve it but can not implement it in LaTeX.

For each list, LaTeX creates a counter. For example, for first sub-paragraph, the counter's value is 1, for second sub-paragraph it is 2. Similarly, when counter's value is 9, (i) will be printed. If else conditional statement can be used to skip counter value of 9 and directly jump from 8 (h) to 10 (j). I need help in implementing this in LaTex.

A minimal working example is given below:-

\documentclass[oneside, 12pt]{article}
\usepackage{enumitem}
\newlist{mylist}{enumerate}{2}
\setlist[mylist]{wide, align = left}

\setlist[mylist, 1]{leftmargin = 0in, label = \arabic*.}
\setlist[mylist, 2]{leftmargin = 0.5in, label = (\alph*)}

\begin{document}

\begin{mylist}
    
    \item Foo
    
    \begin{mylist}
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item There are too many bars and not enough foo's in this list!
        
    \end{mylist}

\end{mylist}

\end{document}

2
  • So, what is your question?
    – mmr
    Commented Nov 24, 2021 at 5:44
  • @mmr I apologize for posting incomplete question. I have edited the original post. I hope the question is clear. If not, please do let me know. Thanks :)
    – Ali Baig
    Commented Nov 24, 2021 at 5:47

2 Answers 2

3

You can insert a test to check the value of mylistii at the beginning of the mylist list:

enter image description here

\documentclass{article}

\usepackage{enumitem}

\newlist{mylist}{enumerate}{2}
\setlist[mylist]{wide, align = left}

\newcommand{\noIorO}{%
  \let\olditem\item
  \renewcommand{\item}{%
    \ifnum\value{mylistii}=8
      \stepcounter{mylistii}% Skips (i)
    \fi
    \ifnum\value{mylistii}=14
      \stepcounter{mylistii}% Skips (o)
    \fi
    \olditem
  }%
}
\setlist[mylist, 1]{leftmargin = 0in, label = \arabic*.}
\setlist[mylist, 2]{leftmargin = 0.5in, label = (\alph*),before=\noIorO}

\begin{document}

\begin{mylist}
  \item Foo
  \begin{mylist}
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item bar
    \item There are too many bars and not enough foo's in this list!
  \end{mylist}
\end{mylist}

\end{document}
4

You can just add \stepcounter{mylistii}. For larger jumps you can use \addtocounter, e.g. \addtocounter{mylistii}{3}.

\documentclass[oneside, 12pt]{article}
\usepackage{enumitem}
\newlist{mylist}{enumerate}{2}
\setlist[mylist]{wide, align = left}

\setlist[mylist, 1]{leftmargin = 0in, label = \arabic*.}
\setlist[mylist, 2]{leftmargin = 0.5in, label = (\alph*)}

\begin{document}

\begin{mylist}
    
    \item Foo
    
    \begin{mylist}
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar
        
        \item bar\stepcounter{mylistii}
        
        \item bar
        
        \item There are too many bars and not enough foo's in this list!
        
    \end{mylist}

\end{mylist}

\end{document}

enter image description here

2
  • Thank you for your reply. Your solution will require manually updating the counter. Is it possible to automate it, that is, adding a conditional statement in definition of the mylist environment?
    – Ali Baig
    Commented Nov 24, 2021 at 6:11
  • You may need a new counter representation command and use \AddEnumerateCounter to make enumitem know it. The package doc has an example. Commented Nov 24, 2021 at 6:24

You must log in to answer this question.

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