From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: Inlining TikZ blocks as SVG in HTML export Date: Mon, 21 Jan 2019 14:49:40 +0100 Message-ID: <87d0oqaznv.fsf@polytechnique.org> References: <87va2xwlln.fsf@port-garion.isae.fr> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:51621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glZxS-0006gf-My for emacs-orgmode@gnu.org; Mon, 21 Jan 2019 08:49:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1glZxR-0003ZE-KO for emacs-orgmode@gnu.org; Mon, 21 Jan 2019 08:49:46 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:26812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1glZxR-0003Vy-9g for emacs-orgmode@gnu.org; Mon, 21 Jan 2019 08:49:45 -0500 In-reply-to: <87va2xwlln.fsf@port-garion.isae.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Christophe Garion Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; format=flowed On 2019-01-09 22:46, Christophe Garion 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 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE6lXof/BsSVW56ZmGBA0KO07S5ccFAlxFzfUACgkQBA0KO07S 5cfQGggAydIdh0P1QVbnwhbBOwnkp+sApQRmppbl6Pz0XSfNkvB5c4LQq+5OmqMY Q7eUlK4eW4iIV9X9sDIX9NLWrzCNssu+jF+kywCS6nBSO3T5e0UEPe84EPzUNH5E lgZE2Q+TuYiuDOVyfDy3P01zV7dsPF140KY+DS+0RpImws1i63yPHctMZ9soz28P AFyMerz8y5Dnm+pkNKdPEtcW6sKV13Md/cPhMdSsG/A93Y+VC/dI2OJ5RC7QoTzR hnnzehgRxhc6Z7AN9lo6OwCGWNvauU0Qzk4Wib7oLsnFX9XG+t0g9BPXTMcrIuQ+ DvoBMZRzB7hYNUqadeXUUZEl48/PiQ== =P8/5 -----END PGP SIGNATURE----- --=-=-=--