6

I am writing an Org document with some large figures (images) which I would like to place on a separate page in landscape orientation when exporting to LaTeX. In LaTeX I can achieve what I want by using \begin{sidewaysfigure}. What is the easiest way to get Org to do this?

Google turns up this documentation, which mentions sideways tables but not sideways figures AFAICT, and this patch, which should add support for sideways figures, but I don't think it has been merged into the version I installed from the Org-mode ELPA repository. (M-x org-version displays Org-mode version 8.2.9 (8.2.9-elpaplus @ […] ~/.emacs.d/elpa/org-plus-contrib-20141012/).

Is there an easy way to get this behavior with my current version of Org?

(Edited to add: It looks like the patch above has been merged into the bleeding-edge Org snapshot, so perhaps I should just install that. However, I would still be interested to know if there is a way to get this functionality using the current stable release of Org from October 2014).

  • 1
    Doesn't it work if you just add \begin{sidewaysfigure}? – Malabarba Oct 18 '14 at 9:06
  • Not as well as I would like. If I just add #+LATEX: \begin{sidewaysfigure} and #+LATEX: \end{sidewaysfigure} before and after, I get a figure environment within a sidewaysfigure, which does not render properly. I could just drop down to LaTeX for the whole thing, of course, but I'd like to retain Org's ability to export to different formats as well if possible. – Jon O. Oct 18 '14 at 19:33
  • 2
    For the time being I've installed the latest Org revision from Git, which works very well for this, although it seems to have bugs in other areas (understandably). If worst comes to worst I guess I can apply the :float sideways patch to the stable version locally. – Jon O. Oct 18 '14 at 19:35
  • 1
    Ah, I see. So the sidewaysfigure environment needs to replace the figure environment? Sounds like a job for exporti hooks. :-) – Malabarba Oct 18 '14 at 19:35
5

Using a current org version (at least 8.2.10, which is the one currently shipped with Emacs), you can achieve what you want by simply using #+begin_sidewaysfigure instead of #+begin_figure.

Try:

(with-temp-buffer (insert
"#+LATEX_HEADER: \\usepackage{rotating}
#+NAME: sideway
#+CAPTION: test
#+begin_sidewaysfigure
[[file:test.png]]
#+end_sidewaysfigure")
(org-mode)
(org-latex-export-as-latex nil nil nil t))

Result:

\begin{sidewaysfigure}
\caption{\label{sideway}test}
\includegraphics[width=.9\linewidth]{test.png}
\end{sidewaysfigure}

For html you could get:

<div class="sidewaysfigure">

<div class="figure">
<p><img src="test.png" alt="test.png" />
</p>
</div>

</div>

which is then for you to fix via css or whatnot.

  • It seems this answer is saying to use a recent org version and use #+begin_sidewaysfigure instead of #+begin_figure. But it doesn't actually say that. Could you clarify? – Malabarba Oct 21 '14 at 10:35
  • Thanks for this answer. I've since switched to using the most recent Org which has a specific option for sideways floats, but this will be very useful if I need other miscellaneous kinds of LaTeX environments in future. – Jon O. Nov 1 '14 at 7:20

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.