7

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)?

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
Sungpil Han
  • 638
  • 6
  • 11
  • 2
    I don't have enough time to help you here, but this might help: https://github.com/yihui/rmarkdown-cookbook/issues/217 – Yihui Xie Aug 21 '20 at 15:19

1 Answers1

8

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).

Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55