Fix Worg image export trick for Emacs-27.2 and Org-9.5.2

This commit is contained in:
Gerard Vermeulen 2022-01-05 17:37:03 +01:00
parent cc7d3adff3
commit 9b9d12ce99
2 changed files with 58 additions and 0 deletions

2
.gitignore vendored
View File

@ -20,6 +20,8 @@
latexmkrc latexmkrc
org-store-link org-store-link
setup-include.org setup-include.org
tree.svg
worg-backend-dependent-execution-update.org
/_minted-README /_minted-README
/eln-cache /eln-cache

View File

@ -1556,6 +1556,62 @@ Listing [[lst:emacs-lisp-setup-call]] initializes the buffer local variables
\end{titlepage} \end{titlepage}
#+end_src #+end_src
*** [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#orgcc214c1][Worg: backend dependent execution]]
:PROPERTIES:
:CUSTOM_ID: sec:backend-dependent-execution-update
:END:
#+caption[Worg update: backend dependent header arguments]:
#+caption: Worg update: backend dependent header arguments.
#+name: lst:backend-dependent-execution-update
#+begin_src org :tangle worg-backend-dependent-execution-update.org
,#+latex_header: \usepackage{tikz}
,#+header: :file (by-backend (html "tree.svg") (latex nil))
,#+header: :results (by-backend (html "raw file") (latex "latex replace"))
,#+header: :headers '("\\usepackage{tikz}\n")
,#+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
,* COMMENT Setup
,#+begin_src emacs-lisp
(with-eval-after-load 'ox
(setq org-babel-latex-htlatex "htlatex")
(defmacro by-backend (&rest body)
`(cl-case org-export-current-backend ,@body)))
,#+end_src
#+end_src
#+caption[Specify export backend dependent header arguments]:
#+caption: Specify export backend dependent header arguments.
#+name: lst:header-arguments-by-backend
#+begin_src emacs-lisp
(with-eval-after-load 'ox
(defmacro by-backend (&rest body)
`(cl-case org-export-current-backend ,@body)))
#+end_src
This section updates the outdated [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html#orgcc214c1][Worg: backend dependent execution]] example to
Emacs-27.2 and Org-9.5.2. It shows how to export [[https://en.wikipedia.org/wiki/PGF/TikZ][PGF/TikZ]] images to:
1. [[https://en.wikipedia.org/wiki/PDF][PDF]] by embedding in [[https://www.latex-project.org/][LaTeX]].
2. [[https://en.wikipedia.org/wiki/HTML][HTML]] by passing from [[https://www.latex-project.org/][LaTeX]] by [[https://en.wikipedia.org/wiki/PDF][PDF]] and to [[https://en.wikipedia.org/wiki/Scalable_Vector_Graphics][SVG]].
Listing [[lst:backend-dependent-execution-update]] tangles to
[[file:worg-backend-dependent-execution-update.org][worg-backend-dependent-execution-update.org]] as either a standalone example or an
example for inclusion. Listing [[lst:header-arguments-by-backend]] tangles to the
=user-init-file= to make the convenience =by-backend= macro always available.
Finally, inclusion of [[file:worg-backend-dependent-execution-update.org][worg-backend-dependent-execution-update.org]] produces here
the figure with the nodes 1, 2, 3, and 4:\\
#+include: worg-backend-dependent-execution-update.org
*This line is hidden because of the "{{{*}}}COMMENT Setup" header in the inclusion!*
* Programming * Programming
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: sec:programming :CUSTOM_ID: sec:programming