Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a typical scientific manuscript in a LaTeX .tex file, and I need to convert it to MS Word .doc file. The reason for having to convert to MS Word is I'm submitting the manuscript to an academic journal and they only accept MS Word (I know...)

The manuscript includes title page, figures, tables, equations (inline and in their own align environment), footnotes, bibliography, and an annex. The tables are in their own separate tables.tex file, which I include using the \include{tables} command. Most tables take up a whole landscape page, and were generated sing the package pdflscape. I am using Windows 7 Professional.

My plan is to use pandoc to go form .tex to .odt, open the latter in Libre Office, and convert to .doc. I have read a related question but it is too general. Similarly the examples in the Pandoc website are too simple. I have played around but I am unable to accomplish what I want. This is surprising since converting a scientific manuscript is probably the most common use case for Pandoc. Here are some sample failures:

Example 1

I open a command line in the project folder, and execute the following:

pandoc -s document.tex -o document.odt

I get this error message:

pandoc: figure1: openFile: does not exist <no such file or directory>

where figure1 is the name of a figure file (e.g. figure1.png) in the project folder referenced in a line as \includegraphics[width=5.8in]{figure1}. I suspect pandoc expects a .png extension but not sure how to provide it.

Example 2

Next I try .html, and excute the following:

pandoc -s document.tex -o document.html

The program executes fine. I open HTML file. Footnotes are there but figures are missing, tables are displayed as LaTeX, bibliography is missing, in-line math displays well, but math in align environment does not, section labels are displayed, and some other minor issues.

So given that mine is probably a typical use case scenario, my question is this: What commands should I use to get the .odt file I want? I could not find a fully worked out example on the web.


Here is a specific list of errors. I'll update how I corrected them based on community suggestions:

  1. Figures not rendering. Solved by adding .png extension to .tex file in \includegraphics command. Now figures are included but they are huge, with half of each figure outside the page.
  2. No bibliography. Solved. First, I have one huge consolidated Latex .bib file where I keep all my citations. I manage it using JabRef. This was giving me problems as I do not keep the cleanest .bib file in town. So I reduced the problem by using a neat trick in JabRef that allows you to subset your master .bib file using the .aux file generated by Latex when compiling your manuscript. In JabRef click on Tools > New Subdatabase based on AUX file. This way I generated a much smaller biblio.bib file with only the articles referenced in my manuscript. Running pandoc -s document.tex -o document.odt --bibliography=biblio.bib did the trick.
  3. Display math. Math in \begin{align} environment displayed in verbatim \latex; (A partial solution is to use the TexMaths Libre Office extension. Copy and paste the latex math code in the .odt file created by Pandoc into the equation editor, and so on. Surely this could be built into a macro that can post-process all remaining math.) UPDATE: Display math works very well using --mathjax extension.
  4. Inline math. Inline equation do not always render properly. Bold math is a problem. E.g. $\Sigma=\sigma^2\bm{I}$ displays as $\Sigma=\sigma^2\bm{I}$;
  5. Labels are displayed (e.g. section labels show as [sec:empirical] blah blah];
  6. All tables display as raw latex.
share|improve this question
1  
Try with \includegraphics[width=5.8in]{figure1.png}. This is only a workaround, since pandoc should support the extensionless format (which is the recommended one) as well. –  Federico Poloni May 2 '13 at 8:44
2  
The needs of convertion to Word have often been discussed in this forum. We found surprisingly many solutions to avoid conversion. So if you tell us the cause for your wish to convert your manuscript, we could look out for an alternative. That said, I suggest to use tex4ht to convert your manuscript to *.doc or whatever. –  Keks Dose May 2 '13 at 9:16
    
Try invoking Pandoc with the --default-image-extension=.png option (implemented in pandoc 1.11). You are probably best trying to generate .docx output. –  Charles Stewart May 2 '13 at 12:29
1  
Fred: pandoc --version gives the version. I think you have overambitious expectations of pandoc: it cannot understand the whole Tex language, it can only do shallow parsing of typical Latex idioms. If you want the full language, then you need to run a Tex engine, and Keks' suggestion of tex4ht is the right sort of approach. –  Charles Stewart May 2 '13 at 16:27
1  
@CharlesStewart Yes I looked at tex4ht but it is not very intuitive and does not appear to be well supported. For example I install the packages using MiKTex 2.9 package manager. I open CMD line in project folder. I enter hlatex document and get error that it is not recognized. Part of the problem is there is no definitive guide. Online I've seen claims it works out of the box in MiKTek, others point to long set up instructions. Hard to figure out. Any pointers? –  Fred May 2 '13 at 16:44
show 7 more comments

migrated from stackoverflow.com May 2 '13 at 8:23

This question came from our site for professional and enthusiast programmers.

5 Answers

I gave up on pandoc for almost exactly the same reasons you listed.

If you are set on using pandoc, the simplest solution may be to just identify environments and packages that cause trouble - and then not use them, or just type the offending stuff directly in to MS Word.

I've had a fair amount of luck with going to word documents using latex2rtf to create an .rtf that then gets converted, rather than going through pandoc. As I wrote in Hide output, but maintain the cross-references, my solution has been to put a very tight cap on the packages that are used when creating a tex document that you know will be converted. This is because a lot of problems with conversion from .tex to .rtf are caused by optional packages and environments that are not supported.

See https://github.com/AndyClifton/AccessibleMetaClass for a demo of a class that gives you a file that can be converted with latex2rtf to .rtf and thus to .docx. Bonus: this class almost(!) gives you a tagged PDF that passes automated testing for tags (the fabled 508 compliance).

share|improve this answer
add comment

I'm not sure you want to read this.

If you are forced to use MS Word for your work then better use Word to write it.

LaTeX typesetting is much more better than Word can do. So every conversion from LaTeX to Word will disappoint you about the quality of the conversion---if possible.

Why do you want to do the same "work" two times: first writing your script in LaTeX, later rework completly the word file?

share|improve this answer
3  
professor prefers MS word, but I love Latex structure. –  selwyndd21 Oct 12 '13 at 1:35
    
Sometimes you have to share an editable work to other colleagues that don't use LaTeX... –  G M Dec 19 '13 at 11:26
    
@Kurt: I have the exactly same problem as Fred. I always write my papers in LaTeX because it handles the organziation of the structure and all figure and literature references,.. so exceptionally well! Also, the reviewer in the end does not to have be bothered with all those arising problems when you submit a paper that is written in Word or other text editors, e.g. cross-checking references. Hands down: LaTeX wins, always. –  Paglia Orba Apr 15 at 15:55
add comment

I haven't tried pandoc. There doesn't seem to be a definitive solution. I usually try one of these and see which works. Here is how to convert to Word using tex4ht.

mk4ht oolatex document.tex

This should produce document.odt. You can convert this to Word using OpenOffice.org/LibreOffice. A short tutorial is here. Unfortunately, this may fail for long documents. Another option is to first compile with latex (not pdflatex) and then

latex2rtf document.tex and open document.tex directly in Word.

For long documents, I have had good results by converting the output pdf to Word. There are quite a few pdf to Word converters.[Adobe Acrobat, online converters, of other freeware.] that work pretty well.

share|improve this answer
add comment

I write my APA6th papers with LaTeX and export them with all beauty to PDF. Normally this is all I need. Sometimes publisher ask for word files (the reason why I don't know...). So I was on the search to a decent pdf to word converter since simpletex4th has table issues and I need tables a lot. The only converter I am satisfied with is PDF to Word + by Lighten Software Limited for Mac. The docx generated has NO differences from the PDF output and is perfectly editable. This works much better than these tex to xxx converters. http://www.lightenpdf.com/pdf-to-word-converter-mac.html http://www.lightenpdf.com/pdf-to-word-converter.html

share|improve this answer
add comment

Going via html using the --webtex option may solve your inline maths issue. Won't do anything about cross-referencing (the general case of your issue 5)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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