emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: Christophe Garion <tofgarion@runbox.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Inlining TikZ blocks as SVG in HTML export
Date: Mon, 21 Jan 2019 14:49:40 +0100	[thread overview]
Message-ID: <87d0oqaznv.fsf@polytechnique.org> (raw)
In-Reply-To: <87va2xwlln.fsf@port-garion.isae.fr>

[-- Attachment #1: Type: text/plain, Size: 2619 bytes --]

On 2019-01-09 22:46, Christophe Garion <tofgarion@runbox.com> 
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

      reply	other threads:[~2019-01-21 13:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09 21:46 Inlining TikZ blocks as SVG in HTML export Christophe Garion
2019-01-21 13:49 ` Alan Schmitt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d0oqaznv.fsf@polytechnique.org \
    --to=alan.schmitt@polytechnique.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=tofgarion@runbox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).