2

Consider the following code:

\documentclass[a4paper,10pt]{memoir}
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{xcolor}

\begin{document}

\chapter{Chapter1}
\section{Section1.1}
\lipsum[1]
\begin{enumerate}
    \item item 1
    
    {\color{blue!60} Next line for explanation}
    \item item 1
    
    {\color{blue!60} Next line for explanation}
    \item item 1
    
    {\color{blue!60} Next line for explanation}
\end{enumerate}
\subsection{Subsection1.1.1}
\lipsum[1]
\begin{enumerate}
    \item item 1
    
    Next line for explanation 1
    \item item 2
    
    Next line for explanation 2
    \item item 3
    
    Next line for explanation 3
\end{enumerate}
\chapter{Chapter2}
\section{Section2.1}
\lipsum[1]
\begin{enumerate}
    \item item 1
    
    Next line for explanation 1
    \item item 2
    
    Next line for explanation 2
    \item item 3
    
    Next line for explanation 3
\end{enumerate}
\section{Section2.2}
\lipsum[1]
\begin{enumerate}
    \item item 1
    
    Next line for explanation 1
    \item item 2
    
    Next line for explanation 2
    \item item 3
    
    Next line for explanation 3
\end{enumerate}
\subsection{Subsection2.2.1}
\lipsum[1]
\begin{enumerate}
    \item item 1
    
    Next line for explanation 1
    \item item 2
    
    Next line for explanation 2
    \item item 3
    
    Next line for explanation 3
\end{enumerate}
\chapter{Chapter3}
\section{Section3.1}
\lipsum[1]
\begin{enumerate}
    \item item 1
    
    Next line for explanation 1
    \item item 2
    
    Next line for explanation 2
    \item item 3
    
    Next line for explanation 3
\end{enumerate}
\subsection{Subsection3.1.1}
\lipsum[1]
\begin{enumerate}
    \item item 1
    
    Next line for explanation 1
    \item item 2
    
    Next line for explanation 2
    \item item 3
    
    Next line for explanation 3
\end{enumerate}
\end{document}

I made the next line (of item of the enumitem) colored blue to show some explanation as you can see in the figure.

enter image description here

It is OK for a list. But I have a lot of lists in my document as you see in the code. How can I automate this thing using macro or command to make (colored blue) the next line of each enumitem that can easily managed.

To say clearly, I want all the lines Next line for explanation 1/2/3 to be blue colored.

1

1 Answer 1

1

One simple, yet imperfect solution would be to create a newcommand:

\newcommand{\bitem}[2]{
    \item #1
    
    {\color{blue!60} #2}
    }

And to use it whenever needed:

\begin{enumerate}
    \bitem{item 1}{The blue nest line for explanation 1}
    \item item 2
    
    Nest line for explanation 2
    \item item 3
    
    Nest line for explanation 3
\end{enumerate}

enumitem formatting

Although I'm pretty sure that some Expl3 expert would come with handier solution.

4
  • It's not much easier to manage. I must edit all the \item in this way which is really tough.
    – mmr
    Commented Dec 12, 2021 at 9:49
  • I know that. I'm just not clever enough to figure another good solution out. Hope someone will. But since your item title and the rest of its content are considered all the same, it could be difficult to distinguished what is going to be coloured.
    – SebGlav
    Commented Dec 12, 2021 at 9:51
  • To say clearly, I want all the lines Next line for explanation 1/2/3 to be blue colored.
    – mmr
    Commented Dec 12, 2021 at 10:04
  • 1
    It was perfectly clear to me. Colouring everything (including "item 1") in blue is easy, but discriminating what is to be couloured in the enumerate content is another challenge.
    – SebGlav
    Commented Dec 12, 2021 at 10:32

You must log in to answer this question.

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