I have a org mode file which has some custom macros like
#+LATEX_HEADER: \newcommand{\opt}[1]{{#1}^{*}}
Sometimes I need to export the same document to html, where this appears as
undefined control sequence \opt
How should I define the same macro so that html exports can see them too?
There is incomplete solution:
#+LATEX_HEADER: \newcommand{\opt}[1]{{#1}^{*}}
#+BEGIN_HTML
\(
\newcommand{\opt}[1]{{#1}^{*}}
\)
#+END_HTML
\opt{2} - works for 'latex backend
\( \opt{2} \) - works for 'html backend
It needs a way to combine them. You have to escape macros with \(
depending on backend, for example like in answer https://stackoverflow.com/a/12719168/1937596, but from that time org-mode changed API
If applicable to you, you could try using Org macros in such a way:
#+MACRO: opt @@latex:\opt{$1}@@@@html:$1@@
That is {{{opt(...)}}} gets converted to:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With