4

I am trying to rotate a figure on the page by 90 degrees. I am using:

\usepackage{rotating}

and then my figure code looks like:

\begin{sidewaysfigure*}[ht]
  \centering
  \begin{tabular}{@{}cc@{}}
    \includegraphics[width=120mm]{c1713_a_vm.png} &
    \includegraphics[width=120mm]{c1713_b_vm.png}
  \end{tabular}                                       
  \caption{figure caption}
  \label{fig_label}
\end{sidewaysfigure*}

This produces a figure that seems to be hugging the left hand side, and missing half of the caption. I want to center it horizontally (as you view it), but I'm not sure how to do this.

I have found a similar problem here, and apparently the problem here is the "mn2e" document class (for an astrophysical journal). I'm not using that class, but I am using a class for a different astrophysics journal ("emulateapj"), which seems like a bit of a coincidence! The remedy suggested was to put:

\RequirePackage{rotating}

before the \documentclass instruction. But when I try this, it doesn't solve my problem and I get the following error:

*** BUG ***
In pixman_region32_init_rect: Invalid rectangle passed
Set a breakpoint on '_pixman_log_error' to debug

enter image description here


MWE:

\documentclass{emulateapj}
\newcommand{\vdag}{(v)^\dagger}
\newcommand\aastex{AAS\TeX}
\newcommand\latex{La\TeX}
\usepackage{amsmath,mathtools,etoolbox}
\usepackage{longtable}
\usepackage{float}
\usepackage{tabularx,colortbl}
\usepackage{adjustbox}\usepackage{mathtools}
\usepackage{array}
\usepackage{makecell}
\usepackage{stackengine}
\setstackEOL{\cr}                                                        
\usepackage[table]{xcolor}
\usepackage{adjustbox}
\usepackage{rotating}

\begin{document}

\begin{sidewaysfigure*}[ht]                                                                                                                                                                
  \centering
  \begin{tabular}{@{}cc@{}}
    \includegraphics[width=120mm]{1713_a_vm.png} &
    \includegraphics[width=120mm]{1713_b_vm.png}
  \end{tabular}
  \caption{Figure caption figure caption figure caption.}
  \label{1713_vm}                                                                                                                                                                                             
\end{sidewaysfigure*}

\end{document}
  • 1
    Please always post a complete MWE, not code fragments, otherwise helpers have to guess what is happening and make best guess suggestions. – Ross Sep 23 '17 at 01:22
  • 1
    Try \vspace{\fill} \begin{adjustbox} {angle=90,center,nofloat=table} .... \end{adjustbox}\vspace{\fill}, obviously after adding \usepackage{adjustbox} – Ross Sep 23 '17 at 01:28
  • Thanks. I've added a MWE now. I tried your suggestion. It was still off the page but I'm not sure if I was putting it in the right place. – user1551817 Sep 23 '17 at 02:04

2 Answers2

3

The default format for apj is twocolumn. It can be set to one column with the class option \documentclass[onecolumn]{emulateapj}. Indeed, if this class option is chosen, the two figures are centered horizontally on the page.

The starred variant sidewaysfigure* is intended to switch the sidewaysfigure environment from two column to one column. However, with the default class option set to twocolumn, the sideways table remains in the first (left) column on a two column page.

One column can be enforced by invoking \onecolumngrid before the sidewaystable environment. I also changed sidewaysfigure* to sidewaystable* since you are putting a table in the sideways environment rather than a figure.

You can get the Figure prefix for the caption by adding \usepackage{capt-of} and using \captionof{figure}{my caption}. Note it is not possible to use \captionof from the caption package. Loading the caption package generates many errors, presumably due to clashes with what is happening inside the emulateapj class file.

This is the result, with the showframe option added to geometry to show the positioning.:

enter image description here

This is the MWE:

\documentclass{emulateapj}
\newcommand{\vdag}{(v)^\dagger}
\newcommand\aastex{AAS\TeX}
\newcommand\latex{La\TeX}
\usepackage{amsmath,mathtools,etoolbox}
\usepackage[showframe]{geometry}
\usepackage{rotating}
%\usepackage{longtable}
%\usepackage{caption}
%\usepackage{float} 
\usepackage{capt-of}
\usepackage{tabularx,colortbl}
\usepackage{mathtools}
\usepackage{array}
\usepackage{makecell}
\usepackage{stackengine}
\setstackEOL{\cr}                                                        
\usepackage[table]{xcolor}

\begin{document}

\onecolumngrid

\begin{sidewaystable*}
    \begin{tabular}{@{}cc@{}}
    \includegraphics[width=0.45\textheight]{example-image-a} &
    \includegraphics[width=0.45\textheight]{example-image-a}
  \end{tabular}
  \captionof{figure}{ caption figure caption figure caption.}
  \label{1713_vm}
\end{sidewaystable*}

\end{document}
Ross
  • 5,656
  • 2
  • 14
  • 38
  • 1
    You can use \figcaption{caption figure} and so you don't need the caption package that causes the errors. – koleygr Sep 23 '17 at 10:40
  • 1
    @koleygr. Thanks. Maybe what I wrote wasn't clear. I used \captionof from the capt-of package. I rewrote that part of the answer. – Ross Sep 23 '17 at 10:53
  • 1
    Ok. Didn't noticed that. Nice (You already have +1 from me I am not deleting my answer just because somebody else (other document class) will find it useful.) – koleygr Sep 23 '17 at 11:17
1

You can try without sidewaysfigure just using tikz package like this:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{blindtext}
\usepackage{caption}
\begin{document}

\pagebreak
\thispagestyle{empty}
\begin{tikzpicture}
\node[rotate=-90] at (0,0) {\begin{minipage}{0.98\textheight}
                   \begin{center}
                   I'd like to rotate this page
                   \end{center}
                   \blindtext

                   \centering
                   \includegraphics[width=0.3\textwidth]{example-image-a}
                      \captionof{figure}{Test caption}
                \end{minipage}};
\end{tikzpicture}

\end{document}

Also you can see my answer here: https://tex.stackexchange.com/a/392793/120578 if you wish to rotate the pdf page too

koleygr
  • 20,105