Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
\enlargethispage{1\baselineskip} solves the problem, but this is not that consistent. –  Josef Oct 21 '12 at 15:26
1  
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

1 Answer 1

up vote 4 down vote accepted

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}
  {}% \begin{testenviron}
  {\ignorespacesafterend}% \end{testenviron}
share|improve this answer
    
Thank you for your further explanation. This solved my problem. –  Josef Oct 21 '12 at 15:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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