4

Using amsthm package, is there an elegant way to automatically get a \newpage before every theorem?

Edit: MWE featuring Christian Hupfer's suggestion

\documentclass{article}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}
% \makeatletter
% \g@addto@macro{\thm}{\clearpage}
% \makeatother
\begin{document}
\begin{thm}
There are infinitely many prime numbers.
\end{thm}
% \newpage

\begin{thm}
$\sqrt{2}$ is irrational.
\end{thm}
\end{document}
  • assuming your theorem environment is called theorem, \makeatletter\g@addto@macro{\theorem}{\clearpage}\makeatother should work... however, this is untested -- as usual, provide a compilable document, please – user31729 Feb 10 at 15:19
  • that doesn't work very well, I get "Theorem x.y" in one page and the body of the theorem (i.e. the stuff between \begin{thm} and \end{thm) in the next. – noibe Feb 10 at 15:24
  • 1
    It was a guess only. Again: Providing a document is the better way to help us to help you – user31729 Feb 10 at 15:25
4

Since the definition of thm as done by amsthm is a little bit tricky, I suggest to use

\AtBeginEnvironment{thm}{\clearpage}

This is safe and will add the clear page before the theorem headline (and not disrupting the display)

\documentclass{article}
\usepackage{blindtext}
\usepackage{amsthm}
\usepackage{etoolbox}
\newtheorem{thm}{Theorem}

\AtBeginEnvironment{thm}{%
  \clearpage%
}
\begin{document}
\blindtext
\begin{thm}
There are infinitely many prime numbers.
\end{thm}

\begin{thm}
$\sqrt{2}$ is irrational.
\end{thm}
\end{document}
  • I know this isn't related to the original question, but what is the difference between \clearpage and \newpage? – noibe Feb 10 at 15:42
  • 2
    @noibe: A \clearpage will always issue a new page and emitting all pending floats before, i.e. the will be flushed to the previous page, then the page break occurs. A \newpage for example will not eject a new page in case of being specified in a column setup, it will end the local column only then. In most cases \clearpage is the right approach... For instance, I can hardly remember setups where I needed \newpage – user31729 Feb 10 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.