From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: "Charles C. Berry" <ccberry@ucsd.edu>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: shorter syntax for both latex and html export of a figure
Date: Tue, 08 Mar 2016 14:46:26 +0100 [thread overview]
Message-ID: <m2ziu9t74d.fsf@charm-ecran.irisa.fr> (raw)
In-Reply-To: <m28u1tuun3.fsf@charm-ecran.irisa.fr> (Alan Schmitt's message of "Tue, 08 Mar 2016 11:33:04 +0100")
[-- Attachment #1: Type: text/plain, Size: 1841 bytes --]
On 2016-03-08 11:33, Alan Schmitt <alan.schmitt@polytechnique.org> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
prev parent reply other threads:[~2016-03-08 13:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-07 10:35 shorter syntax for both latex and html export of a figure Alan Schmitt
2016-03-07 16:34 ` Charles C. Berry
2016-03-08 10:33 ` Alan Schmitt
2016-03-08 13:46 ` 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=m2ziu9t74d.fsf@charm-ecran.irisa.fr \
--to=alan.schmitt@polytechnique.org \
--cc=ccberry@ucsd.edu \
--cc=emacs-orgmode@gnu.org \
/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).