0

I'm working with a Windows machine. I use Rstudio/knitr to write and convert a (R)markdown file to an html file. The source markdown file contains some mathematics typed in the LaTeX language hence the html file contains some Mathjax.

For instance there is the following LaTeX code in the markdown file is:

$H_0:= \{|\mu_x-\mu_y|>S\}$

hence the expected output is:

enter image description here

This output correctly appears in the html file.

But now I try to convert this html file to a tex file:

pandoc -s myfile.html -o myfile.tex

And then I get the following code in the output tex file:

\textbackslash{}( H\_0:=
  \textbackslash{}\{\textbar{}\textbackslash{}mu\_x-\textbackslash{}mu\_y\textbar{}\textgreater{}S\textbackslash{}\}
  \textbackslash{}) où \textbackslash{}( S \textbackslash{})

which gives the following rendering after compiling with (pdf)latex:

output

Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
  • 1
    What happens when you try to convert from your Markdown source directly using `pandoc -s myfile.rmd -f markdown -o myfile.tex`? Pandoc doesn't recognise embedded $...$ formulae in HTML, only in its markdown, so the failure you describe is expected. It won't evaluate inline R expressions - are there any other deviations? – Charles Stewart Dec 28 '12 at 00:57
  • @CharlesStewart I think that is the answer. The tex file should be created from markdown directly instead of html. – Yihui Xie Dec 28 '12 at 03:18
  • 1
    @CharlesStewart & Yihui, thanks. In fact I realized my question is a duplicate after posting it : http://stackoverflow.com/questions/11338049/how-to-convert-html-with-mathjax-into-latex-using-pandoc – Stéphane Laurent Dec 28 '12 at 08:25
  • @CharlesStewart & Yihui: I have problems with the encoding when converting md to tex, because as a French I use accented letters. But this is another question. – Stéphane Laurent Dec 28 '12 at 08:26
  • @CharlesStewart & Yihui: I wanted to try the html to tex conversion to see what happens for the figures. When converting the md file, figures are in separate files. When converting the html file, figures are coded in a long character string. But it is too long: impossible to compile the tex file. – Stéphane Laurent Dec 28 '12 at 08:28
  • @StéphaneLaurent: Use Xetex or Luatex as your Tex engine, not Pdftex, since those use Unicode as their encoding natively. There are ways to compile HTML to a Tex-based representation - the tools seem to be better for Context than Latex. – Charles Stewart Dec 28 '12 at 09:27
  • @CharlesStewart Thanks. In fact I am also interested in printing the html file in pdf. That does not work well with Pdfcreator. – Stéphane Laurent Dec 28 '12 at 11:19

0 Answers0