I'd like to set a variable to be expanded in several LaTeX code blocks. For the sake of simplicity, there is only one in this case, foo
. :header-args :var
is ignored: I presume because LaTeX does not support interactive evaluation? The best I could come up with is verbose. Is there a workaround, for example by using LuaTeX?
foo.org:
#+name: x-val
#+begin_src emacs-lisp :var val=1 :exports none
val
#+end_src
#+RESULTS: x-val
: 1
#+name: foo
#+begin_src latex :noweb yes :tangle foo.tex
\documentclass{article}
\begin{document}
x = <<x-val()>>
\end{document}
#+end_src
foo.tex
\documentclass{article}
\begin{document}
x = 1
\end{document}
The first and second code blocks are evaluated with C-c C-c
and C-u M-x org-babel-tangle
, respectively.
UPDATE:
I tried this:
#+PROPERTY: header-args:latex :var val=1
#+name: foo
#+begin_src latex :noweb yes :tangle foo.tex
\documentclass{article}
\begin{document}
x = val
\end{document}
#+end_src
And I get this:
\documentclass{article}
\begin{document}
x = val
\end{document}
init.el (in full) contains config.el (in full) contains:
(org-babel-do-load-languages '(org-babel-load-languages '((latex . t) (python . t))))