1

Say you have the following org-babel source block:

#+BEGIN_SRC latex :results raw :file test.pdf
\LaTeX
#+END_SRC

When executing it, org-babel will do the actual compilation in a temporary directory and move the resulting PDF back to your working directory afterwards. The problem with this is that I cannot include my local LaTeX commands and configuration with \input{myMacros}, since it won't be found in the temporary directory.

How can I tell org-babel to execute a source block in the folder of the org-mode file (hence in the default-directory)?

2
  • 1
    Looks like the :dir header argument can probably be used for this, see orgmode.org/manual/dir.html and org-babel.readthedocs.io/en/latest/header-args/#dir Example: #+header: :dir (format "%s" default-directory) (Note: probably not working with just default-directory). If this works I will post as answer.
    – Hubisan
    Oct 15 '19 at 8:05
  • @Hubisan Unfortunately, your proposal doesn't work here. Even when using :dir, the compilation still takes place in some temporary directory. Maybe this is a bug in org-mode 9.2.6?
    – Timm
    Oct 15 '19 at 10:33
0

I've checked :dir again and it seems to work now (with org-mode v9.4). Here is a minimal example:

#+BEGIN_SRC latex :tangle ./workingdir/inputfile.tex
Content from input file
#+END_SRC

#+BEGIN_SRC latex :results raw :file test.pdf :dir ./workingdir
\input{inputfile}
\LaTeX
#+END_SRC

Thanks to @Hubisan for the pointer!

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.