0

I've been writing in Markdown format lately to generate a standalone HTML (mathjax) and a beamer presentation for scientific documentations, via Pandoc.

Now I am trying to add new math definitions (using LateX's \newcommand). Adding the new commands file works great for beamer, as I input all the \newcommand lines the in the template, then parse it with Pandoc's --template=<file>

To do the same for HTML, I add the command directly in the file using the new math command, for instance $$\newcommand{\avg}[1]{\left \langle #1 \right \rangle}$$ and it works great with panodc standalone HTML conversion, even with my editor's HTML preview (Sublime Text 3 with OmniMarkupPreviewer)

Now what is the best solution to add more than 200 new commands ?

  • painfully define all new commands in my main Markdown file ?

  • configure a local mathjax configuration file (read the documentation but it's not working for me)

  • other options ?
scoa
  • 19,359
  • 5
  • 65
  • 80
SAAD
  • 759
  • 1
  • 9
  • 23
  • but how can I use this feature with pandoc ? – SAAD Aug 06 '15 at 15:29
  • actually, there is a simpler solution. Create a file with all your definitions, for instance `new_commands.md`, and then compile like that : `pandoc new_commands.md main_file.md -o main_file.html` This will concatenate the two files before compilation – scoa Aug 06 '15 at 15:56
  • more than 200 new commands? what are you trying to accomplish? maybe there's a better way... – mb21 Aug 07 '15 at 11:19
  • actually this file is already done ... it's a one-file compilation of various `\newcommands` used separately in publications, and now I want the same commands to write a technical documentation in Markdown – SAAD Aug 07 '15 at 14:34
  • I'm guessing the problem with configuring MathJax would be that you have to convert all your macros from newcommand to JS declarations. The third party preamble extension allows you to use newcommand in the configuration, maybe that helps? See https://github.com/mathjax/MathJax-third-party-extensions/blob/master/preamble/README.md – Peter Krautzberger Aug 08 '15 at 06:43
  • @PeterKrautzberger : this would be great, but can you give a minimal example of locally configuring MathJax to be compiled later by Pandoc ? I already tried manually converting one or two macros in a `local.js` script but it doesn't seem to work. – SAAD Aug 12 '15 at 13:55
  • If you need one solution for both html and LaTeX output, @scoa's concatenation seems better. I don't know pandoc well enough but perhaps you can even add some html/CSS to hide the macros without interfering with the LaTeX side. – Peter Krautzberger Aug 12 '15 at 14:07

0 Answers0