11

I'd like to typeset two chunks of text (a problem statement and solution) next to each other, but I don't want the problem to be the last thing on a page and the solution to be the first thing on the next page. Is there a way to get LaTeX to try to keep them together if they occur at a page boundary — for example, by pushing a few lines of the problem onto the solution page, or vice versa? (Each paragraph/section can be broken individually, but I would like the boundary to be on one page.)

  • put \nopagebreak between them. (It might needs some other changes as well, especially if you are using \flushbottom rather than \raggedbottom, but start there:-) – David Carlisle Oct 18 '12 at 18:36
  • 1
    Maybe this one could help you. – Benedikt Bauer Oct 18 '12 at 18:36
  • @DavidCarlisle: Oh, c'mon! That's too simple! ;-) – Benedikt Bauer Oct 18 '12 at 18:37
  • Please add a minimal working example (MWE) that illustrates your problem. It would be easier to help you that way. – Werner Oct 18 '12 at 18:53
  • This mostly depends on how you define the logical units for problem and solution. – egreg Oct 18 '12 at 19:33
8

There also is the samepage environment. I would try the following:

Random sentence of the problem. Random sentence of the problem. Random
sentence of the problem.

  \begin{samepage}
  One of the last sentences of the problem. The last sentences of the
  problem.

  The first sentence of the solution. Another sentence of the solution.
  \end{samepage}

Random sentence of the solution. Random sentence of the solution. Random
sentence of the solution.

Maybe that's good enough for you.

0

I personally like \filbreak because it goes back to Knuth (and it nests better than some of the other approaches). See the FAQ:

Yet another trick by Knuth is useful if you have a sequence of small blocks of text that need, individually, to be kept on their own page. Insert the command \filbreak before each small block, and the effect is achieved.

In the following, if page breaks happen, they will tend to happen at the \filbreaks.

\filbreak
Here is the problem statement that goes on and on and on. And even more.

Here is the solution statement that goes on and on. And even more

\filbreak
Here is the problem statement that goes on and on and on. And even more.

Here is the solution statement that goes on and on. And even more

\filbreak
Here is the problem statement that goes on and on and on. And even more.

Here is the solution statement that goes on and on. And even more

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.