0

I am a linux user and using the following way for landscape pages in my system:

\documentclass[twoside,10pt]{article}
\usepackage{lipsum}
\usepackage[top=3cm,bottom=2cm,left=4cm,right=2cm]{geometry}
\usepackage{fancyhdr}
\fancyfoot[OE]{\begin{minipage}{\textwidth}\centering\rule{1pt}{\dimexpr 2cm-10pt}\end{minipage}}
\usepackage{capt-of}

\usepackage{adjustbox}


\newenvironment{myLandscape}
               {\clearpage                 
                \pdfpageattr{\the\pdfpageattr/Rotate 90}%
                \newgeometry{top=3cm,bottom=2cm,left=4cm,right=2cm}% 
                \begin{adjustbox}{angle=90}%
                \begin{minipage}{\textheight}%
}
               {\end{minipage}% 
                \end{adjustbox}%
                \clearpage

                \pdfpageattr{\the\pdfpageattr/Rotate 0}%
                \restoregeometry
               }


\begin{document}

\pagestyle{fancy}

\section{Some Section}
\subsection{Some Subsection}
Some text in portrait here

\lipsum[1]


\begin{myLandscape}
  Test Text on Rotated Page.

  \begin{center}
    \includegraphics[width=10cm]{example-image-a}
    \captionof{figure}{A centered 10cm figure}
  \end{center}  
\end{myLandscape}

Text in next page.

\end{document}

My problem is that the pdf generated by this code can not opened in a mac (and possibly in a windows OS) but skips the landscape pages [tested from friends with mac with both "adobe" (or acrobat or adobe acrobat) and the "preview" pdf readers].

I 'd like to change the code and make it work for all these OSs (linux, mac and Windows) but I have not a mac and not windows system too. So, I would like help from someone that can compile and test the code and help me with the additions needed to be able to use it on any OS.

Output:

enter image description here

enter image description here

enter image description here

PS: I know about lscape and pdflscape packages, but I need more control than these packages and to get over their problems on margins etc. (Every landscape page has to be in one environment with my way but this is not a problem for me)

0

1 Answer 1

4

You are writing \the \pdfpageattr /Rotate 90 in the pdf, you must expand the value. The resetting code is wrong, the goal is not to add /Rotate 0 but to remove the /Rotate 90 (which happens in your code at the \end{myLandscape} automatically).

\documentclass[twoside,10pt]{article}
\usepackage{lipsum}
\usepackage[top=3cm,bottom=2cm,left=4cm,right=2cm]{geometry}
\usepackage{fancyhdr}
\fancyfoot[OE]{\begin{minipage}{\textwidth}\centering\rule{1pt}{\dimexpr 2cm-10pt}\end{minipage}}
\usepackage{capt-of}

\usepackage{adjustbox}


\newenvironment{myLandscape}
               {\clearpage
                \pdfpageattr\expandafter{\the\pdfpageattr/Rotate 90}%
                \newgeometry{top=3cm,bottom=2cm,left=4cm,right=2cm}%
                \begin{adjustbox}{angle=90}%
                \begin{minipage}{\textheight}%
}
               {\end{minipage}%
                \end{adjustbox}%
                \clearpage
                \restoregeometry
               }


\begin{document}

\pagestyle{fancy}

\section{Some Section}
\subsection{Some Subsection}
Some text in portrait here

\lipsum[1]


\begin{myLandscape}
  Test Text on Rotated Page.

  \begin{center}
    \includegraphics[width=10cm]{example-image-a}
    \captionof{figure}{A centered 10cm figure}
  \end{center}
\end{myLandscape}

Text in next page.

\end{document}
3
  • Thanks @Ulrike... I would like to know if this works on mac or on windows for you (I suppose it was a mistake of mine and it will work anywhere... but have to ask before accepting)... Strange that my way worked for linux
    – koleygr
    Commented Nov 25, 2018 at 16:05
  • 1
    it works on windows (while your code produced a broken pdf). Commented Nov 25, 2018 at 16:15
  • Thanks... I will ask from a friend with mac to test it and then will accept.
    – koleygr
    Commented Nov 25, 2018 at 16:39

You must log in to answer this question.

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