Using latex \newcommand
with revealjs output
#2068
-
Thanks for all your work on quarto - it's awesome. I am following the example here for including equations in a quarto document using the revealjs format. When I knit the following
Without newcommand, output generated
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Reveal.js is HTML, thus it raw tex is ignored. If you really want to use LaTeX, choose beamer, not Reveal.js: https://quarto.org/docs/presentations/beamer.html Footnotes |
Beta Was this translation helpful? Give feedback.
-
HTML math in revealjs will use MathJax. In MathJax, if support exist for a TeX command, then you can use it. It happens that However, you need to use Math environment, with ---
title: "mre"
format:
revealjs:
self-contained-math: true
---
$$
\newcommand\muy{\mathrm{mu\_y}}
\begin{equation}
\muy
\end{equation}
$$ By using only Raw latex with Example ---
title: "mre"
format:
revealjs:
self-contained-math: true
---
```{=tex}
\begin{equation}
\newcommand\muy{\mathrm{mu\_y}}
\muy
\end{equation}
``` But this would work too ---
title: "mre"
format:
revealjs:
self-contained-math: true
---
\begin{equation}
\newcommand\muy{\mathrm{mu\_y}}
\muy
\end{equation}
In Markdown using the Overall, Mathjax processing adds a layer that needs to be understood when some specific customization are desired. Hope it helps understand |
Beta Was this translation helpful? Give feedback.
-
Note that (as I learned yesterday from another quarto user), \newcommand does work. You just need to adjust your syntax:
Specifically, I think the issue you're seeing (on top of raw latex not being emitted in html formats) is that in quarto, we typically don't use If you're careful to use while
generates this PDF output: while |
Beta Was this translation helpful? Give feedback.
Note that (as I learned yesterday from another quarto user), \newcommand does work. You just need to adjust your syntax:
Specifically, I think the issue you're seeing (on top of raw latex not being emitted in html formats) is that in quarto, we typically don't use
\begin{equation}
, we use display math ($$
) and regular crossreferences ({#eq-muy}
).If you're careful to use
\newcommand
outside math mode, then the markdown should be portable across formats. This way, you get the following slides by default:while
genera…