[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)
#+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=*this*,label="fig:$1",caption="$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=2, every node/.style={transform shape}]
\node[color=blue]{$\omega^{(\omega^\omega\,+\, \omega^2 \times 8 \,+\,
\omega)}+ \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
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂ (2016-02, Mauna Loa Obs.): 404.02
signature.asc
Description: PGP signature