Tricky pagebreaking problem

I have a problem with some pagebreakings in my thesis.

I have used a recursive \afterpage{\clearpage} based macro in order to alternate text and figures, which works fine, most of the time. However, sometimes two pages of text are together, which is not normal.

I tried to do manual \clearpage, \newpage and \pagebreak in order to get the rythm right.

With either \clearpage or \newpage it works fine (so this is not a float problem), but with \pagebreak I don't get anything different at all.

Of course if I use \clearpage or \newpage, my line is not interrupted cleanly, and the continuing text after the figures neither.

Why is this working like this? It does not seem to me that this is strictly an \afterpage issue.

It is as if \pagebreak and \afterpage were "soft breaks" that sometimes get ignored for some reason while \clearpage and \newpage were "hard breaks".

I have tried to make a MWE but still it is not done yet.

Perhaps in the meanwhile you should be able to give me some hints?

EDIT: I seem to have identified a pattern: most of the time, this occrus when the following page of text is one very long paragraph. It might cause a problem, but still, why the difference between \pagebreak and \clearpage and \newpage?

-
Without seeing your macros it's difficult to tell. –  egreg Jun 19 '11 at 15:14
If you really want a strict setup where every recto is devoted to figures and every verso to text, then it's probably best to write your own output routine to get this. Unfortunately this is not at all easy, but any \afterpage{} type magic is unlikely to be 100% successful. –  Lev Bishop Jun 22 '11 at 16:15
@Lev, I am fully aware of the limitations of afterpage, one seemingly being that paragraphs longer than one page do not allow the afterpage to work properly. However, it seems to me that any pagebreak in these conditions should make it work, which it does not... And I don't understand why. –  Martigan Jun 22 '11 at 19:12

I can't test this without access to your document, but if you are correct that the cause is very long paragraphs, then you can turn these into smaller paragraphs, breaking them every 20 lines or so: {\parfillskip=0pt\par\parskip=0pt\noindent} (stolen from the TeXBook exercise 14.15).

-
Your answer is useful for circumventing the issue, and I will upvote it, after having tried it, of course, but I am still genuinely interested in the failing of the \pagebreak (or \afterpage). –  Martigan Jun 23 '11 at 15:31

I tried now some hours around why my \pagebreak[3] did not work. You need a \vfill element, otherwise LaTeX doesn't know which area it can "stretch" to actually break a page.

So I just use:

\vfill
\pagebreak[3]


Minimal working example:

\documentclass{article}

\begin{document}

\def\wl{\par \vspace{\baselineskip}}

\newcommand\question[0]{
\vfill
\pagebreak[3]
{\bf Question}
%\vspace{12pt}
\wl
}

\wl
\wl
}
\newcommand\fett[1]{{\bf #1}}

\newcommand\examplequestion{
\question
What is $1 + 1$?
$3$
}
\examplequestion
\examplequestion
\examplequestion
\examplequestion
\examplequestion
\examplequestion
\examplequestion
\examplequestion
\examplequestion

\end{document}


A question/answer pair is not allowed to be on separate pages, so this way they stick together, because the page breaks with \pagebreak[3] over each question and not inside.

-
Welcome to TeX.SX! It would be helpful if you could turn this into a complete minimal working example (MWE) and say a bit more about how it works. –  Adam Liter Mar 11 '14 at 1:40