1

There is a problem with the MWE: A solution for the MWE was found. But this solution does not work for the actual project. So far, I could not work out the reason for this. Therefore, other solutions are much welcomed.

I am working on a project in which I have to rotate some figures and some tables in a twoside document. The image below shows the results I want to achieve by automated determination of the rotation angles:

  • -90° on verso (left) pages,
  • +90° on recto (right) pages if the verso page is not rotated,
  • -90° on recto pages if the verso page is rotated.

We assume left-to-right (LTR) script (e.g. English language) here.

My macro \rotateRectoVerso only works in the first two cases. For obvious reasons it cannot work in the third case. The solution has to work with https://ctan.org/pkg/endfloat. So far I would like to keep the captions unharmed since a reader usually reads the book unrotated and finding the figure might be easier this way. In classes in which \ifthispageodd is not defined one might compare If Then Else for odd page/even page.

enter image description here

\documentclass[paper=b7,twoside,14pt]{scrbook}
\usepackage{tikz}
% I could not solve my problem with these
%\usepackage{hvfloat}
%\usepackage[twoside]{rotating}

\newcounter{imagecounter}
\newcommand{\examplePic}[1]{
\stepcounter{imagecounter}
\begin{tikzpicture}
    \draw (-2,-2) -- (0,0) node {\bfseries\huge J\Alph{imagecounter}} -- (2,2);
\end{tikzpicture}
}

%works in many cases
\newcommand{\rotateRectoVerso}[1]{\ifthispageodd{\rotatebox{90}}{\rotatebox{-90}}{#1}}

\usepackage[nomarkers,heads,nolists,noheads]{endfloat}

\begin{document}
\chapter{manual}
Foo.

\begin{figure}
    \examplePic{}
    \caption{normal}
\end{figure}
\begin{figure}
    \rotatebox{90}{\examplePic{}}
    \caption{manually rotated}
\end{figure}


\begin{figure}
    \rotatebox{-90}{\examplePic{}}
    \caption{manually rotated}
\end{figure}
\begin{figure}
    \examplePic{}
    \caption{normal}
\end{figure}




\begin{figure}
    \rotatebox{-90}{\examplePic{}}
    \caption{manually rotated}
\end{figure}
\begin{figure}
    \rotatebox{-90}{\examplePic{}}
    \caption{manually rotated}

\end{figure}


\chapter{auto}
The first two pairs work (after a second compilation). The last does not. 
\clearpage

\begin{figure}
    \rotateRectoVerso{\examplePic{}}
    \caption{automatically rotated}
\end{figure}
\begin{figure}
    \examplePic{}
    \caption{normal}
\end{figure}


\begin{figure}
    \examplePic{}
    \caption{normal}
\end{figure}
\begin{figure}
    \rotateRectoVerso{\examplePic{}}
    \caption{automatically rotated}
\end{figure}


\begin{figure}
    \rotateRectoVerso{\examplePic{}}
    \caption{automatically rotated}
\end{figure}
\begin{figure}
    \rotateRectoVerso{\examplePic{}}
    \caption{automatically rotated}
\end{figure}


\end{document}
  • I am wondering a very basic thing and most likely I am missing something essential. If I understand you correctly, you want to make the rotation angle depend on the rotation of the previous page. On the other hand, your macro only tests if the page number is odd, and has no further if statement. How should that work? (I apologize in advance if I am missing something obvious.) – marmot Apr 28 '18 at 3:02
  • @marmot: Thank you for your interest. The given macro is written just to show "what I have done so far" and to show what kind of interface I am hoping for. It clearly cannot work this way. I also tried to work with counters to compare the previous rotated page with the current but that did not work, too. I decided to keep the MWE minimal. – CampanIgnis Apr 28 '18 at 13:38
0

The following code solves the problem for the MWE but does not solve the problem for the project itself.

\documentclass[paper=b7,twoside,14pt]{scrbook}
\usepackage{tikz}
% I could not solve my problem with these
%\usepackage{hvfloat}
%\usepackage[twoside]{rotating}

\newcounter{imagecounter}

\newcommand{\examplePic}[1]{
\stepcounter{imagecounter}
\begin{tikzpicture}
    \draw (-2,-2) -- (0,0) node {\bfseries\huge J\Alph{imagecounter}} -- (2,2);
\end{tikzpicture}
}

\newcounter{lastRotatedVerso}\setcounter{lastRotatedVerso}{-99}
\newcounter{lastRotatedVersoStep}\setcounter{lastRotatedVerso}{-95}

\newcommand{\rotateRectoVerso}[1]{\ifthispageodd
{%Recto
% A second counter might be necessary if two floats on the recto need to be rotated
\setcounter{lastRotatedVersoStep}{\value{lastRotatedVerso}}
\stepcounter{lastRotatedVersoStep}
\ifnum\value{lastRotatedVersoStep}=\value{page}
\rotatebox{-90}{#1}
\else
\rotatebox{90}{#1}
\fi
}{%Verso
\rotatebox{-90}{#1}
\setcounter{lastRotatedVerso}{\thepage}
}
}


\usepackage[nomarkers,heads,nolists,noheads]{endfloat}

\begin{document}
\chapter{manual}
Foo.

\begin{figure}
    \examplePic{}
    \caption{normal}
\end{figure}
\begin{figure}
    \rotatebox{90}{\examplePic{}}
    \caption{manually rotated}
\end{figure}


\begin{figure}
    \rotatebox{-90}{\examplePic{}}
    \caption{manually rotated}
\end{figure}
\begin{figure}
    \examplePic{}
    \caption{normal}
\end{figure}




\begin{figure}
    \rotatebox{-90}{\examplePic{}}
    \caption{manually rotated}
\end{figure}
\begin{figure}
    \rotatebox{-90}{\examplePic{}}
    \caption{manually rotated}

\end{figure}


\chapter{auto}
The first two pairs work (after a second compilation). The last does not. 
\clearpage

\begin{figure}
    \rotateRectoVerso{\examplePic{}}
    \caption{automatically rotated}
\end{figure}
\begin{figure}
    \examplePic{}
    \caption{normal}
\end{figure}


\begin{figure}
    \examplePic{}
    \caption{normal}
\end{figure}
\begin{figure}
    \rotateRectoVerso{\examplePic{}}
    \caption{automatically rotated}
\end{figure}


\begin{figure}
    \rotateRectoVerso{\examplePic{}}
    \caption{automatically rotated}
\end{figure}
\begin{figure}
    \rotateRectoVerso{\examplePic{}}
    \caption{automatically rotated}
\end{figure}



\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.