Your code can be made to work by modifying both \@totalleftmargin
(which controls nested list indentation) and \linewidth
as well as issuing a \parshape
to take these changes into consideration:
\documentclass{article}
%\documentclass[fleqn]{article}
\usepackage{amsthm}
\newcommand{\Blabla}{Bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.}
\makeatletter
\newtheoremstyle{indented}
{3pt}% space before
{3pt}% space after
{\addtolength{\@totalleftmargin}{3.5em}
\addtolength{\linewidth}{-3.5em}
\parshape 1 3.5em \linewidth}% body font
{}% indent
{\bfseries}% header font
{.}% punctuation
{.5em}% after theorem header
{}% header specification (empty for default)
\makeatother
\theoremstyle{indented}
\newtheorem{definition}{Definition}
\begin{document}
\Blabla
\begin{definition}
\Blabla
\begin{enumerate}
\item \Blabla
\item \Blabla
\end{enumerate}
\Blabla
\[A=B\]
\Blabla
\end{definition}
\Blabla
\end{document}
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 the list
environment of LaTeX. The enumitem
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:
\ifnum\@listdepth=\@ne
\enit@outerparindent\parindent
\else
\parindent\enit@outerparindent
\fi
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 the enumerate
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.
\begin{enumerate}[parsep=0pt,listparindent=15pt]
or, if you like this properly fixed you could set \enit@outerparindent
in your definition of exercises
if it exists (i.e., if enumitem
was loaded), e.g.,
\makeatletter
\newenvironment{exercises}%
{\begin{list}{\exitem}{%
\@ifundefined{enit@outerparindent}{}% if this command exists set it, otherwise do nothing
{\ifnum\@listdepth=\@ne
\enit@outerparindent\parindent
\else
\parindent\enit@outerparindent
\fi
}%
\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}}
\makeatother
Because of the @
signs you need \makeatletter ...\makeatother
.
Best Answer
To get enumerated and itemized lists that have the same amounts of left-hand and right-hand indentation, I'd recommend using the
enumitem
package -- which provides many extensions to and improvements over LaTeX's list environments -- and itsleftmargin
andrightmargin
options. The following MWE illustrates this.Added material after receiving a comment from the OP. I'm afraid I'm not quite sure about the meaning of the question
The new MWE below provides four separate option settings for shaping the itemized (or, equivalently, enumerated) list items. Hopefully, one of these settings meets your needs.
Suppose the final setting of the list items is what you're looking for. If you want this setting to apply uniformly to all enumerated and itemized lists, you should insert the command
in your document's preamble, immediately after the
\usepackage{enumitem}
instruction.