Open bbolker opened 2 years ago
Hi @bbolker,
For HTML output, the math rendering will by default be supported by MathJax. Here, you are trying to pass raw LaTeX for an HTML output, so this is not full proof. Using the Math markdown syntax would be easier for multi format output. Know that passing raw LaTeX will not always work as MathJaX is not 100% porting LaTeX syntax.
In this case of your example, MathJaX will recognize the \begin{equation}
I believe because it is among the few supportted environment so it will work. Also it seems \small
and \text
are among the supported command. However, I think you need to invert the use of \text{}
and \small{}
. Try:
---
title: "test of raw latex"
output:
html_document: default
pdf_document: default
---
```{=latex}
\begin{equation}
S = \underbrace{b}_{\small \text{birth}}
- \underbrace{\beta S I }_{\small \text{infection}}
\end{equation}
![image](https://user-images.githubusercontent.com/6791940/149117855-5886c51d-4baf-4b38-b945-ab72e3220755.png)
That being said, with R Markdown, it is often better to Markdown syntax which has support for Math Syntax (https://bookdown.org/yihui/rmarkdown/markdown-syntax.html#math-expressions) from Pandoc's Markdown: https://pandoc.org/MANUAL.html#math
So using `$$` block
````markdown
---
title: "test of raw latex"
output:
pdf_document: default
html_document: default
---
Equation
$$
S = \underbrace{b}_{\small \text{birth}}
- \underbrace{\beta S I }_{\small \text{infection}}
$$
It depends if you want numbering equation support or not in the PDF I guess.
Anyway, both works as expected I believe. Does it help ?
there is a triple-back-quote ending delimiter here that I'm having trouble formatting
See the issue guide about how to format https://yihui.org/issue/#please-format-your-issue-correctly
This is related to https://github.com/rstudio/rmarkdown/issues/1449, but the standard solution (identify a raw LaTeX block) isn't working for me.
HTML output looks like this:
(note that "\small" is interpreted literally rather than executed as a LaTeX command)
PDF output is fine:
Here's the whole Rmd file:
Session info: