emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Inlining TikZ blocks as SVG in HTML export


From: Alan Schmitt
Subject: Re: [O] Inlining TikZ blocks as SVG in HTML export
Date: Mon, 21 Jan 2019 14:49:40 +0100
User-agent: mu4e 1.0; emacs 26.1

On 2019-01-09 22:46, Christophe Garion <address@hidden> writes:

Hello,

I would like to be able to export Org files containing TikZ pictures to HTML files with SVG pictures corresponding to TikZ pictures inlined directly in the HTML files. My use case is to produce quizz questions with graph drawings for the Moodle LMS (https://moodle.org/) used at our university. It is really painful to upload picture files to Moodle and link them to text and Moodle accepts plain HTML5 for text description, so it
seems to be a rather food solution.

Here is an example of how I do it. The by-backend is defined as follows:

;; to export to both latex and html
(defmacro by-backend (&rest body)
 `(cl-case org-export-current-backend ,@body))

#+header: :file (by-backend (latex "sigma3.tikz") (t "sigma3.png")) #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 800
  #+header: :results raw graphics
  #+header: :fit yes
  #+header: :packages '(("" "tikz"))
  #+begin_src latex
  \usetikzlibrary{matrix,arrows}
  \begin{tikzpicture}
 \matrix (m) [matrix of nodes, row sep=1em, column sep=4em]
 { iterate & map & reduce \\
   & & $acci$  \\
$a_{0} = a$ & $f(a_{0})$ & \\ & & $acc_{0} = fc\; (f\; a_{0})\; acci$ \\ $a_1 = a_0+i$ & $f(a_{1})$ &\\ & & $acc_{1} = fc\; (f\; a_{1})\; acc_{0}$ \\
   $\ldots$             & $\ldots$   &\\ & & ~ \\
$a_{n-1} = a_{n-2} + i$ & $f(a_{n-1})$ &\\ & & $acc_{n-1} = fc\; (f \; a_{n-1})\; acc_{n-2}$ \\
   $a_n = a_{n-1} + i$ & $f(a_{n})$         &\\
$a_{n+1} = a_n + i > b$& & $res = fc\; (f\; a_{n})\; acc_{n-1}$ \\
 };
\draw (m-3-1) edge[->,thick] node[auto]{\scriptsize $f$} (m-3-2); \draw (m-5-1) edge[->,thick] node[auto]{\scriptsize $f$} (m-5-2); \draw (m-9-1) edge[->,thick] node[auto]{\scriptsize $f$} (m-9-2); \draw (m-11-1) edge[->,thick] node[auto]{\scriptsize $f$} (m-11-2);

  \draw (m-6-3) edge[dotted] (m-8-3);

  \draw[in=90,out=0] (m-3-2) edge[thick] (m-4-3.north);
\draw (m-2-3) edge[->,thick] node[right]{\scriptsize $fc$} (m-4-3);

  \draw[in=90,out=0] (m-5-2) edge[thick] (m-6-3.north);
\draw (m-4-3) edge[->,thick] node[right]{\scriptsize $fc$} (m-6-3);

  \draw[in=90,out=0] (m-9-2) edge[thick] (m-10-3.north);
\draw (m-8-3) edge[->,thick] node[right]{\scriptsize $fc$} (m-10-3);

  \draw[in=90,out=0] (m-11-2) edge[thick] (m-12-3.north);
\draw (m-10-3) edge[->,thick] node[right]{\scriptsize $fc$} (m-12-3);
  \end{tikzpicture}
  #+end_src

Best,

Alan

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]