From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: shorter syntax for both latex and html export of a figure Date: Tue, 08 Mar 2016 14:46:26 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adHy4-0003cA-0G for emacs-orgmode@gnu.org; Tue, 08 Mar 2016 08:46:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adHy0-0002Lo-PW for emacs-orgmode@gnu.org; Tue, 08 Mar 2016 08:46:31 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:61482) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adHy0-0002JP-Jp for emacs-orgmode@gnu.org; Tue, 08 Mar 2016 08:46:28 -0500 In-Reply-To: (Alan Schmitt's message of "Tue, 08 Mar 2016 11:33:04 +0100") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Charles C. Berry" Cc: emacs-orgmode --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2016-03-08 11:33, Alan Schmitt writes: > Thank you for the suggestion. At the moment I use a macro (because I > need to put the resulting figure in a figure environment, as I want a > label and caption), but I will give this a try. I'm fairly happy with what I ended up doing (using a macro as I need to pass some extra arguments, and I don't know how to extend a source block with custom arguments), so here is my solution. I define this utility function that is lob-ingested: #+name: wrap-res #+BEGIN_SRC emacs-lisp :var link=3D"" :var caption=3D"" :var label=3D"" :re= sults raw :exports none (concat "#+LABEL: " label "\n#+CAPTION: " caption "\n" link) #+END_SRC I also define a macro (it's on one line but for this email I'm wrapping it) #+macro: tikzfig #+header: :file (by-backend (latex "$1.tikz") (t "$1.png")) :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 300 :results file raw :fit yes :headers '("\\usepackage{tikz}") :post wrap-res(link=3D*this*,label=3D"fig:$1",caption=3D"$2") I can then have the following that is exported both in tikz and png (I do not use svg as I found htlatex lacking for text nodes): {{{tikzfig(cnf-example,An ordinal in Cantor normal form)}}} #+begin_src latex \begin{tikzpicture}[scale=3D2, every node/.style=3D{transform shape}] \node[color=3Dblue]{$\omega^{(\omega^\omega\,+\, \omega^2 \times 8 \,+\, \o= mega)}+ \omega^\omega + \omega^4+ 6$}; \end{tikzpicture} #+end_src The first argument of the macro is the label of the figure (with "fig:" added automatically) as well as the file used to export the figure, the second argument is the caption. Hopefully this may be useful to others. Best, Alan =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 Monthly Athmospheric CO=E2=82=82 (2016-02, Mauna Loa Obs.): 404.02 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBCgAGBQJW3teyAAoJEAQNCjtO0uXHfD4H/jxbaY+BY+9XNXqV/s0cwtzj hfi5zGTMGv7KJi1xVMl03xWVAkzqzZ3+EKQS59KiFH5GZupjDy9yteCjggWZHSsA mdNc/n3wHqdpnZ4kElaL5lrlc7jjlv7RJqeDNdz9ji6irDO1jR0LZpmWdW9GAn5B 03VLxRiVQUAOx4FvOY8himfBUxOxp6YczU/LoUYju0/1oYAJQpMBfgsgjIGnU+fu KUUDhHAfhEUixAvl1kwmu4twG2EhP0g/ADjmQqsxOF+3DL2y5Dv5n2gw3ChbKqzN RmmGhoXVGsut9PuWw0dUNuNJVQeFHhSLX1VoqeYyJ4i3tpReSNhUZs6Dc0nmzCg= =FSX/ -----END PGP SIGNATURE----- --=-=-=--