6

So I wrote a LaTeX package that would give me full-page floats: https://tex.stackexchange.com/a/84312/13450

Unfortunately, it introduces hard page breaks.

\documentclass[a5paper]{memoir}
\usepackage{picturepage}
\usepackage{mwe}
\begin{document}
\blindtext\blindtext

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam
lobortis facilisis sem. Nullam nec mi et neque pharetra sollicitudin.
Praesent imperdiet mi nec ante. Donec ullamcorper, felis non sodales
commodo, lectus velit ultrices augue, a dignissim nibh lectus
placerat pede. Vivamus nunc nunc, molestie ut, ultricies vel, semper
in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque.
Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum
augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent
blandit blandit mauris. Praesent lectus tellus, aliquet aliquam,
luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum.
Nunc quis urna dictum turpis accumsan semper. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem.
Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet
mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus
velit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus
nunc nunc, molestie ut, ultricies vel, semper in, velit. Ut porttitor.
Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Duis fringilla tristique neque. Sed interdum libero
ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi
sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit
mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a,
turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum
turpis accumsan semper.
\picturepage{example-image-a}{Full-page image.}{fig:a}

\blindtext\blindtext

\blindtext\blindtext\blindtext\blindtext
\end{document}

So this obviously introduces an ugly page break (pages after the image not shown).

ugly page break

Now usually, \afterpage is perfect for these kinds of cases.

\documentclass[a5paper]{memoir}
\usepackage{picturepage}
\usepackage{mwe}
\usepackage{afterpage}
\begin{document}
\blindtext\blindtext

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam
lobortis facilisis sem. Nullam nec mi et neque pharetra sollicitudin.
Praesent imperdiet mi nec ante. Donec ullamcorper, felis non sodales
commodo, lectus velit ultrices augue, a dignissim nibh lectus
placerat pede. Vivamus nunc nunc, molestie ut, ultricies vel, semper
in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque.
Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum
augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent
blandit blandit mauris. Praesent lectus tellus, aliquet aliquam,
luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum.
Nunc quis urna dictum turpis accumsan semper. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem.
Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet
mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus
velit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus
nunc nunc, molestie ut, ultricies vel, semper in, velit. Ut porttitor.
Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Duis fringilla tristique neque. Sed interdum libero
ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi
sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit
mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a,
turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum
turpis accumsan semper.
\afterpage{\picturepage{example-image-a}{Full-page image.}{fig:a}}

\blindtext\blindtext

\blindtext\blindtext\blindtext\blindtext
\end{document}

For some reason I haven't been able to figure out, at least with memoir, this usage of \afterpage utterly ruins the page following the \picturepage.

perfect page break, fucked up following page

Now, going back to a more manual approach, one could notice that LaTeX breaks the first page after "amet ipsum." So introducing the page break there will of course make two paragraphs out of one. But as long as this fact could be visually concealed, this would be a workable solution (not a good one, let alone a beautiful one ... but it'll do). Unfortunately, I don't know how to tell LaTeX that it should just typeset the first half of the paragraph as it used to. The second one is a simple matter of \noindent:

\documentclass[a5paper]{memoir}
\usepackage{picturepage}
\usepackage{mwe}
\begin{document}
\blindtext\blindtext

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam
lobortis facilisis sem. Nullam nec mi et neque pharetra sollicitudin.
Praesent imperdiet mi nec ante. Donec ullamcorper, felis non so-
dales commodo, lectus velit ultrices augue, a dignissim nibh lectus
placerat pede. Vivamus nunc nunc, molestie ut, ultricies vel, sem-
per in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque.
Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum
augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Prae-
sent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam,
luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum.
\picturepage{example-image-a}{Full-page image.}{fig:a}
\noindent Nunc quis urna dictum turpis accumsan semper. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem.
Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet
mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus
velit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus
nunc nunc, molestie ut, ultricies vel, semper in, velit. Ut portti-
tor. Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Duis fringilla tristique neque. Sed interdum libero
ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi
sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit
mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a,
turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum
turpis accumsan semper.

\blindtext\blindtext

\blindtext\blindtext\blindtext\blindtext

\end{document}

Last line before page break is no longer full

So as I hope you are able to see (and as it is expected behaviour), the last line of the paragraph before the page break is no longer justified, thus destroying the impression of a coherent paragraph over the two pages.

How do I get LaTeX to typeset that last paragraph before the page break as it did before, without the ragged-right last line? Of course, if you have any idea how my problem might be solved at any other point, especially by fixing the afterpage behaviour, that'd be at least as appreciated.

Apologies if this seems too specific to my messed up picturepage package or not minimal enough because I'm using this huge chunk of code but I felt it would be better to provide a decent motivation instead of just asking "How do I split a paragraph but I don't want afterpage because reasons!"

  • It is kind of bizarre that the problem arises if the memoir class is used but not if the article class is used. – Mico May 25 '14 at 15:57
  • @Mico I agree, it is. Unfortunately, memoir is so huge that it's probably hard to pinpoint what part exactly is to blame. – Christian May 25 '14 at 17:18
  • 1
    @Mico it seems that changing geometry in an \afterpage is to blame. This is a relatively new feature of the geometry package so maybe nobody noticed this bug yet. \afterpage{\newgeometry{textheight=\paperheight,textwidth=\paperwidth}\null\restoregeometry} will already produce a similar behaviour, adding a \clearpage after \restoregeometry will mess the page up exactly as my package does. – Christian May 25 '14 at 17:31
  • @Christian Perhaps the atbegshi package would be useful? I used it to do something similar here... (Haven't tested this with memoir class, maybe it has the same problems.) – cslstr May 25 '14 at 18:09
  • @cslstr Looks promising but when I pass \picturepage to \AtBeginShipoutNext, I get a Not in outer par mode error :/ – Christian May 25 '14 at 18:26
4

It is not clear why you need to break the paragraph and page manually, or use afterpage. the standard figure environment can be used mid-paragraph without disturbing the line or page breaking, with the figure being inserted at the next available page break. I use sidewaysfigure to get the rotation but the insertion behaviour is the same.

enter image description here

\documentclass[a5paper]{memoir}
\usepackage{rotating,blindtext}

\begin{document}
\blindtext\blindtext

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam
lobortis facilisis sem. Nullam nec mi et neque pharetra sollicitudin.
Praesent imperdiet mi nec ante. Donec ullamcorper, felis non so-
dales commodo, lectus velit ultrices augue, a dignissim nibh lectus
placerat pede. Vivamus nunc nunc, molestie ut, ultricies vel, sem-
per in, velit. Ut porttitor. Praesent in sapien. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque.
Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum
augue a leo. Morbi sed elit sit amet ante lobortis sollicitudin. Prae-
sent blandit blandit mauris. Praesent lectus tellus, aliquet aliquam,
luctus a, egestas a, turpis. Mauris lacinia lorem sit amet ipsum!
\begin{sidewaysfigure}[p]
\includegraphics[width=\columnwidth]{example-image-a}
\caption{Full-page image.\label{fig:a}}
\end{sidewaysfigure}
Nunc quis urna dictum turpis accumsan semper. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis sem.
Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet
mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus
velit ultrices augue, a dignissim nibh lectus placerat pede. Vivamus
nunc nunc, molestie ut, ultricies vel, semper in, velit. Ut portti-
tor. Praesent in sapien. Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Duis fringilla tristique neque. Sed interdum libero
ut metus. Pellentesque placerat. Nam rutrum augue a leo. Morbi
sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit
mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a,
turpis. Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum
turpis accumsan semper.

\blindtext\blindtext

\blindtext\blindtext\blindtext\blindtext

\end{document}

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.