1

I found this discussion, and the last response gives this code:

#+TITLE: Test
#+AUTHOR: Blah
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [american]
#
# Setup tikz package for both LaTeX and HTML export:
#+LATEX_HEADER: \usepackage{tikz}
#+PROPERTY: header-args:latex+ :packages '(("" "tikz"))
#
#+PROPERTY: header-args:latex+ :exports results

* One Diamond

#+name: diamond
#+header: :file (by-backend (latex "diamond.tikz") (t "diamond.svg"))
#+begin_src latex :results raw file
  \begin{tikzpicture}
    \draw (1,0) -- (0,1) -- (-1,0) -- (0,-1) -- cycle;
    % \node at (0,0) {\(x_i\)};
  \end{tikzpicture}
#+end_src

#+caption: A diamond.
#+attr_latex: :float t :width ""
#+results: diamond

* COMMENT setup

#+name: setup
#+begin_src emacs-lisp :results silent :exports none
  ;; (setq org-babel-latex-htlatex "htlatex")
  (defmacro by-backend (&rest body)
    `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
#+end_src

# Local variables:
# eval: (org-sbe "setup")
# End:

First, the local variable call to elisp block setup doesn't seem to work. But then I don't really understand what by-backend is doing. Where can I learn about such a macro and why is it used in this situation? Also, why is so much placed in the org-mode header, i.e., what exactly are these doing?

#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [american]
#
# Setup tikz package for both LaTeX and HTML export:
#+LATEX_HEADER: \usepackage{tikz}
#+PROPERTY: header-args:latex+ :packages '(("" "tikz"))
#

I've seen TikZ code like this:

\documentclass[tikz, margin=3mm]{standalone}

and org-mode doesn't seem to like it. Where and how would it be utilized? Basically, I'm trying to put together a comprehensive tutorial on TikZ in org-mode. I'm seeing lots of one-off tunneling. Need a good tutorial, I'd say. . . .

  • 1
    I don't know which version of org-mode above code was written for: by-backend is seemingly used for swiching the export behaviour according to chosen backends (latex vs. html e.g.). in org-mode 9 such a functionality is provided by org-export-current-backend. – Dieter.Wilhelm Jan 1 '17 at 20:09
  • #+LATEX_CLASS: will invoke an Org template named "article", this template defines documentclass and some other headers. #+LATEX_CLASS_OPTIONS: will populate the part of the template related to documentclass. #+LATEX_HEADER: will also populate the same template, but will insert any LaTeX code before documentclass and \begin{document}. You don't have to use tikz document class (unless your entire work is in tikz, in which case you don't really need Org). – wvxvw Jan 2 '17 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.