1

Goal

I created a twoside document, that contains some sidewaysfigures (using the package rotating). I would like these pages to be shown rotated in the PDF viewer, without affecting the printing. It should be one PDF file that can be used for reading and printing.

Research

Current Approach

I created a MWE with one image on page 3 (odd) and a second image on page 6 (even).

MWE

\documentclass[a4paper, 11pt, twoside]{scrbook}

\usepackage{lipsum} \usepackage{rotating}

\newenvironment{mysidewayspage}{% \clearpage% \Ifthispageodd{% \global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 270}% }{% \global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 90}% } }{% \clearpage% \global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 0}% }

\begin{document} \lipsum[1-8] \begin{mysidewayspage} \begin{sidewaysfigure}[htb] \centering \includegraphics[height=.6\textwidth, keepaspectratio]{example-image} \caption{Example Image} \end{sidewaysfigure} \end{mysidewayspage} \lipsum[5-15] \begin{mysidewayspage} \begin{sidewaysfigure}[htb] \centering \includegraphics[height=.6\textwidth, keepaspectratio]{example-image} \caption{Example Image} \end{sidewaysfigure} \end{mysidewayspage} \lipsum[16-20] \end{document}

Result

The result is correctly shown in the viewer (Adobe Reader).

enter image description here

Problem with Printing

When printing this (or viewing the preview for 2 on 1), the rotated odd page 3 will be correctly arranged:

enter image description here

But the rotated even page 6 is upside down:

enter image description here

Question

Is there a solution to show rotated pages in landscape mode only for the PDF view without affecting the printing, so one PDF file can be used for both cases?

There might be some viewer-depend behavior, but a solution that work for the default viewers would be good (esp. Adobe Reader).

dexteritas
  • 9,161
  • 1
    your attribute setting is wrong, you end up with all rotations: /Rotate 90/Rotate 0/Rotate 270 in a page (but I don't if the printer will behave if you correct that.) – Ulrike Fischer Oct 24 '23 at 21:20
  • Oh, right. But if I reduce it to \pdfpageattr{/Rotate 270} etc., the printing problem remains. – dexteritas Oct 24 '23 at 21:39
  • Hmmm... why do you think it's upside down? (honest question... not joking! ). I think that the way you show is the better one to read (you turn the book 90 degrees clockwise to read both images). – Rmano Oct 25 '23 at 10:01
  • @Rmano sidewaysfigure rotates the images so that they can be read from the edge of the book. I think this is common and useful for printed books. You can see that the whole page is rotated 180° here by the page number. If I print the document double-sided, then suddenly one page would be the wrong way around. – dexteritas Oct 25 '23 at 11:00
  • @dexteritas ah, ok, got it. Thanks for explaining! – Rmano Oct 25 '23 at 13:39

1 Answers1

2

You are pilling up /Rotate instructions and some of your pages now contain even three values /Rotate 90/Rotate 0/Rotate 270.

A correct way to set the rotation would be to use the PDF management (the command sets a label and so should be inside the sidewaysenvironment).

\DocumentMetadata{} %load PDF management 
\documentclass[a4paper, 11pt, twoside]{scrbook}

\usepackage{lipsum} \usepackage{rotating} \ExplSyntaxOn \newcommand\myrotate{% \Ifthispageodd{% \pdfmanagement_add:nnn{ThisPage}{Rotate}{90} }{% \pdfmanagement_add:nnn{ThisPage}{Rotate}{270} } } \ExplSyntaxOff

\begin{document} \lipsum[1-8] \begin{sidewaysfigure}[htb] \centering\myrotate \includegraphics[height=.6\textwidth, keepaspectratio]{example-image} \caption{Example Image} \end{sidewaysfigure} \lipsum[5-15] \begin{sidewaysfigure}[htb] \centering\myrotate \includegraphics[height=.6\textwidth, keepaspectratio]{example-image} \caption{Example Image} \end{sidewaysfigure} \lipsum[16-20] \end{document}

But I can't tell you if your printer driver will handle that better.

Ulrike Fischer
  • 327,261
  • This implementation is definitely nicer. You only need a relatively up-to-date tex distribution. However, the problem with printing unfortunately remains. – dexteritas Oct 24 '23 at 21:49