1

I am willing to convert my latex file to MS word (docx extension) to share it with some of my co-authors that do not use latex (they should!!).

I have two issues:

1) In the tex file I include some figures. However, when I convert the file, I got the following error message: "pandoc could no find image 'Figure1", skipping.

The files with the two figures are in the same folder I am working. Is there any way I can ask pandoc to include those figures in the docx file?

2) A part from point 1), everything works fine. However, pandoc cannot convert two equations (I got the latex code instead of the two equations). The MWE generating those equations is:

\documentclass[12pt, A4paper]{article}

\usepackage{amssymb}
\usepackage{amsmath}


\begin{document}

Consistently, the probabilities in Eq. (1) and Eq. (2) are defined as follows, respectively:
\[
(\alpha)P\left[\frac{1}{2}+\mu \right] =
\setlength{\arraycolsep}{0pt}
\renewcommand{\arraystretch}{2}
\left\{ 
\begin{array}{l @{\quad} l r l}
    0            & \text{if } & \mu &{} < -\dfrac{1}{2}\\
    \alpha\mu & \text{if } & -\dfrac{1}{2} &{} \leq \mu \leq \dfrac{1}{2}\\
    1            & \text{if } & \mu &{}> \dfrac{1}{2} 
\end{array}
\right.
\]
and:
\[
P\left[\frac{1}{2}+\gamma \mu -(\alpha -1)\right]=
\setlength{\arraycolsep}{0pt}
\renewcommand{\arraystretch}{2}
\left\{ 
\begin{array}{l @{\quad} l r l}
    0            & \text{if} & \gamma\mu &{} < \alpha -\dfrac{3}{2}\\
    \dfrac{1}{2}+\gamma \mu -(\alpha -1) & \text{if} &{} \alpha -\frac{3}{2} &{}\leq \gamma \mu \leq \alpha -\frac{1}{2}\\
    1            & \text{if } & \gamma \mu &{}> \alpha -\frac{1}{2} 
\end{array}
\right.
\]
\vspace{0.5cm}

\end{document}

Why this is the case? Is there any chance I can write the two equations above such as I get the identical result but they are written in a way pandoc can convert? Thanks in advance.

  • Pandoc is great for Markdown conversion, it's LaTeX support is rather limited. You can try to convert your file to odt using tex4ht (command mk4ht oolatex filename) and then convert it to docx using LibreOffice. I was able to convert your sample, with some issues. – michal.h21 Nov 21 '16 at 22:21
  • @michal.h21Thanks for your reply, Which are the issues you got with the conversion, following your procedure? – Dario Nov 21 '16 at 22:43
  • there is one bug in tex4ht, which cause compilation error (but the document compiles correctly), it can be fixed with one declaration in the document. other issue seems to be bug in my version of LibreOffice, it don't display relation operators at beginning of the table cell (for example & {} < isn't displayed). This can be also fixed with a change in the code, but it isn't really elegant. I have LO 5.0 installed, so it is possible that it is fixed in more recent LO versions – michal.h21 Nov 21 '16 at 22:59
4

Remove the \setlength{\arraycolsep}{0pt} and it should work -- that seems to be causing the problem.

And please consider reporting problems like this on the pandoc bug tracker, so we can improve pandoc. It would be a relatively simple matter to change the texmath library (which pandoc uses for math conversions) to ignore (or better, do something with) the \setlength command.

As for the figure, pandoc should be able to find the image; again, we'd be interested in a detailed bug report with enough information to reproduce the problem. (Also, be sure you're using the most recent version of pandoc, or at least tell us which version you're using.)

  • Thank you very much for your reply John. I tried removing \setlength{\arraycolsep}{0pt}. It did not work. I also tried to remove \renewcommand{\arraystretch}{2}. It works with some flaws: In the first line after the curly bracket the following appears: l@ lrl0. This is a minor problem, as I can remove l@ lrl but the problem still remains. I am using pandoc 1.18 for Windows. Could you please tell me how I can obtain a full bug report? From cmd I cannot obtain it. – Dario Nov 22 '16 at 9:41
  • Regarding the images, they are saved as png file. Does pandoc require a different extension? – Dario Nov 22 '16 at 9:52
  • I rarely look over here, so please come to the pandoc-discuss mailing list on google groups, or submit a bug report at github.com/jgm/pandoc/issues. – John MacFarlane Nov 22 '16 at 20:44
  • As for the image: a png should work fine. However, you do need to put the .png extension in the LaTeX \includegraphics{...} command; pandoc doesn't currently find images without extensions in quite the way LaTeX does. – John MacFarlane Nov 22 '16 at 20:46
0

Apologies for my late reply: I have tried all settings exporting .tex to .docx - with pandoc and however had to resolve to with www.ilovepdf.com which rendered even formats quite nicely.

  • 1
    Thanks do you mean that you generated the PDF from latex and then converted it in word using ilovepdf? – Dario Feb 27 at 14:02
  • Yes. That was by far the easiest! – chrischi Feb 28 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.