Incompatibility between noindentafter and etoolbox (> v2.5f)?
The noindentafter
wants to patch \end
(which is a bad thing to do), in order to inject some code. With the last release of LaTeX, \end
has become robust, but in a rather peculiar way that makes xpatch
useless in this case.
The package should do
\expandafter\patchcmd\csname end \endcsname{%
\if@ignore\@ignorefalse\ignorespaces\fi%
}{%
\if@ignore\@ignorefalse\ignorespaces\fi%
\csuse{@noindent@#1@hook}%
}{}{%
\PackageWarningNoLine{noindentafter}{%
Patching `\string\end' failed!\MessageBreak%
`\string\NoIndentAfter...' commands won't work%
}%
}
You can do it yourself, but you have to live with the innocuous warning until the package is updated.
\documentclass[11pt]{article}
\usepackage{noindentafter}
\NoIndentAfterEnv{enumerate}
\setlength{\parindent}{3em}% % To make the indentation clearly visible
\makeatletter
\expandafter\patchcmd\csname end \endcsname{%
\if@ignore\@ignorefalse\ignorespaces\fi%
}{%
\if@ignore\@ignorefalse\ignorespaces\fi%
\csuse{@noindent@#1@hook}%
}{}{%
\PackageWarningNoLine{noindentafter}{%
Patching `\string\end' failed!\MessageBreak%
`\string\NoIndentAfter...' commands won't work%
}%
}
\makeatother
\begin{document}
\begin{enumerate}
\item[(1)] Some text.
\item[(2)] Some other text.
\end{enumerate}
Text that should not be indented.
\end{document}
I'm not sure about the usefulness of the package, as it's much easier not to leave a blank line after \end{enumerate}
and obtain exactly the same output.
\documentclass[11pt]{article}
\setlength{\parindent}{3em}% % To make the indentation clearly visible
\begin{document}
\begin{enumerate}
\item[(1)] Some text.
\item[(2)] Some other text.
\end{enumerate}
Text that should not be indented.
\end{document}
I found out that its not necessary anymore to patch \end
directly. The etoolbox
-macro \AfterEndEnvironment
can do the very same now. The following code works for me, copied from the noindentafter
-package.
\newcommand*\@NoIndentAfter{%
\@ifnextchar\par{%
\def\par{%
\everypar{\setbox\z@\lastbox\everypar{}}%
\@restorepar%
}%
}{}%
}
\newrobustcmd*{\NoIndentAfterThis}{\@NoIndentAfter\par\par}
\AfterEndEnvironment{enumerate}{\NoIndentAfterThis}
I assume this works only for the updated version of \end
(see @egregs answer about the update), because the noindentafter
package author explicitely writes:
The package
etoolbox
provides the command\AfterEndEnvironment
which creates a hook executed at a very late point inside the\end
command. However, this hook is still located before\ignorespaces
, which is too early to properly suppress the indention after an environment. Therefore another hook is now added to\end
using\patchcmd
. This new hook puts new code at the very end.
However, this doesn't seem to be true anymore.