TransWikia.com

How do I convert Open Office documents into LaTeX?

TeX - LaTeX Asked on June 11, 2021

Is there a good utility for this? Does it more than the standard stuff, or does it also do formulas and poems etc. in a good way?

7 Answers

You could use Writer2LaTeX:

Perhaps have a look at alternative ways: Converters from PC Textprocessors to LaTeX

Correct answer by Stefan Kottwitz on June 11, 2021

LibreOffice Writer, as one would expect, also includes Writer2LaTeX as an extension.

Writer2LaTeX is being actively developed (the current stable version is 1.0.2 (included with Ubuntu Natty, for example), the latest development alpha is 1.1.8. Changes include the development of Writer4LaTeX, aiming to integrate Writer with a LaTeX installation, providing a 'LaTeX' menu item on the LibreOffice Writer menu bar, effectively providing (by default) latex (usually symlinked to pdflatex) as a typesetting engine for Writer accessible directly on the Writer menu. The options for the extensions can be set from within Writer.

The range of export options for Writer2LaTeX (Writer extension) and w2l (command line Writer2LaTeX) is extensive and detailed in the software's manual. At the top level Writer2LaTeX allows the selection of export options that range from an ultra-lean document (not much more than content) to keeping the screen appearance (in a .pdf), and allows custom configuration of options. The documentation covers this so I'll not put more here beyond this quotation:

1.2 More about Writer2LaTeX and Writer2BibTeX

Writer2LaTeX is quite flexible: It can take advantage of several LaTeX packages, such as hyperref, pifont, ulem. It can create customized LaTeX code based on the styles and text in the document. Also it supports more than 25 different languages, latin, greek and cyrillic scripts and 8 input-encodings. The flexibility makes it possible to use Writer2LaTeX from several philosophies:

You can use LaTeX as a typesetting engine for your OOo documents: Writer2LaTeX can be configured to create a LaTeX document with as much formatting as possible preserved. Note that the resulting LaTeX source will be readable, but not very clean. Be aware that even though Writer2LaTeX tries hard to cope with any document, you will only get good results for well structured documents, ie. documents that are formatted using styles. For other documents you will find that Writer2LaTeX uses the principle garbage in – garbage out!

If you need to continue the work on your document in LaTeX your primary interest may be the content rather than the formatting. Writer2LaTeX can instructed to produce a LaTeX document which strips most of the formatting and hence produces a clean LaTeX source from any source document.

Traditionally, LaTeX documents are written by hand using a text editor. Using a graphical frontend like LyX provides a more user friendly alternative. A companion extension named Writer4LaTeX is in available and provides the tools to make you use OOo as a graphical frontend for LaTeX.

If it may be of interest, visit the Writer2LaTeX project site, browse the documentation and perhaps give the software a try with copies of your documents. (If you have Ubuntu Natty then the v1.0.2 software and manual can be installed using Synaptic and the manual should then be at /usr/share/doc/writer2latex/manual/user-manual.odt).

I have used v1.0.2 for exporting several documents to aid with transitioning workflows from word processor or DTP software to TeX and friends. In general I have wanted good content conversion and some limited structure conversion and have had less interest in preserving the look of the document. My documents have generally been simple but the conversion has been helpful and, where the document was well structured (e.g. styles used) then this has been mostly preserved -- at least enough to provide suggestions for LaTeX commands and packages. The only notable exception was multiple columns were lost but I did not try changing options to achieve that: for my use it was easier to take the content and apply appropriate LaTeX commands to provide a suitable structure. This also applies to formulae. As an example, if Einstein's famous equation is entered as text (using a superscript) and then with the Writer equation editor the resulting .tex file, (created via Writer4LaTeX and Writer2Latex (v1.1.8) within LibreOffice Writer) contains:

begin{document}
e = mctextsuperscript{2}

 $e=mc^{2}$
end{document}

There is useful discussion of file conversion to LaTeX in the question adding Word files to documents, including some helpful links to other tools and links to detailed consideration of their (de-)merits.

Answered by mas on June 11, 2021

AbiWord (http://www.abisource.com/) has the facility to import documents and export as Latex. It is open source. I've used it a few times but the one downside is that the equations are rendered as images.

Answered by bbujeya on June 11, 2021

There is a new project called odt2tex. It is very small and only depends on libzip and libexpat. So there is no need to have libre/openoffice installed to run the Writer2LaTeX extension. Also you don't need a Java Runtime what would even allow this tool to run on RasPi in a feasible manner.

Answered by Marc Rotter on June 11, 2021

w2l -inputencoding=iso-8859-7 -multilingual=true myfile.odt

This command produces a LaTeX file, even if the source is written in Greek. There will be no changes to the text.

Answered by Giannis Athanasiadis on June 11, 2021

Another solution is provided from the package pandoc:

If you need to convert files from one markup format into another, pandoc is your swiss-army knife.

As an example, you can do:

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

Answered by Theova on June 11, 2021

I found this solution to convert OpenDocument spreadsheets into LaTeX. It worked for me under LibreOffice 6.3.5:

  1. Download from there (Firefox should ask you to install, otherwise open the file from your Downloads folder)
  2. Open your spreadsheet, mark a cell range of interest
  3. Open "Tools -> Macros ... -> Run macro ..."
  4. Choose "Calc2LaTeX/Calc2LaTeX" from "My Macros" and select the "Main" macro
  5. Make adjustments in the following dialogue and click "Convert"
  6. Wait for the pop-up and copy the LaTeX source into your file (alternatively, the dialogue has the option to store the output directly in a file).

Note: The "Cancel" button does not work. Just press ESC to exit the dialogue.

The conversion is not particularly powerful, e.g. for large tables you have to manually convert into a longtable environment for instance. But it did a decent job for a complicated table I had only in CSV format and that needed many edits before being converted into TEX.

Answered by Mario on June 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP