2

I have a problem in Latex where \afterpage somehow seems to have problems with a split equation, so that the code does not compile. I use \afterpage to fill a page before a large landscape figure is presented, to avoid the whitespace that is produced otherwise. This is the MWE (comment out the \afterpage command and it will compile):

\documentclass[a4paper]{scrbook}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{lipsum}


\begin{document}
\lipsum[1-2][1-20]
\afterpage{
\begin{landscape}
\begin{figure}
\includegraphics[width=\textwidth]{example-image-a}
\caption{Caption}
\end{figure}
\end{landscape}}
\lipsum[1-5]
\begin{equation}
\begin{split}
x&=\frac{\pi}{2}\\
&=\frac{3}{2}
\end{split}
\end{equation}
\lipsum[1-2]
\end{document}
6
  • why don't you use sidewaystable and let the figure properly float? afterpage is not really a stable command. Aug 18, 2020 at 12:20
  • I used sidewaysfigure first, which works perfectly except that the corresponding page in the pdf is not rotated. So far I could achieve this effect only by using the landscape environment. If it is possible to rotate the page in the pdf also with using sidewaystable, this would be perfect!
    – CarlJacobi
    Aug 18, 2020 at 12:36
  • 1
    See tex.stackexchange.com/a/472608/2388 and tex.stackexchange.com/a/479816/2388 (in a future latex it will be easier, but currently you need labels with pdflatex, only lualatex and xelatex can do it without it). Aug 18, 2020 at 12:40
  • If you are open to try with another font, try your code with \renewcommand{\rmdefault}{qag} (as an example) in your preamble ....
    – koleygr
    Aug 18, 2020 at 12:49
  • 3
    if you use afterpage you should be happy when it works, not surprised when it doesn't. Aug 18, 2020 at 13:09

1 Answer 1

1

An easy solution is to separate the equation from the preceding paragraph. This solution puts the equation inside a splitable paragraph, but the spacing on the first and last lines are slightly off.

\documentclass[a4paper]{scrbook}
\usepackage{amsmath, amssymb}
\usepackage{graphicx}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{lipsum}

\newsavebox{\tempbox}

\begin{document}
\lipsum[1-2]
\afterpage{%
\begin{landscape}
\begin{figure}
\centering
\includegraphics[width=\textheight]{example-image-a}
\caption{Caption}
\end{figure}
\end{landscape}}
\lipsum[1-3]

\setbox\tempbox=\vbox{\strut
Text in pragraph before equation.
Text in pragraph before equation.
Text in pragraph before equation.
Text in pragraph before equation.
Text in pragraph before equation.
Text in pragraph before equation.
Text in pragraph before equation.
\begin{equation}
\begin{split}
x&=\frac{\pi}{2}\\
&=\frac{3}{2}
\end{split}
\end{equation}
Text in same paragraph after equation.
}\unvbox\tempbox
\lipsum[1-2]
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .