6

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

Rogach
  • 3,088

1 Answers1

8

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}

% NOTES
% Organization?
% Citations in text?

\makeatletter
\newcommand\compparbox[2]{%
\parbox{\dimexpr #1\relax}{#2}
}
\@ifpackageloaded{tex4ht}{
 \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
 \usepackage[colorlinks=true,urlcolor=blue,linkcolor=blue]{hyperref}
\begin{document}
\singlespacing

  \begin{center}

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

    \normalsize
    Автор \href{mailto:someone@somewhe.re}{\nolinkurl{<someone@somewhe.re>}} (Россия, Москва)

  \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

michal.h21
  • 50,697
  • 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
  • Strange thing is that if I define that macro in the normal xelatex run, everything works as expected. – Rogach Apr 23 '12 at 14:22
  • Ok, that much of clean-up I can certainly survive :) Thank you! – Rogach Apr 23 '12 at 14:44