quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
333 stars 29 forks source link

vscode: Supply mathjax macros for math-preview and display-mode editing? #97

Closed tecunningham closed 1 year ago

tecunningham commented 1 year ago

I have some mathjax macros that I use a lot.

I would like to define those macros so quarto extension in vscode can use them when rendering maths in (1) "visual mode" editing; or (2) the math preview pane.

(I know how to add mathjax macros to the YAML of a Quarto document so they'll display in the generated HTML, but that YAML doesn't seem to inform the preview-pane or visual-mode rendering of maths).

jjallaire commented 1 year ago

I believe that if you define the macros within a raw tex block within the document they will be picked up by both visual mode and the math preview pane.

That said, I believe that we pick up the macro definitions using a regex over the whole document so if you can provide a minimal example of your YAML definitions that don't work I can see if we can pick those up as well.

tecunningham commented 1 year ago

Oh thanks so much, problem solved. Apologies if this was already in documentation and I missed it.

The following works for me with both preview-pane and visual-mode:


```{latex}
\newcommand{\ut}[2]{\underbrace{#1}_{\text{#2}}}

$$\ut{x^2}{caption}$$


Here's my original YAML definition which was working for the HTML generation:

format: html: embed-resources: true html-math-method: mathjax include-in-header:

jjallaire commented 1 year ago

Okay, great! Glad to hear this works as expected. This isn't in the docs so easy to miss (will remedy that).