Graphics, Figures & TablesRotate image 90 or 270 depending on the side of the page

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jorsborn
Posts: 12
Joined: Sat Feb 26, 2011 4:17 am

Rotate image 90 or 270 depending on the side of the page

Post by jorsborn »

I tried searching the forums for my solution but my key words turned up nothing. I have some large images included in my document and it is my desire that they consume the whole page in landscape. I have achieved this by using the align=90 argument. No problem there.

Now, I want to supply either 90 degrees or 270 degrees depending on which side of the book it is on (right or left). I want the image bottom always facing the binding. I know about the ifthen package and I believe I could probably make this work if I only knew how to test for the side of the page that the image was on.

Thoughts?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

jorsborn
Posts: 12
Joined: Sat Feb 26, 2011 4:17 am

Rotate image 90 or 270 depending on the side of the page

Post by jorsborn »

I've pieced together something but it doesn't typeset. If you typeset the bit below it will spit out angle=90 on page 1 and angle=270 on page 2. That's correct behavior. However, if I try to use it to dynamically supply the angle= argument to \includegrpahics then it fails (remove the begin/end comment to experience this behavior).

Code: Select all

\documentclass[11pt]{book}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{comment}

\begin{document}

\begin{comment}
\begin{figure}[ht!]
\begin{center}
\includegraphics[width=7.5in,\ifthenelse{\isodd{page}}{angle=90}{angle=270} ]{flashcamdx_logo_proof}
\caption{Top view of the device.}
\label{fig:Internal Features Top View}
\end{center}
\end{figure}
\end{comment}

\ifthenelse{\isodd{\value{page}}}{angle=90}{angle=270}
\newpage
\ifthenelse{\isodd{\value{page}}}{angle=90}{angle=270}

\end{document}

Any suggestions?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Rotate image 90 or 270 depending on the side of the page

Post by localghost »

jorsborn wrote:[…] I want the image bottom always facing the binding. […]
This is no good idea and besides typographical nonsense. The captions and therewith the bottom of the figures should either point to the outer margin or in one direction (left or right). Perhaps another approach by the rotating package is satisfactory for you.

Code: Select all

\documentclass[11pt,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage{rotating}

\begin{document}
  \begin{sidewaysfigure}[!ht]
    \centering
    \rule{12.8cm}{7.2cm}
    \caption{Dummy figure}\label{fig:dummy-1}
  \end{sidewaysfigure}

  \begin{sidewaysfigure}[!ht]
    \centering
    \rule{12.8cm}{7.2cm}
    \caption{Dummy figure}\label{fig:dummy-2}
  \end{sidewaysfigure}
\end{document}
The package manual has more information about possible customization.


Thorsten
jorsborn
Posts: 12
Joined: Sat Feb 26, 2011 4:17 am

Rotate image 90 or 270 depending on the side of the page

Post by jorsborn »

Let's say that it wasn't a bad idea or typographical nonsense for the sake of learning.

Any idea why...

Code: Select all

\ifthenelse{\isodd{\value{page}}}{angle=90}{angle=270}
... doesn't expand inside the arguments for \includegraphics?
Post Reply