1

I am tryin to write a customized list where the label separation (separation between text and label) should change depending on the number of digits in the label. For example, if the label is less than 10, the label separation should be 0.36in, for labels between 10 and 99, the label separation should be 0.27in.

In the first step, I am trying to write a customized list which should display foo if the list counter is equal to 1, else it should display bar. However, it is working for last \item entry no matter how many entries there are. Following is MWE.

\documentclass{article}
\usepackage{enumitem}
\usepackage{etoolbox}
\setlist[enumerate]{wide, align=left, topsep=0mm, parsep=0.20in, partopsep=0mm, itemsep=0in, labelindent=0pt, labelsep=0.36in}
\newenvironment{FirstList}[1][]{
    \begin{enumerate}[#1] } {
    \ifnumcomp{\theenumi}{=}{1}{
    FOO } {
    BAR}
    \end{enumerate} }

\begin{document}

    \begin{FirstList}
    \item 

    \item 

    \item 

    \item 
    \end{FirstList}

\end{document}

1 Answer 1

0

If you want the test to be applied at each item, you may want to locally redefine \item.

\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate]{wide, align=left, topsep=0mm, parsep=0.20in, partopsep=0mm, itemsep=0in, labelindent=0pt, labelsep=0.36in}
\newenvironment{FirstList}[1][]{\begingroup\let\olditem\item
    \renewcommand\item{\olditem
    \ifnum\value{enumi}=1
    FOO
    \else
    BAR
    \fi}
    \begin{enumerate}[#1] } {
    \end{enumerate} \endgroup}

\begin{document}

\begin{FirstList}
    \item 

    \item 

    \item 

    \item 
\end{FirstList}

\end{document}

enter image description here

You can then change the \labelsep at some critical values of the counter. Here I chose this number to be 2, but you can choose 9, 99 and so on.

\documentclass{article}
\usepackage{enumitem}
\setlist[enumerate]{wide, align=left, topsep=0mm, parsep=0.20in, partopsep=0mm, itemsep=0in, labelindent=0pt, labelsep=0.36in}
\newenvironment{FirstList}[1][]{\begingroup\let\olditem\item
    \renewcommand\item{\olditem
    \ifnum\value{enumi}=1
    FOO
    \else
    BAR
    \fi
    \ifnum\value{enumi}=2
     \addtolength\labelsep{-0.2in}
    \fi}
    \begin{enumerate}[#1] } {
    \end{enumerate} \endgroup}

\begin{document}

\begin{FirstList}
    \item 

    \item 

    \item 

    \item 
\end{FirstList}

\end{document}

You must log in to answer this question.

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