-
Notifications
You must be signed in to change notification settings - Fork 11
Display math highlighting #29
Comments
It would be great to get some clarify what the use cases for "raw" equations are. I definitely don't think that raw LaTeX environments are a best practice if you are concerned about portability, as equations without \begin{equation}
E=mc^2
\end{equation} I do however know that the bookdown documentation uses a lot of raw equation environments, and I'm sure there is some motivation for this (and awareness that the tradeoff of having them stripped out of some formats is worth it -- perhaps there is a special workaround for @yihui What do you know about the tradeoffs here and when its important/preferred/required to escape out of constraints imposed by If it turns out that raw equation environments are indeed required in some cases because of limitations in |
One reason to use raw input is to prevent pandoc from converting math environments. The syntax |
Oh, I missed that the conversion only happens when parsing LaTeX, not Markdown. This means it could possibly be fixed in the LaTeX writer. |
Okay, I see, when converting .tex -> .md, But if you use Unless this is something that is easy to address, perhaps as things are, the suggested style for general aligned equations in a .(q)md file should be
|
In bookdown, I had to apply a hack to preserve LaTeX math environments for output formats that are not PDF or HTML (e.g., EPUB): rstudio/bookdown@8a4d8c0 That is, I don't require |
@tarleb Do you think there is something else/more that Pandoc should be doing here? I confess that I'm not excited about the idea of math blocks having two syntaxes (one of which does not show up in the AST as math) so if there is a way to make |
I'm not sure, but it does seem reasonable to me to change pandoc to do the equivalent of function Math (mth)
local is_align = mth.text:match [[^%s*\begin%{align%}.*\end%{align%}%s*$]]
if FORMAT:match('tex') and is_align then
return pandoc.RawInline('tex', mth.text)
end
end I think this would should be doable with minor changes to the LaTeX and ConTeXt writers, but I might be missing something. I'll dig a bit deeper and bring it up with John. |
Issue: to use latex environments (like
align
orequation
) in a Quarto document, the best practice (iiuc) is to use them raw (\begin{align} ... \end{align}
), not to enclose them in dollar signs (like$$\begin{align} ... \end{align}$$
).However, the VSCode extension implicitly encourages the latter (see image below; enclosing in dollar signs makes the align environment be nicely highlighted and preview-able when editing, whereas without the dollar signs it just looks like plain text). This is not good, because one shouldn't enclose environments in dollar signs, since this will lead to LaTeX compiling error when rendering (as described below).
Possible solution: Make it so highlight/preview-ing works for such latex environments without enclosing them in dollar signs.
For an example, here is a quarto document
example.md
:This looks like the following, in with quarto-vscode:
Enclosing the align environment in double dollar signs, like
$$\begin{align} ... \end{align}$$
makes the highlighting/previewing work in VSCode, but makes the following (bad) TeX, if converted to PDF or TeX formats. E.g., withquarto render example.md --to pdf
, the second example above results in the following tex code:which causes (xe)latex to give the error
Removing the double dollar signs fixes this issue, but then you can't get nice highlighting in VSCode.
The text was updated successfully, but these errors were encountered: