> On Aug 1, 2017, at 10:20 PM, Grant Rettke <g...@wisdomandwonder.com> wrote: > > Good morning, > > I'm happily exporting an Org-Mode document to LaTeX using the nifty > `letterine' package. An example is attached. Writing using it has been > so fun that naturally now I want to export it both to text and HTML. > My source document looks like this for reference and all of this works > fine: > >> start > #+TITLE: A Poem Title > #+AUTHOR: > #+DATE: > #+OPTIONS: num:nil > #+LATEX: \pagenumbering{gobble} > > #+BEGIN_CENTER > @@latex:\lettrine[lines=1]{T}{this}@@ is line 1. > > @@latex:\lettrine[lines=1]{H}{ere}@@ is line 2. > > @@latex:\lettrine[lines=1]{O}{ver}@@ there is line 3. > #+END_CENTER >> end > > Now I'm left be wondering how I can using a single document and export > it correctly to LaTeX, HTML and text. Here are some ideas I came up > with: > > - Write the same line two times, one for each exporter. Redundant but > it would work. > - Use a source block that takes a line of text, checks the type of > exporter running, and returns an appropriate markup then on export it > works right. > - Maybe there is a macro for this?
Putting together a macro seems like the best option. Recall that you can use elisp in macros by placing it between `(eval’ and `)', so the following emits “def’ in all but latex exports and “abc” for latex. #+BEGIN_SRC emacs-lisp (defun foo (a b) (if (eq 'latex org-export-current-backend) a b)) #+END_SRC #+MACRO: bar (eval (foo $1 $2)) {{{bar("abc" "def")}}} HTH, Chuck