latexmarkdownmathjaxquarto

Include external custom math commands from YAML header


I have a bunch of custom math commands that I'd like to ba able to use in all my quarto documents.
Is there a way to include custom math commands in the quarto YAML header (for example, by pointing to a .sty file)?


Solution

  • I think we actually need two external .sty files for this.

    \newcommand{\e}{\varepsilon}
    
    \(
    \newcommand{\e}{\varepsilon}
    \)
    

    Including those in the md or qmd file:

    ---
    format:
      pdf:
        include-in-header: path/to/math_commands.sty
      html:
        include-before-body: path/to/mathjax_commands.sty 
    ---
    
    $$
    \e
    $$
    

    HTML output:
    html output

    PDF output:
    pdf output