org-macros
org-macros copied to clipboard
multi-export-target macros
I'm working on an org file that will eventually export to html and pdf/latex.
If anyone's interested, I can add these sorts of macros on here, and perhaps give them some better names.
#+MACRO: begin_main (eval (begin-main-macro))
#+MACRO: end_main (eval (end-main-macro))
#+MACRO: begin_aside (eval (begin-aside-macro))
#+MACRO: end_aside (eval (end-aside-macro))
#+begin_src elisp :exports results :results silent
(defun begin-main-macro ()
(pcase org-export-current-backend
('latex "\\begin{minipage}[t]{0.5\\textwidth}")
('html "@@html:<div class='main'>@@")
(t "")))
(defun end-main-macro ()
(pcase org-export-current-backend
('latex "\\end{minipage}")
('html "@@html:</div>@@")
(t "")))
(defun begin-aside-macro ()
(pcase org-export-current-backend
('latex "\\begin{minipage}[t]{0.2\\textwidth}")
('html "@@html:<div class='aside'>@@")
(t "")))
(defun end-aside-macro ()
(pcase org-export-current-backend
('latex "\\end{minipage}")
('html "@@html:</div>@@")
(t "")))
#+end_src
Usage:
{{{begin_main}}}
Main section stuff goes here.
{{{end_main}}}
{{{begin_aside}}}
Aside section stuff goes here.
{{{end_aside}}}
You have to run the src block with C-c C-c
before exporting. I think there's an option to do this automatically, but I haven't set that up.