8

I write in latex, but I often need to collaborate with others who insist on using MS Word. so, I create my part of the document first in latex, then I convert it to MS-Word and kiss it goodbye. it's a roach motel kind of conversion---it checks in, but it won't check out. and please don't ask me to convert my collaborators. I can't. I wish. but I can't.

now, in the past, I have looked at https://www.tug.org/utilities/texconv/textopc.html but found no good solutions there. I also looked at solutions in Workflow for converting LaTeX into Open Office / MS Word Format and they were a good start.

from what I have seen, the best completely painless effortless way on me, as a user, seems to be to use OCR on the pdf file. It gets a good part of the required MS-Word formatting right. (I find the ones with interim conversion to odt to be not only painful but also having poor results.)

Alas, there is one oddity. I think that typical OCR software tends to ignore the information that pdftotext (from glyph&cog's poppler ubuntu package) can obtain. This is because there are occasional characters that are misrecognized in words.

is there an OCR program that can use the text-based information in pdf files in its scan process, too? has anyone done systematic experimentation on the quality of automated latex -> pdf -> msword (OCR) translations?

7
  • This doesn't answer your question, but you might be interested in taking a look at the Rich Text mode of writeLaTeX and their JotGit. I've never used either of them, but they both look interesting.
    – Adam Liter
    Jun 16, 2014 at 4:04
  • 6
    If it's clear for a specific document, that it will need to be converted to Word, I'd have a look at markdown (see pandoc and others) This is will allow you to convert to LaTeX and Word easily. Jun 16, 2014 at 4:40
  • 4
    And why don't you use tex4ht?
    – Keks Dose
    Jun 16, 2014 at 6:10
  • 3
    Finereader will convert your pdf to image and then process it with ocr, so all possible structural information in the pdf file are lost. also new typing errors may occur. I often convert scanned books to text with Finereader and it takes lot of time to correct all typos and formatting errors in this process, I would definitely use tex4ht to convert LaTeX to word
    – michal.h21
    Jun 16, 2014 at 6:37
  • 2
    tex4ht -> ODF -> open in LibreOffice, tidy up -> DOC/DOCX. That has worked best for me, at least.
    – cfr
    May 13, 2016 at 16:19

2 Answers 2

4

Your best option is probably pandoc, that can convert from and to Microsoft Word (docx) and LaTeX (among others).

A sample document such as

% This is a simple sample document.  For more complicated documents take a look in the excersice tab. Note that everything that comes after a % symbol is treated as comment and ignored when the code is compiled.

\documentclass{article} % \documentclass{} is the first command in any LaTeX code.  It is used to define what kind of document you are creating such as an article or a book, and begins the document preamble

\usepackage{amsmath} % \usepackage is a command that allows you to add functionality to your LaTeX code

\title{Simple Sample} % Sets article title
\author{My Name} % Sets authors name
\date{\today} % Sets date for date compiled

% The preamble ends with the command \begin{document}
\begin{document} % All begin commands must be paired with an end command somewhere
    \maketitle % creates title using infromation in preamble (title, author, date)
    
    \section{Hello World!} % creates a section
    
    \textbf{Hello World!} Today I am learning \LaTeX. %notice how the command will end at the first non-alphabet charecter such as the . after \LaTeX
     \LaTeX{} is a great program for writing math. I can write in line math such as $a^2+b^2=c^2$ %$ tells LaTexX to compile as math
     . I can also give equations their own space: 
    \begin{equation} % Creates an equation environment and is compiled as math
    \gamma^2+\theta^2=\omega^2
    \end{equation}
    If I do not leave any blank lines \LaTeX{} will continue  this text without making it into a new paragraph.  Notice how there was no indentation in the text after equation (1).  
    Also notice how even though I hit enter after that sentence and here $\downarrow$
     \LaTeX{} formats the sentence without any break.  Also   look  how      it   doesn't     matter          how    many  spaces     I put     between       my    words.
    
    For a new paragraph I can leave a blank space in my code. 

\end{document} % This is the end of the document

gives, comiled with latex:

enter image description here

Now, if you run

pandoc document.tex -o document.docx

you obtain a .docx document that looks like this:

enter image description here

Not everything will be perfectly preserved, but you will get better results than using OCR, in my opinion and experience.

You can find some more examples at https://pandoc.org/demos.html.

1
  • 1
    +1. -also a great example of MS words ugly output. Nov 5, 2021 at 9:58
2

The best to convert a latex file into a msWord file is latex --> pdf --> msWord. You need to take care that you are using msWord 2013 or a higher version. This doesn't alter my graphics. But I lose hyperlinks and it messes with a couple of equations.

To avoid re-writing the messed-up equations, msWord 365 works great. You can use the Equation Editor of msWord 365 in LaTeX mode.

I also have a collaborator who would work only in msWord. After several hits and trials, I found that this is your best way to go.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .