rstudio / distill

Distill for R Markdown
https://rstudio.github.io/distill/
Apache License 2.0
423 stars 57 forks source link

Theorems and other LaTeX-like env support #101

Open shamindras opened 5 years ago

shamindras commented 5 years ago

I've just started using the distill package for personal blogging. Great experience so far.

I wanted to understand if rmarkdown LaTex support is offered similar to bookdown here.

I tried to write a theorem in a distill article by using:

```{theorem}
Here is my theorem.
```

This gave the warning (error):

Warning message:
In get_engine(options$engine) :
  Unknown language engine 'theorem' (must be registered via knit_engines$set()).

And no theorem was displayed. Could anyone please explain if/how to get this working for math-based distill blogposts?

UPDATE: I also tried adding the following (on MacOS) to the distill yaml header:

header-includes:
  - \usepackage{amsmath}
  - \usepackage{amssymb}
  - \usepackage{amsthm}
  - \usepackage{bm}
  - \usepackage{bbm}
  - \usepackage{amsfonts}
  - \usepackage{mathtools}

And also then did the following:

$$\begin{theorem}
We note that the most interesting theorem is the following:
\begin{align}
x &= 1 \\
y &= 2
\end{align}
\end{theorem}$$

This did not display any equation though. If you omit begin{theorem} tags then align does work as per rmarkdown.

cderv commented 2 years ago

Sorry for the delay on this one. I understand this is now a duplicate of #433

I have put an answer in https://github.com/rstudio/distill/issues/433#issuecomment-1004812002 based on new syntax offered by bookdown for theorem env. It should work for distill but it is surely not the best. It should be more built-in the distill article format.

I also tried adding the following (on MacOS) to the distill yaml header:

You can use LaTeX command for a HTML document. \usepackage won't have any effect when you are rendering to HTML. You can't use directly LaTeX code inside HTML unless there is a specific support (like with equation environment because we support MathJax JS library which parse and transform this). \begin{theorem} is not something that will work for a generic HTML.