emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* shorter syntax for both latex and html export of a figure
@ 2016-03-07 10:35 Alan Schmitt
  2016-03-07 16:34 ` Charles C. Berry
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Schmitt @ 2016-03-07 10:35 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 177 bytes --]

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:

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: orgtikz.org --]
[-- Type: text/x-org, Size: 1632 bytes --]

#+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

[-- Attachment #1.3: Type: text/plain, Size: 547 bytes --]


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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-08 13:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-07 10:35 shorter syntax for both latex and html export of a figure Alan Schmitt
2016-03-07 16:34 ` Charles C. Berry
2016-03-08 10:33   ` Alan Schmitt
2016-03-08 13:46     ` Alan Schmitt

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).