[OS X TeX] unwanted page break

Berend Hasselman bhh at xs4all.nl
Wed Jun 15 21:58:03 CEST 2011


On 15-06-2011, at 21:41, Art Werschulz wrote:

> Hi.
> 
> Attached you will find two files that illustrate a problem I'm having.  As you can see in the PDF file, there's a page break between the "Exercise 3.4" heading and the solution.   Needless to say, this is a really bad place for a page break.  It would make much more sense for the page break to appear before the heading, so that the heading and the solution would be together.
> 
> Note that the definition of the "solution" environment includes a \nopagebreak.  Moreover, I even inserted a \nopagebreak within the solution to this exercise.  This availed me not.
> 
> Of course, I could insert a \newpage before the solution to Exercise 3.4.  But this is a pretty brittle solution.  What I'm showing you here is really a stripped-down example of the real thing, which is the solutions manual to a textbook.  Moreover, rather than manually maintaining separate files for the text and the solutions manual, we're using the "answers" package to generate the solutions manual file automatically, which adds a bit more indirection to the stew.  So going back and fixing things manually would be a tedious, error-prone solution, which would break if we were to include additional exercises.
> 
> Do any of you have suggestions about how to fix this?  Many thanks!!


In the preamble insert this

\usepackage{needspace}

Replace your definition of solution with

\newenvironment{solution}[1]%
  {\needspace{4\baselineskip}\noindent\textbf{Exercise #1.}}{}

This will keep the header with the start of the table together

Berend


More information about the macostex-archives mailing list