This question led to a new package:
noindentafter
There are a number of environments which I never want to follow up with an indented paragraph. itemize
, enumerate
, theorem
, definition
, etc. I know there are people who think this is bad style. But it's a personal preference. Those environments basically always end a paragraph for me, so the visual clue is not needed in my case.
I've found several similar questions, but none of them do what I need:
- Automatic \noindent on the first paragraph of each theorem environment
- Automatically adding \noindent after \section{*}
- Automatic noindent after quote environment
That third one was actually most useful, but appears to be unreliable for patching existing environments with. It doesn't seem to be working in my memoir
document.
To be clear, I don't want to remove the actual paragraph break. That's a semantic concept. I just want to patch the document style so that paragraphs following certain environments remain unindented.
I've tried the following two 'solutions' (which use etoolbox
for patching):
\newcommand*{\noindentnext}{\everypar{{\setbox\z@\lastbox}\everypar{}}}
\newcommand*{\NoIndentAfterEnv}[1]{\AfterEndEnvironment{#1}{\noindentnext}}
\newcommand*{\NoIndentAfterCmd}[1]{\apptocmd{#1}{\noindentnext}{}{}}
\NoIndentAfterEnv{itemize}
\NoIndentAfterEnv{theorem}
...
This one is loosely based on the third post from the list above. It sometimes works. It sometimes does nothing. I'm unable to predict when it will fail. The second:
\let\old@par\par
\newcommand*{\noindentnextpar}{\def\par{\let\par\old@par\par\noindent}}
\newcommand*{\NoParIndentAfterEnv}[1]{\AfterEndEnvironment{#1}{\noindentnextpar}}
\newcommand*{\NoParIndentAfterCmd}[1]{\apptocmd{#1}{\noindentnextpar}{}{}}
I invented this one myself. It breaks when the patched environment is not followed by a paragraph. It has also shown itself to inexplicably fail in other situations.
Once and for all, I'd like to have a reliable way to do this.
Let me give an example of what I need, just to be clear:
\NoIndentAfterEnv{itemize}
\begin{itemize}
\item ...
\end{itemize}
This starts a new paragraph. Note the empty line. But it should not be indented.
But this paragraph \emph{should} be indented.
\newcommand*{\noindentnext}{\def\par{\@@par\noindent\let\par\@@par}}
but you have the same. What do you mean it breaks?missing \item
error if aproof
environment ends while the augmented\par
is still in effect. I also remember getting errors if several augmented environments followed each other without a paragraph inbetween, but I can't seem to reproduce this right now.\let\@old@end\end\renewcommand{\end}[1]{\let\par\@@par\@old@end{#1}}
. Seems like I shouldn't be able to get away with it, but I did.indentnext
key to control the indentation after an environment. See this article on ConTeXt wiki for details. This is an old feature that works with MkII (pdftex/xetex) as well as MkIV (luatex).noindentafter
package is broken with the latest latex version (may 2021), seems it has been broken since nov 2019. See this github issue and this SE TeX question for details and potential solutions.