# Environment makes unnecessary page break

I have a problem with user-defined environments in LaTeX. Even though the content of an environment seems to fit, sometimes LaTeX makes an unneccessary page break after all.

Here is my MWE:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{lmodern}

\newenvironment{testenviron}
{}
{}

\begin{document}
\begin{testenviron}
Irgendein Text\dots

\vspace{17.5cm}

\dots und am Ende eine Formel:
$f(x)=x$
\end{testenviron}
\end{document}


To keep it simple, the environment has an empty pre- and postcode. Furthermore \vspace{17.5cm} stands for any text of this length. But for some inexplicable reason pdfLaTeX puts an empty page after that. So my question is: What I am doing wrong and what I am misunderstanding? If I write the pre- and postcode directly without using environments, no further page appears - that's kinda strange.

-
\enlargethispage{1\baselineskip} solves the problem, but this is not that consistent. –  Josef Oct 21 '12 at 15:26
See en.wikibooks.org/wiki/LaTeX/Customizing_LaTeX#Extra_space . Instead of \newenvironment{testenviron} {} {} use \newenvironment{testenviron} {\noindent\ignorespaces} {\par\noindent\ignorespacesafterend} –  mythealias Oct 21 '12 at 15:29
Thank you, this solves my problem. –  Josef Oct 21 '12 at 15:35

By inserting the replacement text (an empty group {}) for your testenviron at both \begin{testenviron} and \end{testenviron}, you obtain the same result. My assumption is that you just commented out these lines, which lead to a 1-page document.
Ending your environment with a display equation causes any \end{testenviron} content to be set on a new line, even if it's an empty group.
How would you fix it? This depends on what you include in testenviron, or whether you usually end your environment with a display equation. Easiest, in this instance would be to ignore the empty space at the end using
\newenvironment{testenviron}