Writer 2 Latex User Manual Screen
Writer 2 Latex User Manual Screen
Writer 2 Latex User Manual Screen
version 0.5
© 2002–2007 Henrik Just
Table of Contents
1 Introduction 3
2 Installation 5
6 Troubleshooting 52
1 . Introduction
1.1 . What is Writer2LaTeX?
Writer2LaTeX is a utility to convert OpenDocument text and spreadsheet documents – in partic-
ular documents containing formulas – into other formats.
Actually it is 4 converters in one:
• Writer2LaTeX converts OpenDocument text documents to LaTeX 2e, and works together
with:
• Writer2BibTeX extracts bibliographic data from an OpenDocument text document and con-
verts it to BibTeX format.
• Writer2xhtml converts OpenDocument text documents to XHTML 1.0 strict or XHTML 1.1 +
MathML 2.0, using CSS2 to convert style information.
• Calc2xhtml converts OpenDocument spreadsheet documents to XHTML 1.0 strict, using
CSS2 to convert style information.
The old file formats for OpenOffice.org 1.x (or StarOffice 6/7) Writer and Calc documents are
also supported.
Although Writer2LaTeX is a general OpenDocument converter, it is primarily designed for use
with OpenOffice.org/StarOffice You can use Writer2LaTeX
• ...as a command line utility, independent of OpenOffice.org/StarOffice.
• ...as an export filter for OpenOffice.org 2.x, StarOffice 8 or NeoOffice 2.01 .
• ...from another Java program.
This user's manual will explain how to install and use Writer2LaTeX.
Writer2LaTeX is a Java application, and thus should work on any platform that supports
Java. You need Sun's Java 2 Virtual Machine (Runtime Environment), version 1.4 or 1.5.
You can download this from http://java.sun.com/getjava/download.html. AFAIK
Writer2LaTeX doesn't run (unmodified) under any other Java interpreter.
Note: In this manual OOo is used as an abbreviation of OpenOffice.org/StarOffice/NeoOffice.
1
If you want to use Writer2LaTeX as an export filter in older versions, please use version 0.4.
2 . Installation
2.1 . How to install Writer2LaTeX for command line usage
Writer2LaTeX can work as a standalone command line utility (that is without OOo).
If you use these styles and uses the configuration file article.xml when you convert your
document with Writer2LaTeX, you will get a result that resembles a handwritten LaTeX file.
Note that hard formatting and any other styles will be ignored.
4.3 . Configuration
XHTML export can be configured with a configuration file. Where the configuration is read from
depends on how you use Writer2xhtml:
If you use Writer2xhtml as an export filter in OOo, the configuration is handled as follows:
• The file writer2latex.xml is read from the user installation directory of OOo
On linux/unix usually something like <home directory>/.OpenOffice.org2/user
On windows usually something like <user profile>\OpenOffice.org2\user
If the file does not exist, it will be created automatically.
If, on the other hand, you use Writer2xhtml from the command line, you will have to specify on
the command line which configuration file to use.
The configuration is a file in xml format. Here is a sample configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<option name="xhtml_custom_stylesheet" value="/mystyle.css" />
<option name="xhtml_ignore_styles" value="false" />
<option name="xhtml_use_dublin_core" value="true" />
<option name="xhtml_convert_to_px" value="true" />
<option name="xhtml_split_level" value="1" />
<xhtml-style-map name="mystyle" class="paragraph" element="p"
css="mycssstyle" />
</config>
7
This and the following options replaces the former option xhtml_ignore_styles.
• The option xhtml_section_formatting is used for the same purpose for section format-
ting. (But note that OOo does not offer section styles currently).
• The option xhtml_table_formatting is used for the same purpose for table formatting.
(But note that OOo does not offer table styles currently).
• The option xhtml_ignore_table_dimensions is used to specify that you don't want ta-
ble dimensions (table width, column width and row height) to be exported, but want to leave
the layout of the tables to the browser.
• The option xhtml_use_dublin_core is used to specify if Dublin Core Meta data should
be exported (the format will be as specified in http://dublincore.org/documents/
dcq-html/). If the value is false, it will not be exported.
• The option xhtml_convert_to_px can have the values true (default) or false. When
this option is true, Writer2xhtml will convert all units to px, otherwise the original units are
used. The resolution is assumed to be 96ppi, you can change this with the xhtml_scaling
option. Eg. a scaling 75% will change the resolution to 72ppi.
• The option xhtml_scaling is used to specify a scaling of all formatting, ie. to get a different
text size than the original document. The value must be a percentage.
• The option xhtml_column_scaling is used to specify an additional scaling for table
colums. The value must be a percentage.
• The option xhtml_split_level is used to specify that the Writer documents should be
split in several documents and the outline level at which the splitting should happen (the
default 0 means no split). This is convenient for long documents. Each output document will
get a simple navigation panel in the header and the footer.
• The option xhtml_calc_split is used to specify that the Calc documents should be split
in several documents, one for each sheet. This is convenient for large spreadsheets. Each
output document will get a simple navigation panel in the header and the footer.
• The option xhtml_uplink is used to specify a link which brings the user up in the page
hierarchy. For example "../index.html".
• The option xhtml_directory_icon is used to specify an (icon) image that represents a
directory. This is used when Writer2xhtml creates index pages for a directory.
• The option xhtml_document_icon is used to specify an (icon) image that represents a doc-
ument. This is used when Writer2xhtml creates index pages for a directory.
• The option xhtml_use_list_hack is used to fix a problem with continued lists. This will
export a list that continues on level 2 or below like <ol><ol><li>...</li></ol></ol>,
which is not valid in xhtml, but works in browsers. Also two deprecated attributes are used
to continue numbering. Default is false.
• The option xhtml_tabstop_style can be used to specify a style used for tabstops. Nor-
mally tabstops are exported as spaces, but with this option the space will be contained in a
span element, eg. <span class="tabstop"> </span>. You can then define a css rule
like eg. tabstop { width: 2em; }.
• The option ignore_double_spaces can have the values true (default) or false. Setting
the option to true will instruct Writer2xhtml to ignore double spaces, otherwise they are
converted to non-breaking spaces.
• The option ignore_empty_paragraphs can have the values true (default) or false. Set-
ting the option to true will instruct Writer2xhtml to ignore empty paragraphs..
• The option ignore_hard_line_breaks can have the values true or false (default). Set-
ting the option to true will instruct Writer2xhtml to ignore hard line breaks (shift-Enter).
So by using these styles only, you will create well-structured XHTML documents. See the docu-
ment sample-xhtml.sxw for an example of how to use this.
Warning: Some elements are not allowed inside pre, so this might in some cases lead to invalid
documents. This will be fixed in a later version of Writer2xhtml.
5 . Using Writer2LaTeX from another Java application
Version 0.5 features a new API to use Writer2LaTeX from another Java application. Please see
the javadoc for the package writer2latex.api for details.
Here's a simple example8 showing how to convert a file to LaTeX using a custom configuration
(excluding exception handling):
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Enumeration;
import writer2latex.api.*;
import writer2latex.util.Config;
factory.createConverter("application/x-latex");
// Create a configuration
Config config = new Config();
config.read(new FileInputStream("myconfig.xml"));
8
The handling of the configuration will change in version 1.0.
config.setOption("inputencoding","latin1");
converter.setConfig(config);