pdf - sidewaysfigure and landscape - TeX

I have some figures which I wish to display in landscape, with rotated captions.

I can achieve this fine using the sidewaysfigure environment from the rotating package.

I want to also ensure that the PDF document automatically displays in the right orientation for the reader.I can achieve this using the landscape environment from the pdflscape package.

I can't however seem to combine both of these for the effect I want. If I try encapsulating the sidewaysfigure in the landscape environment I get my graphic rotated 180 degrees (the page does display in the right orientation on screen however).

\afterpage{\begin{landscape}
\begin{sidewaysfigure}
    \centering
    \includegraphics{image}
    \caption{caption}
    \label{fig:label}
\end{sidewaysfigure}
\end{landscape}}

Doesn't work - figure displays incorrectly.

\begin{sidewaysfigure}
    \centering
    \includegraphics{image}
    \caption{caption}
    \label{fig:label}
\end{sidewaysfigure}

Figure displays correctly, but PDF document doesn't recognise that this page is landscape so displays automatically in portrait when viewed on-screen.

2 Answers

  1. Brent- Reply

    2019-11-15

    Don't use sidewaysfigure within landscape - it will turn your figure twice. A regular figure should suffice:

    \documentclass{article}
    \usepackage{rotating}
    \usepackage{pdflscape}
    
    \begin{document}
    
    \begin{landscape}
     \begin{figure}
      \centering
      \includegraphics{image}
      \caption{caption}
      \label{fig:label}
     \end{figure}
    \end{landscape}
    
    \end{document}
    
  2. Brian- Reply

    2019-11-15

    Although this question was seemingly answered (by @Bettina) over a year ago, I think that the complexity of the question and answer is misleading. There are two potential problems in the proposed solution:

    1. If the landscape page is placed amongst other floats, it doesn't behave nicely
    2. If the landscape page has other headers/footers, it doesn't behave nicely

    I will link some helpful threads:

    I think the following example illustrates how to put everything together. It works for my purposes, and the other floats around the document seem to flow properly. Now it uses the flafter package which forces floats to appear after their declaration in the text.

    \documentclass{article}
    
    \usepackage{pdflscape}
    \usepackage{afterpage}
    \usepackage{flafter}
    \usepackage{fancyhdr}
    \fancypagestyle{lscape}{% 
    \fancyhf{} % clear all header and footer fields 
    \fancyfoot[LE]{}
    \fancyfoot[LO] {}
    \renewcommand{\headrulewidth}{0pt} 
    \renewcommand{\footrulewidth}{0pt}}
    
    \begin{document}
    
    \afterpage{
    \clearpage% To flush out all floats, might not be what you want
    \begin{landscape}
    \thispagestyle{lscape}
    \pagestyle{lscape}
    \begin{figure}
    \includegraphics{myfigure.pdf}
    \caption{Test}
    \end{figure}
    \end{landscape}
    }
    
    \end{document}
    

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>