[Top][All Lists]

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

Re: [O] shorter syntax for both latex and html export of a figure

From: Alan Schmitt
Subject: Re: [O] shorter syntax for both latex and html export of a figure
Date: Tue, 08 Mar 2016 14:46:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin)

On 2016-03-08 11:33, Alan Schmitt <address@hidden> 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="" :var caption="" :var label="" :results raw 
:exports none
(concat "#+LABEL: " label "\n#+CAPTION: " caption "\n" link)

I also define a macro (it's on one line but for this email I'm wrapping

#+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

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=2, every node/.style={transform shape}]
\node[color=blue]{$\omega^{(\omega^\omega\,+\, \omega^2 \times 8 \,+\, 
\omega)}+ \omega^\omega + \omega^4+ 6$};

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.



OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂ (2016-02, Mauna Loa Obs.): 404.02

Attachment: signature.asc
Description: PGP signature

reply via email to

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