5

When using the external TikZ library to externalize an image in a pdflscape landscape environment, the resulting image is rotated by 90 degrees. This does not happen when including "normal" images. How can I avoid this? Or is there another way to have a single landscape page in a PDF that is also displayed in landscape mode in the viewer?

I want the document to look the same, whether \tikzexternalize is active or not, so just wrapping the tikzpicture in \rotatebox{90} is, unfortunately, not an option.

In my real document, only one page is in landscape mode, so unfortunately I can't just use the landscape option of the documentclass. Also, I'm using memoir for my actual document, in case that makes a difference for the solution.

MWE:

\documentclass{article}
\usepackage{pdflscape}
\usepackage{mwe} % For the example image
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % Without externalization, the orientation is correct
\tikzset{external/force remake}


\begin{document}
\lipsum[1-5]
  \begin{landscape}
    \includegraphics[width=4cm]{example-image-a}
    \begin{tikzpicture}
      \node [scale=5] {A};
    \end{tikzpicture}
  \end{landscape}
\end{document}

Output with \tikzexternalize commented out: Everything's fine

With \tikzexternalize uncommented: The TikZ A is rotated incorrectly:

  • You could add a \rotatebox depending on whether \tikzexternalize@hasbeencalled is defined and equals 1. I was however not successful in patching tikzpicture in a way that makes everything work correctly. – Caramdir Jun 26 '12 at 20:28
  • @Caramdir: That's a good idea, but that doesn't work with the trim left and trim right functionality (another thing I didn't mention, sorry!). rotatebox doesn't rotate the trim direction, unfortunately. – Jake Jun 26 '12 at 20:37
4

The main difference between the original lscape and pdflscape is (I think, I don't know the latter so well:-) that pdflscape inserts code get the viewer to keep the page orientation in the viewer, but if your viewer is using heuristics to do this automatically (acrobat by default_ then this may not be needed and the two may conflict.

  • 2
    Thank you! Using \usepackage[pdftex]{lscape} instead of \usepackage{pdflscape} works great in my case (including the correct rotation of the content, the display of the landscape page in landscape mode in the viewer, the orientation of externalized images, and the trim left/trim right functionality of the externalized tikzpicture). – Jake Jun 26 '12 at 21:00

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.