[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] shorter syntax for both latex and html export of a figure
From: |
Alan Schmitt |
Subject: |
[O] shorter syntax for both latex and html export of a figure |
Date: |
Mon, 07 Mar 2016 11:35:48 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) |
Hello,
I'm trying to adapt the example that allows to export a figure both to
tikz and to png so that I don't have to manually add all the header
lines.
Here is what I tried:
#+LATEX_HEADER: \usepackage{tikz}
* Tikz test
Here's a tree, exported to both html and pdf.
#+header: :file (by-backend (latex "tree.tikz") (t "tree.png"))
#+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 800
#+header: :results file raw
#+header: :fit yes
#+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 same, with shorter syntax
#+header: :file (by-backend (latex "tree2.tikz") (t "tree2.png"))
#+begin_src tikz
\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 evaluate this first
#+begin_src emacs-lisp :results silent
(defmacro by-backend (&rest body)
`(case org-export-current-backend ,@body))
(org-babel-do-load-languages
'org-babel-load-languages
'((latex . t)))
(defalias 'org-babel-execute:tikz 'org-babel-execute:latex)
(add-to-list 'org-src-lang-modes '("tikz" . latex))
(defvar org-babel-default-header-args:tikz
'((:imagemagick . "yes")
(:iminoptions . "-density 600")
(:imoutoptions . "-geometry 300")
(:results . "file raw")
(:fit . "yes")
(:headers . "'(\"\\\\usepackage{tikz}\")")))
#+end_src
The first part, where all the headers line are there, works great, but
the second source block for a newly defined language tikz (an alias to
latex with some default headers) does not work unfortunately. In the
exported version, I get a minted source block and not a link.
Am I doing something wrong? Is it possible to have a shorter syntax for
these blocks, or do I have to put all the header lines all the time?
Thanks,
Alan
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂ (2016-01, Mauna Loa Obs.): 402.52
signature.asc
Description: PGP signature
- [O] shorter syntax for both latex and html export of a figure,
Alan Schmitt <=