rlatexmathjaxbookdowngitbook

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


Solution

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