I'm trying to control the indentation of paragraphs in an enumerated list that is inside a customized list environment. I find that changing \parindent in the inner list has no effect.
Here's an example that reproduces the problem:
\documentclass{report}
\usepackage{lipsum}
\usepackage{enumitem}
\newlength{\exlabelwidth}
\settowidth{\exlabelwidth}{\small 99.99}
\newlength{\exlabelsep}
\setlength{\exlabelsep}{0.5em}
\newlength{\exsymbolwidth}
\settowidth{\exsymbolwidth}{\small\ensuremath{*}}
\newcounter{exercise}[chapter]
\renewcommand{\theexercise}{\thechapter.\arabic{exercise}}
\newcommand{\exitem}{}
\newenvironment{exercises}%
{\begin{list}{\exitem}{%
\usecounter{exercise}%
\small%
\setlength{\itemindent}{\exlabelwidth}%
\addtolength{\itemindent}{\labelsep}%
\setlength{\labelwidth}{\exlabelwidth}%
\addtolength{\labelwidth}{\exsymbolwidth}%
\addtolength{\labelwidth}{\exlabelsep}%
\setlength{\leftmargin}{0.0cm}%
\setlength{\itemsep}{0.0cm}%
\setlength{\parsep}{0.0cm}%
\setlength{\listparindent}{\parindent}%
}%
}%
{\end{list}%
}
\newcommand{\ex}[1][]{%
\renewcommand{\exitem}{%
\makebox[\exsymbolwidth][r]{#1}\hspace{\exlabelsep}%
\makebox[\exlabelwidth][r]{\bfseries\theexercise}}\item%
}
\begin{document}
\begin{exercises}
\ex
\lipsum[1]
\lipsum[2]
\ex
\lipsum[3]
\begin{enumerate}[parsep=0pt,listparindent=\parindent]
\item
\lipsum[1]
\lipsum[2]
\end{enumerate}
\end{exercises}
\end{document}
The environment is based on advice I received on tex.stackexchange. I tried to make the code shorter, but I get errors. What I would like to be able to do is to have the second paragraph in the enumerate environment indented. Right now, it starts flush left regardless of whether I use the enumitem package and set parsep to zero or not.
Thanks for any advice.
Best Answer
Your problem is due to the fact that on one hand you use the
enumitem
package but then you also define your own lists via thelist
environment of LaTeX. Theenumitem
package doesn't know about your new list and gets confused.Basically what happens is that the following code in
\enit@preset
makes the wrong choice:The idea of this code is to save the outer
\parindent
value in\enit@outerparindent
when we enter the first level of lists and if we enter a nested list reuse the saved value instead. Now unfortunately your new list doesn't know about this so nothing gets saved. But if theenumerate
is entered it is in fact already on level 2 and therefore\parindent
gets the current value of\enit@outerparindent
which is, of course, still zero.So either you simply give
listparindent
and explicit value when you call enumarate, e.g.or, if you like this properly fixed you could set
\enit@outerparindent
in your definition ofexercises
if it exists (i.e., ifenumitem
was loaded), e.g.,Because of the
@
signs you need\makeatletter ...\makeatother
.