Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use latex expression of chemarr for `gitbook` format of bookdown package?

I would like to use latex expression of chemarr for gitbook format of bookdown package.

\begin{equation}
  [C] + [R] 
  \xrightleftharpoons[k_{-1}]{k_1}
  [CR] + [C] 
  \xrightleftharpoons[k_{-2}]{k_2}
  [C2R]
(\#eq:multiplebinding)
\end{equation}

For PDF format, there is no problem of displaying the equation.

PDF-latex

On the other hand, for gitbook format there is an error message.

gitbook-latex

It's mainly because I cannot define the following yaml header for gitbook format.

header-includes:
  - \usepackage{chemarr}

Is there a way to use latex expression of chemarr for gitbook format of bookdown package? If it's impossible, is there a way to use include_graphics function and add equation numbering (say, 19.16 in this example)?

like image 487
Sungpil Han Avatar asked Aug 21 '20 04:08

Sungpil Han


People also ask

How can I list all LaTeX packages in Rmarkdown?

As of rmarkdown version 1.4 it has been possible to use the extra_dependencies parameter to list a character vector of LaTeX packages. This is useful if you need to load multiple packages:

How do you use summation(∑) in latex?

How do you use summation (∑) in LaTeX? LaTeX provides us with the default or amsmath package which gives us commands to beautifully typeset summations. In this article, we shall explore the various commands to typeset summations with numerous examples. In mathematics, summation is denoted by the Greek capital letter sigma (∑).

What is bookdown in R?

Bookdown introduces some additional functionality on top of R Markdown that makes it particularly useful for writing a thesis. You can automatically handle all the numbering of your sections, figures, and tables with bookdown, as well as automatically generating contents pages, and lists of tables and figures.

Should I use bookdown for my thesis?

For PhD students who might want to use bookdown for their thesis I’d strongly recommend using markdown for any analysis reports or papers you write along the way. Markdown has many benefits by itself, and using it also sets you up nicely to use bookdown for your thesis. Why bookdown?


1 Answers

Yihui Xie already gave a good hint to the solution:

Put this code into your document (where you want the equation to appear):

$$
\require{mhchem}
\begin{equation}
  [C] + [R] 
  \xrightleftharpoons[k_{-1}]{k_1}
  [CR] + [C] 
  \xrightleftharpoons[k_{-2}]{k_2}
  [C2R]
(\#eq:multiplebinding)
\end{equation}
$$

Needs to use the arrow of mhchem instead of chemarr since only the first is part of MathJax. But I think it should anyway be basically the same.

This method should work for all Latex commands supported by MathJax (http://docs.mathjax.org/en/latest/input/tex/macros/index.html).

like image 158
Steffen Moritz Avatar answered Oct 16 '22 06:10

Steffen Moritz