I need to export my .tex file to .doc. I tried to do it using

mk4ht ooxelatex file.tex

but got complete garbage as output. The file itself is quite simple - some text and a pair of images.

Is there a way to do it?


small example file

  • Pandoc should convert LaTeX to .docx — haven't tried it though.
    – slhck
    Apr 23, 2012 at 11:59
  • @slhck - it does not work with xelatex :(
    – Rogach
    Apr 23, 2012 at 12:07
  • It will be very difficult to help you without knowing the document. TeX4ht has the capability to convert to OpenOffice format. It isn't guaranteed to work, but the reasons why it doesn't work can be complicated so without a sample document it's hard to help you further. Apr 23, 2012 at 12:46
  • @AndrewStacey - I added the example document.
    – Rogach
    Apr 23, 2012 at 13:26
  • 1
    Have a look at the answer to this related question
    – Sveinung
    Apr 23, 2012 at 17:52

1 Answer 1


The reason why compilation of your document fails is probably that tex4ht has some problems with xetex and fontspec, it is best to use pdftex or luatex as engines for use with tex4ht.

Best option for xelatex documents is to have some switch in the preamble, so you don't load problematic packages when you compile the document with tex4ht

Your sample document corrected:

\documentclass[a4paper, 12pt]{article}

% Organization?
% Citations in text?

\parbox{\dimexpr #1\relax}{#2}
 \usepackage[russian]{babel} % for russian hypenation

  % TEMPORARY - remove in final version!

  \setmainfont[Mapping=tex-text]{Linux Libertine O}

  \usepackage[russian]{babel} % for russian hypenation
  \usepackage[top=20mm, bottom=20mm, left=25mm, right=25mm]{geometry}

  \pagestyle{empty} % remove page numbering

  \setlist{nolistsep} % denser list



    Автор \href{mailto:[email protected]}{\nolinkurl{<[email protected]>}} (Россия, Москва)


Много текста
Много текста
Много текста
Много текста
Много текста
Много текста
Много текста
Много текста
Много текста
Много текста
Много текста
Много текста
Много текста
Много текста
Много текста

  \compparbox{\textwidth/2 - 0.8em}{
    %\includegraphics[width=\textwidth/2 - 0.8em]{comp1-mne.png}
    Рис.1. Картирование ``сенсорного''\\ компонента.
  \compparbox{\textwidth/2 - 0.8em}{
  %  \includegraphics[width=\textwidth/2 - 0.8em]{comp4-mne.png}
    Рис.2. Картирование ``моторного'' \\ компонента.

  \subsection*{Список литературы}
    \item \phantomsection \label{ikeda1992}
          Ikeda A., L\"{u}ders H., Burgess R., Shibasaki H. 1992. Movement-related potentials recorded 
          from supplementary motor area and primary motor area. Brain. V. 115. pp 1017-1043.


with \@ifpackageloaded{tex4ht} you can decide which package to load or not to load, when tex4ht is running. As first parameter include packages for use with tex4ht, as second packages for xelatex.

Compile with

mk4ht oolatex sample.tex "xhtml, charset=utf-8"

Note: Your parboxes are incorrectly transformed with tex4ht, I think you will need some custom configuration to get it working. But this needs some knowledge of odt xml structure

  • I added the sample document to the question.
    – Rogach
    Apr 23, 2012 at 13:27
  • I almost got it to work, using your advice - the only problem left is the \parbox. What package should I import so the converter would recognize it?
    – Rogach
    Apr 23, 2012 at 13:45
  • Those parboxes compile just fine for me, maybe it is a version difference?
    – Rogach
    Apr 23, 2012 at 13:52
  • I would be just fine with the way they are outputted right now (just two big images one after another), but with the garbage (/2 - 0.8em/2 - 0.8em/2 - 0.8e) removed. Maybe I can define something like you defined in "compparbox", which would just silence it?
    – Rogach
    Apr 23, 2012 at 14:05
  • \renewcommand{\parbox}[2]{ #2 } still achieves the same effect - first argument is still printed for some reason.
    – Rogach
    Apr 23, 2012 at 14:13

You must log in to answer this question.

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