1

earlier I asked how to rotate a page with a sidewaysfigure inside (question here). However I couldn't find a solution. I decided to use the landscape environment with afterpage, but when there's other floats near to the rotated one, the appearing order is altered.

In the following MWE, I expected to get the first page full of text, then the rotated figure, and finally the text and floats remaining.

How can I solve it?

\documentclass[12pt,a4paper]{article}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{rotating}
\usepackage{graphics, graphicx}

\begin{document}

\blindtext\par%
%
\afterpage{%
\begin{landscape}
\begin{figure}[h]
\centering
\includegraphics[width=0.7\linewidth]{example-image-a}
\caption{Figure a}
\label{Fig:a}
\end{figure}%
\end{landscape}
\clearpage%
}%
%
\blindtext\par%
%
\begin{figure}[h]
\centering
\includegraphics[width=0.7\linewidth]{example-image-b}
\caption{Figure b}
\label{Fig:b}
\end{figure}
%
\Blindtext\par%
%
\begin{figure}[h]
\centering
\includegraphics[width=0.7\linewidth]{example-image-c}
\caption{Figure c}
\label{Fig:c}
\end{figure}
\end{document} 
  • figure b is only allowed to come [h]ere as you used the optional arguemt to prevent all other options so that forces it to appear in the text, and figure a you forced to come after that by using \afterpage so I can't see what other order you would expect? – David Carlisle Feb 17 at 18:28
  • @DavidCarlisle I expected that the figure a comes first, because it was called first, and before the figures b and c there is a little of text explaining the figure content, then I think that is not correct to put all the floats inside the afterpage – Daniel Valencia C. Feb 17 at 19:32
  • as I explained before the content of \afterpage is just an internal definition it is not interpreted at all so the first figure that tex sees is B, then A is only seen after the afterpage tokens are inserted at the start of the next page. – David Carlisle Feb 17 at 19:58
  • the whole point of floats is that they move that is why they have captions, so any text in the main document flow should refer indirectly to the figure via its label, not be written assuming that it appears in any particular place. I wouldn't use afterpage, but if you use it for one, and you want some other figures to be in the same sequence, you must use it for all. – David Carlisle Feb 17 at 20:02
2

You were explictly forcing A to come after B, if I understand you correctly you want something more like

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{rotating}
\usepackage{graphics, graphicx}

\begin{document}

\blindtext\par%
%
\afterpage{%
\begin{landscape}
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{example-image-a}
\caption{Figure a}
\label{Fig:a}
\end{figure}%
\end{landscape}
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{example-image-b}
\caption{Figure b}
\label{Fig:b}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{example-image-c}
\caption{Figure c}
\label{Fig:c}
\end{figure}
}%
%
\blindtext\par%
%

%
\Blindtext\par%
%
\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.