On 2025-11-02 17:53, Ihor Radchenko wrote: > Could you provide a specific example you are having trouble with?
Hi Ihor!
Of course, sorry for not providing it in the first place. Even this
simplified version of the last example from ob-latex documentation
doesn't work
#+LATEX_HEADER: \usepackage{tikz}
* Tikz test
Here's a tree, exported to both html and pdf.
#+header: :file tree.svg
#+header: :imagemagick
#+header: :results raw
#+begin_src latex
\usetikzlibrary{trees}
\begin{tikzpicture}
\node [circle, draw, fill=red!20] at (0,0) {1}
child { node [circle, draw, fill=blue!30] {2}
child { node [circle, draw, fill=green!30] {3} }
child { node [circle, draw, fill=yellow!30] {4} }};
\end{tikzpicture}
#+end_src
The cure for it is setting
(setq org-babel-latex-preamble (lambda (_)
"\\documentclass[preview]{standalone}"))
and adding =#+header: :headers '("\\usepackage{tikz}")=
to the block headers so it looks like
#+header: :file tree.svg
#+header: :imagemagick
#+header: :results raw
#+header: :headers '("\\usepackage{tikz}")
#+begin_src latex
\usetikzlibrary{trees}
\begin{tikzpicture}
\node [circle, draw, fill=red!20] at (0,0) {1}
child { node [circle, draw, fill=blue!30] {2}
child { node [circle, draw, fill=green!30] {3} }
child { node [circle, draw, fill=yellow!30] {4} }};
\end{tikzpicture}
#+end_src
The latter block execution produces correct output. The former one's
relevant part of *Org PDF LaTeX Output* log is
! Undefined control sequence.
\pgfsys@beginpicture ...ys@svg@boxmodefalse \EndP
\HtmlParOff \pgfkeys
{/pgf...
So it obviously doesn't like this part of =org-babel-latex-preamble=
\\def\\pgfsysdriver{pgfsys-tex4ht.def}
designed specifically for html export and used for some reason in
imagemagick's one (as well as svg without imagemagick header)
--
Best wishes,
Yaroslav Drachov
signature.asc
Description: PGP signature
