# How to convert .tex file to .doc file with tex4ht

I would like to convert a tex file 'test.tex' into something that can be read by OpenOffice (.rtf, .doc, .docx..). (I would like to write my PhD Thesis with Latex/Knitr by my suppervisors don't want to read Latex or PDF. They just want OoO or Word...)

There is something a didn't understand with 'tex4ht'..

This is my code into my 'test.tex':

\documentclass{article}
%\usepackage["xhtml,ooffice" "-cmozhtf" "-coo"]{tex4ht}
%\usepackage[htlatex test.tex "xhtml,ooffice" "ooffice/! -cmozhtf" "-coo -cvalidate"]{tex4ht}

\usepackage["xhtml,ooffice" "ooffice/! -cmozhtf" "-coo -cvalidate"]{tex4ht}
%\usepackage[ "html,word" "symbol/!" "-cvalidate"]{tex4ht}

\oolatex
%\input tex4ht.sty
%\Preamble{"xhtml,ooffice" "ooffice/! -cmozhtf" "-coo -cvalidate"}

\begin{document}

Minimal example \LaTeX\

%\EndPreamble

\end{document}

There is my code into my 'xhtml.cfg':

\begin{document}
\Preamble{"xhtml,ooffice" "ooffice/! -cmozhtf" "-coo -cvalidate"}
\EndPreamble

And there are some error messages:

Line 1 LaTex Error: Missing \begin{document}.
Line 7 Undefined control sequence.
Line 2 File ended while scanning definition of \loadr:e
Line 2 Missing { inserted.
Line 3 Undefined control sequence.
Line 3 Undefined control sequence.
Line 3 Undefined control sequence.
Line 3 Undefined control sequence.
Line 3 Undefined control sequence.
Line 3 Undefined control sequence.

But It's impossible to put the '\begin{document}' in line 1 (before the preamble), and I didn't see any '{' inserted in line 2..

Into my working directory I have these files: test.tex; tex4ht.sty; textht.4ht; test.tmp; test.xref; xhtml.cfg; test.pdf; test.log; test.synctex.gz; test.synctex.gz

Someone have an idea or use it without problem ?

• Irrelevant but "suppervisors don't want to read Latex or PDF" as far as I know they have no right to force you. I can understand that they are not familiar with Latex but what the heck with they don't want to read PDF? – CroCo Jan 18 '17 at 20:53
• I also don't want to read \LaTeX, but I want to read a PDF or (PostScript) file generated with (La)TeX and friends – user31729 Jan 18 '17 at 20:55
• If I'm in your shoe, I will tell them that the beauty of Latex basically can't be converted in Word and this is actually a waste of your invaluable time. – CroCo Jan 18 '17 at 21:04
• Yeah I know, I 've tried many times, but they want to put comment on the report. I've talked about GitHub (you can put comment here), or write on the PDF with different software, but the answer stay just "no". I have already convert friends into Latex, but I've failed with my supervisors.. That why I'm tried to continued to used Latex and send them something they like. – Pierre-louis Stenger Jan 18 '17 at 21:16
• @Pierre-louisStenger, "but they want to put comment on the report" they can do that with the free version of Adobe Reader via this feature add sticky note (i.e. Ctrl+6). At the worst scenario, let them print it out and write down their comments. This makes no sense whatsoever. I hope someone will answer your question though. – CroCo Jan 18 '17 at 21:29

tex4ht is installed with all major TeX distributions, so you don't need custom copies of tex4ht.sty and other packages. Just try to run the command

mk4ht oolatex test.tex

You also don't need to include any custom code in your TeX document, all tex4ht configurations are included by the calling script automatically.

Your TeX file should look like:

\documentclass{article}

\begin{document}

Minimal example \LaTeX\

\end{document}

This is the result in LibreOffice:

• Thanks for answer. At the risk of asking a stupid question, where do you run 'mk4ht oolatex test.tex' command ? On the terminal cmd ? Or somewhere on the Tex distribution software ? Thanks for any help – Pierre-louis Stenger Jan 18 '17 at 23:58
• @Pierre-louisStenger yes, on the command line. You must go to the directory with your document. If you normally compile your documents from your editor, it may be possible to add custom compiler in the editor, so that might be another option. – michal.h21 Jan 19 '17 at 9:23