Search code examples
emacslatexorg-modefigure

How can I stop org mode from moving my figures to the last page?


I'm currently trying to write up my thesis in emacs org-mode, and have run into some problems with file inclusions.

When I include figures with:

#+NAME: fig:banana
#+CAPTION: this is a figure caption
[[/path/to/image.png]]

(or using a pdf) it works fine. But when I insert another image, it is somehow moved to the end of the file instead of being inserted where it is called.

My pdf-export process (in my ~/.emacs file) looks like this:

(setq org-latex-pdf-process
  '("latexmk -pdflatex='pdflatex -interaction nonstopmode' -pdf -bibtex -f %f"))

Any ideas on how to fix this?


Solution

  • A friend of mine pointed me to the LaTex package placeins.

    #+LATEX_HEADER: \usepackage{placeins}
    
    * section 1
    ** hi!
    
    #+TITLE: fig:banana
    #+CAPTION: this is a banana figure
    [[/link/to/banana.png]]
    
    \FloatBarrier
    
    * section 2
    

    The FloatBarrier stops floats (figures are floats) from jumping over them. I will need to look into passing [tbh] options to figures from org mode further.