From 9b9d12ce99592074cac6875fd4cfcb2b73f87330 Mon Sep 17 00:00:00 2001 From: Gerard Vermeulen Date: Wed, 5 Jan 2022 17:37:03 +0100 Subject: [PATCH] Fix Worg image export trick for Emacs-27.2 and Org-9.5.2 --- .gitignore | 2 ++ README.org | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/.gitignore b/.gitignore index b1c34c7..3784151 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ latexmkrc org-store-link setup-include.org +tree.svg +worg-backend-dependent-execution-update.org /_minted-README /eln-cache diff --git a/README.org b/README.org index 9c2a6bf..4d181d6 100644 --- a/README.org +++ b/README.org @@ -1556,6 +1556,62 @@ Listing [[lst:emacs-lisp-setup-call]] initializes the buffer local variables \end{titlepage} #+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 :PROPERTIES: :CUSTOM_ID: sec:programming