Skip to content

Weave fails to convert markdown to pdf when env=:chemical and mathjax=true is involved #229

@goggle

Description

@goggle

I found this issue while rebuilding the tutorials from DiffEqTutorials.jl.

I have a markdown test_chemical.jmd with the following content:
test_chemical.jmd

The relevant line in is this:

x = latexify(repressilator; env=:chemical, mathjax=true);

Using Weave.jl to build a PDF from it (weave(..., doctype="md2pdf")) fails:

┌ Warning: Error converting document to pdf. Try running latex manually
└ @ Weave ~/.julia/packages/Weave/UOxmI/src/pandoc.jl:121
ERROR: IOError: unlink: no such file or directory (ENOENT)

Running pdflatex on the generated .tex file, shows this error:

! Undefined control sequence.
<argument>  \require 
                     {mhchem} \ce { \varnothing &->[\frac {\alpha \cdot K^{n...
l.150 \end{align*}

The relevant section in the .tex file is this:

\begin{align*}
\require{mhchem}
\ce{ \varnothing &->[\frac{\alpha \cdot K^{n}}{K^{n} + P_3^{n}}] m_{1}}\\
\ce{ \varnothing &->[\frac{\alpha \cdot K^{n}}{K^{n} + P_1^{n}}] m_{2}}\\
\ce{ \varnothing &->[\frac{\alpha \cdot K^{n}}{K^{n} + P_2^{n}}] m_{3}}
\end{align*}

The problem is, that Weave.jl adds the command \require{mhchem} to the .tex file because of mathjax=true.

Shouldn't Weave.jl emit the line \require{mhchem} when generating the .tex file?
Or is there another way to make this example work without breaking the transformation to HTML (i.e. keeping mathjax=true when building HTML and using mathjax=false when building PDF in a static .jmd file)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions