When trying to convert a simple LaTeX document to LibreOffice/OpenOffice, cross references and citations do not show in the final document. They do when converting to (X)HTML, but this has other drawbacks. How to set up conversion to LibreOffice properly?

I'm using Ubuntu 12.10 with packaged TeXlive 2012 and LibreOffice 3.6.

The code required to replicate this (shown below) can be downloaded or checked out using Git. To compile, use make texput.odt.



  \section{First} \label{sec:first}



  author = "Anyone",
  title = "Something",
  year = 2010,

Compilation command, according to instructions:

latexmk texput.tex
htlatex texput.tex "xhtml,ooffice,bib-" "ooffice/! -cmozhtf" "-coo -cvalidate"

Resulting output:

.tex -> .odt -> .pdf -> .png

Direct compilation:

.tex -> .pdf -> .png

Analysis of the generated content.xml file (inside texput.odt which in fact is a ZIP archive) shows mysterious <t4htlink> elements, I'm not sure they're part of the Open Document specification... Removing the opening and closing tags fixes the issue, at least for the reference to the section. The citation needs some more fixing. (The results don't change if I omit the bib- switch for the compilation.)

  • 1
    try command 'mk4ht oolatex texput' I think this script does some postprocessing of content.xml file and 't4htlink' elements are replaced with correct odt elements – michal.h21 Dec 12 '12 at 19:51
  • @michal.h21: This works beautifully, thank you. Could you please formulate this as an answer and also provide some detail, especially why this works, and if and how to plug in the other options. A link to more detailed documentation would be great, too. – krlmlr Dec 12 '12 at 23:47

Output generated by tex4ht configurations for openoffice needs some postprocessing, in particular this is needed for correct function of document hyperlinks. This postprocessing is done by some sort of xslt templates, called xtpipes. You can find these templates in directory


Postprocessing with these templates is configured in file

$texroot/texmf-dist/tex4ht/base/(unix | win, depending on your system)/tex4ht.env

in section <ooxtpipes>. To execute this section you need to pass option -cooxtpipes to t4ht programme. So correct command line is:

htlatex texput.tex "xhtml,ooffice,bib-" "ooffice/! -cmozhtf" " -cooxtpipes -coo -cvalidate"

To give you some more information:

Options "xhtml,ooffice,bib-" are passed to latex compilation, "ooffice/! -cmozhtf" to application tex4ht, which is responsible for encoding and image conversions etc, and " -cooxtpipes -coo -cvalidate" are passed to application t4ht, which do postprocessing.

To make life simpler, you can call

mk4ht oolatex filename

mk4ht is perl script with common configurations for calling commands, so you don't need to remember that horrible high number of parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.