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

1

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

Inherent answered 21/8, 2020 at 4:3 Comment(1)
I don't have enough time to help you here, but this might help: github.com/yihui/rmarkdown-cookbook/issues/217Fraction
H
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).

Helotry answered 29/8, 2020 at 12:25 Comment(2)
Thanks, Steffen. This is the perfect answer.Inherent
@SungpilHan I'm still waiting for you to offer your bounty so that I can start to offer mine :)Fraction

© 2022 - 2024 — McMap. All rights reserved.