[Tex/LaTex] Automatic \noindent on the first paragraph of each theorem environment

indentationtheorems

I am currently putting a \noindent before the first paragraph of each theorem, proof, etc. in my memoir document. Is there any way to have memoir do this automatically?

For example, is there any way to make this MWE more concise?

\documentclass{memoir}

\usepackage{amsthm}
\newtheorem{thm}{Theorem}[chapter]

\begin{document}

\noindent This is my introduction.

This is the next paragraph of the introduction, which should be indented.

\begin{thm} (Theorem Name)

\noindent This is my theorem.
Note that I do want the ``(Theorem Name)'' to appear on the same line as where it says \textbf{Theorem 0.1}.

This is the next paragraph of the theorem, which should be indented.

\end{thm}

\noindent Here is a note about the theorem.

\begin{proof}

\noindent This proof has no name.

This is the next paragraph of the proof, which should be indented.

\end{proof}

\noindent This is my conclusion.

The end.

\end{document}

Best Answer

To typeset the name of a certain theorem, use the optional argument of the theorem's environment, e.g., \begin{thm}[Theorem Name]. In my example, I use the thmtools package to conveniently define a new style.

To suppress indentation in the first paragraph after a theorem, one may patch the commands \@endtheorem and \endproof (using the etoolbox package) and then use % (the comment sign) in the text body. (EDIT: For details about amsthms implementation of theorems, see my answer to How to prevent paragraph breaks after theorem environments?)

The \noindent in your example's first paragraph would be superfluous if it was preceded by a sectioning command like \chapter or \section.

\documentclass{memoir}

\usepackage{amsthm}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@endtheorem}{\@endpefalse}{}{}{}
\patchcmd{\endproof}{\@endpefalse}{}{}{}
\makeatother

\usepackage{thmtools}
\declaretheoremstyle[within=chapter,spaceabove=\topsep,notefont=\normalfont\itshape,
    bodyfont=\itshape,postheadspace=\newline]{mystyle}
\declaretheorem[style=mystyle,name=Theorem]{thm}

\begin{document}

\noindent This is my introduction.

This is the next paragraph of the introduction, which should be indented.

\begin{thm}[Theorem Name]
This is my theorem. Note that I do want the ``(Theorem Name)'' to appear on the same
    line as where it says \textbf{Theorem 0.1}.

This is the next paragraph of the theorem, which should be indented.
\end{thm}
% <-- Supresses indentation of following paragraph
Here is a note about the theorem.

\begin{proof}
This proof has no name.

This is the next paragraph of the proof, which should be indented.
\end{proof}
% <-- Supresses indentation of following paragraph
This is my conclusion.

The end.

\end{document}

enter image description here