[Tex/LaTex] How to convert .tex file to .doc file with tex4ht

convertopen-officetex4ht

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 ?

Thank you in advance and sorry for bad english !

Best Answer

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:

enter image description here