# Is there a way to export XeLaTeX document into doc or similar?

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?

EDIT:

small example file

-
Pandoc should convert LaTeX to .docx — haven't tried it though. –  slhck Apr 23 '12 at 11:59
@slhck - it does not work with xelatex :( –  Rogach Apr 23 '12 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. –  Loop Space Apr 23 '12 at 12:46
@AndrewStacey - I added the example document. –  Rogach Apr 23 '12 at 13:26
Have a look at the answer to this related question –  Sveinung Apr 23 '12 at 17:52

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

\documentclass[a4paper, 12pt]{article}

% NOTES
% Organization?
% Citations in text?

\makeatletter
\newcommand\compparbox[2]{%
\parbox{\dimexpr #1\relax}{#2}
}
\usepackage[russian]{babel} % for russian hypenation
\usepackage[utf8]{inputenc}
}{

% TEMPORARY - remove in final version!
\setlength{\emergencystretch}{10em}

\usepackage{xltxtra}
\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

}
\usepackage{setspace}
\usepackage{enumitem}
\setlist{nolistsep} % denser list
\begin{document}
\singlespacing

\begin{center}

\large
Заголовок
\vspace{1em}

\normalsize

\end{center}

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

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

\vspace{2em}
\subsection*{Список литературы}
\begin{enumerate}
\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.
\end{enumerate}

\end{document}


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 '12 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 '12 at 13:45
Those parboxes compile just fine for me, maybe it is a version difference? –  Rogach Apr 23 '12 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 '12 at 14:05
\renewcommand{\parbox}[2]{ #2 } still achieves the same effect - first argument is still printed for some reason. –  Rogach Apr 23 '12 at 14:13