[Tex/LaTex] Indenting multi-line list items in an enumeration

indentationlists

I have an enumeration environment in my LaTeX document consisting of several numbered steps. Now I need to indent some of these steps. I am using the following command to achieve this indentation for one item:

{\setlength\itemindent{2cm} 
   \item Some item text...
}

It works for short item texts, but in the case of longer texts that lead to line breaks, the subsequent lines are not indented. See the following LaTeX code for an example:

\begin{enumerate}
\item This is a normal item without any indentation.
{\setlength\itemindent{2cm} 
\item This is an indented item with a long text that causes a line break. Unfortunately, the new line is not indented. 
}
\item This is a normal item without any indentation.
\end{enumerate} 

(Unfortunately I am not allowed to post an image of the output as I'm a new user…)

The first line of the second item is indented by 2cm, but all subsequent lines are not. Can anyone give me a hint on how to get the subsequent lines indented, too?

Best Answer

As ErikYou suggests, one normally would nest an enumerated list within an enumerated list to get this effect. However, in your case, this would in effect start a new list with its own counter. So, I would suggest you use the IndentedEnumerate environment defined below which starts the nested list so that its enumeration continues on from the previous list and yields:

enter image description here

Notes:

  • This is only set up for one level of nesting -- It will need further enhancements if more than one level of nesting if desired.
  • If the first item is to be indented, you need to add \item[] before starting the IndentedEnumerate environment.
  • If you wish this to work without the enumitem package package, the only tweaks necessary should be to modify how the label is specified for the indented list.
  • The showframe package was used just to show the page margins.

Code:

\documentclass{article}
\usepackage{showframe}
\usepackage{enumitem}

\newcounter{ListStartCount}%
\newenvironment{IndentedEnumerate}[1][]{%
    \setcounter{ListStartCount}{\theenumi}%
    \stepcounter{ListStartCount}%
    \begin{enumerate}[start=\theListStartCount,label={\arabic*.},#1]%
}{%
    \setcounter{enumi}{\theListStartCount}%
    \end{enumerate}%
}%

\begin{document}
\begin{enumerate}
\item[]
\begin{IndentedEnumerate}
\item This is the frist item with indentation, so need \verb|\item[]| before this.
\end{IndentedEnumerate} 
\item This is a normal item without any indentation.
%
\begin{IndentedEnumerate}
\item This is an indented item with a long text that causes a line break. Now, the enumeration is continued and the new line is indented. 
\end{IndentedEnumerate} 
%
\item This is a normal item without any indentation.
\end{enumerate} 
\end{document}
Related Question