# How to convert .tex into .odt?

I wish to convert a .tex file into an .odt file.
Can you suggest a good step-by-step solution?

-
@Naruto: I assume it's a LaTeX document. –  Nathan Osman Nov 25 '11 at 20:33
Note that for all answers below: your success rate will depend on the latex packages used, and math will never be typeset as nicely as in latex. –  David Nov 26 '11 at 3:03

Believe it or not, with complex documents and lots of packages included, I got much better results with LaTeX2HTML than with LaTeX2RTF, Pandoc or TeX4ht.

``````latex2html texfile.tex -split 0 -no_navigation -info "" -address "" -html_version 4.0,unicode
``````

This will generate a folder with the same `texfile` name, so you'll be able to convert the generated HTML to ODT:

``````libreoffice --headless --convert-to odt:"OpenDocument Text Flat XML" texfile/index.html
``````

This will produce a `index.odt` file. Take a look at this answer to check how to use LibreOffice's convert filters.

-
For complex documents with lots of additional packages, files and commands LaTeX2HTML fails. I'm trying to convert my thesis to HTML and than to ODT in order to give it to someone for comments and correction, who is not familiar with LaTeX. Even without custom commands this tool fails. Tikz package for some reason is one of the main culprits. –  rbaleksandar Jul 18 at 8:10
There's no ideal solution @rbaleksandar, specially depending of the packages you're using. I would suggest Pandoc for you. It won't keep all formats, but it is capable of ignoring some structures and build a final document, at least. –  vmassuchetto Jul 18 at 11:28

There is a tool in the repositories that changes LaTeX to openoffice.org's XML format: tex4ht

TeX4ht is a highly configurable TeX-based authoring system for producing hypertext. It interacts with TeX-based applications through style files and postprocessors, leaving the processing of the source files to the native TeX compiler. Consequently, TeX4ht can handle the features of TeX-based systems in general, and of LaTeX in particular.

TeX4ht can be used both for authoring HTML using TeX/LaTeX input files, or for converting existing TeX input files (in any format) into HTML, with (usually) only minor modifications. Other varieties of hypertext can also be produced, including XML, XHTML, MathML and the Openoffice.org format of XML.

Command line...

1. latex filename.tex
2. bibtex filename.aux
3. mk4ht oolatex filename.tex

Should end up with an openoffice.org/libreoffice compatible file.

-
Thank you. BTW, it appears the main maintainer of the package has sadly died two years ago. –  Tal Galili Nov 25 '11 at 19:27
damn that's a pity :( –  Rinzwind Nov 25 '11 at 19:47
I agree - I wish a more active community would have taken upon itself to continue this work... –  Tal Galili Nov 27 '11 at 2:57
+1 for command line example. I did not have time to read the documentation, but the example above is quite easy to follow. –  antmw1361 Jun 5 '13 at 13:39

Another solution is provided from the package pandoc

As an example, you can do:

``````pandoc -f latex -t odt -o output.odt input.tex
``````

If the input file is `latin1` encoded, like my tex files, the solution is:

``````iconv -f ISO-8859-1 input.tex | pandoc -f latex -t odt -o output.odt
``````

I report part of the description of the package:

Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses this library. It can read

• markdown and
• subsets of
• reStructuredText,
• HTML, and
• LaTeX

and it can write

• plain text,
• markdown,
• reStructuredText,
• HTML, -LaTeX, -ConTeXt,
• RTF,
• DocBook XML,
• OpenDocument XML,
• ODT,
• GNU Texinfo,
• MediaWiki markup,
• EPUB,
• Textile,
• groff man pages,
• Emacs Org-mode, and
• Slidy or
• S5 HTML slide shows.
-

It can be done in 2-steps. Go to http://latex2rtf.sourceforge.net/ and use the tools provided to convert first from Latex to RTF and then from RTF to ODT.

Hope it helps.

-

If you've the tex4ht package installed, the command `oolatex filename` converts the .tex into .odt (for more on tex4ht, see here).

Another way would be the latex2rtf package, using RTF als intermediate format.

-
oh - sorry, haven't seen the other replies... –  tohuwawohu Nov 25 '11 at 16:57
Not a problem since you added a link to latex2rtf and that was not in any of the other 2 answers ;) –  Rinzwind Nov 25 '11 at 16:59

Sorry might be late for this one and I am new to askubuntu.

Abiword seems to open latex documents. I use gnumeric to generate my tables in latex.

Hope it helps.

-