Pandoc: [WARNING] Could not convert TeX math
Asked Answered
S

2

7

I tried to convert html to docx by using Pandoc:
here is my html code:

<p> Example: ${v_1} = {\rm{ }}{v_2}$</p>

with MathJax config in head:


    MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
        inlineMath: [['$', '$'], ["\(", "\)"]],
        displayMath: [['$$', '$$'], ["\[", "\]"]],
    },
    "HTML-CSS": {availableFonts: ["TeX"]}
});

Pandoc command that i used (Pandoc version 2.2.3.2):


    pandoc -s  test.html --mathjax  -f html+tex_math_dollars   --pdf-engine=xelatex  -o  xxx.docx

then i got a warning:


    [WARNING] Could not convert TeX math '{v_1} = {\rm{ }}{v_2}', rendering as TeX:
      {v_1} = {\rm{ }}{v_2}
                  ^
      unexpected "{"
      expecting "%", "\\label", "\\nonumber" or whitespace

Someone please tell me how to fix this. Thanks!

Snowstorm answered 13/9, 2018 at 11:48 Comment(0)
S
6

Use the LaTeX \textrm instead of the plain tex \rm, and pandoc will be able to handle it.

Stravinsky answered 13/9, 2018 at 15:38 Comment(0)
I
0

Since 7k users have viewed this question since it was asked... perhaps others have made the same mistake I made as a novice RStudio user.

The first comment in both the README.md and the README.Rmd file is

<!-- README.md is generated from README.Rmd. Please edit that file -->

The intended meaning is (at least arguably) apparent if you pay sufficient attention to the this/that relative pronouns!

<!-- You should edit the README.Rmd file, not the README.md file -->

To repair the damage... I'm currently trying the suggestion to use an explicit devtools::build_readme() which I found in RStudio README.Rmd and README.md should be both staged use 'git commit --no-verify' to override this check

No luck yet ... but I feel like I'm (finally!) making forward progress on getting $\sqrt{x}$ to display properly in my github README!

Irresistible answered 28/12, 2022 at 3:8 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.