Writer2Latex

From Apache OpenOffice Wiki
Jump to: navigation, search

Documentation exclamation.png    This article is outdated.    

This page contains several QA regarding writer2latex for advanced users. Most answers reference to the Writer2Latex configuration file. A companion page for Writer2xhtml is also available.


Contents

How to number the reference chapters with letters instead of numbers?

Insert the following code into the Writer2Latex configuration file:

 <custom-preamble>
 \renewcommand\bibsection{\section{\refname}}
 </custom-preamble>

How to define the title of the reference chapter to anything instead "References" when using bibtex?

Define in the configuration file:

 <custom-preamble>
 \AtBeginDocument{\renewcommand\refname{Bibliography}}
 </custom-preamble>

What does the option "htbp" mean?

They are different placement options:

  • h means "put the float here, if there is enough room left on the page"
  • t means "put the float on top of the page"
  • b mean "put the float at the bottom of the page"
  • p means "create a special page containing only floats"

the possiblities are tried in the order they are given until a suitable one is found.

pdftex is not able to process my file without errors anymore: "LaTeX Error: Too many unprocessed floats." What to do?

This is a well known problem with LaTeX when there is a huge amount of floats.

You can give LaTeX some more placement options using

 <option name="float_options" value="htbp" />

However, it's probably a better idea not to float the tables

 <option name="float_tables" value="false" />

Perhaps a few experiments will show what you prefer.

I found out that draw objects are not included in Latex. The message "Warning: Draw object ignored" appears instead. Is there a way to include them?

If you have inserted drawing objects directly, they will be ignored. One solution is to insert an object instead: Insert - object - OLE object - OpenOffice Drawing.

Which bibtex style exist?

There's a long list on http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html

How to use bibtex with references of the type (Cp. XYZ)?

Load the package natbib by adding a line to the custom-preamble:

 <custom-preamble>
 \usepackage{natbib}
 </custom-preamble>

Then change the string replace for [[ to:

 <string-replace input="[[" latex-code="\cite[Cp.][]{" />

This should generate the references you want.

How to prevent that URLs are displayed in blue and references in green?

You can change this line in the LaTeX code

 \hypersetup{colorlinks=true, linkcolor=blue, filecolor=blue, pagecolor=blue, urlcolor=blue}

To

 \hypersetup{colorlinks=true, linkcolor=blue, citecolor=blue, filecolor=blue, pagecolor=blue, urlcolor=blue}

or any other color you prefer (eg. black if you don't want to color citations).


How to change heading of level 4 to look like a "real" heading?

For example, add this to the configuration:

 <custom-preamble>
 \makeatletter
 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%{-3.25ex\@plus -1ex \@minus -.2ex}%{1.5ex \@plus .2ex}%{\normalfont\normalsize\bfseries}}
 \makeatother
 </custom-preamble>

The formatting of a the \paragraph will be the same as for \subsubsection (level 3), except that it's without numbering.

List of tables or list of figures does not work. What to do?

If you don't have a list of tables in your document, you will have to help Writer2Latex to identify the captions:

 <option name="table_sequence_name" value="Table" />

(the value should be the name of the sequence name in OpenOffice).

Likewise you shoud add

 <option name="figures_sequence_name" value="Illustration" />

if you have image captions.

My resulting document has wrong counting of page numbers. What to do?

It's a simple LaTeX problem; you should always run your document throug TeX twice.

How to implement marginal notes with Writer2Latex like the \marginpar{...} in LaTeX?

These can be created quite easily with Writer2LaTeX.

Again you can either use styles or text content:

With styles: Create a paragraph style called eg. marginpar and add

 <style-map name="marginpar" class="paragraph" before="\marginpar{" after="}" />

With text: Add a string-replacement to your configuration, eg.

 <string-replace input="/margin/" latex-code="\marginpar{" />
 <string-prelace input="//" latex-code="}" />

or something similar Then you will write bla bla /margin/This goes to the margin// bla bla...

Another alternative is to use notes/annotations in OpenOffice:

 <option name="notes" value="marginpar" />

In all cases you must ensure that there is sufficient room in the margin; by changing the margin in OpenOffice or in the converted LaTeX file.

Is it possible to hack latex code directly in OpenOffice? How to use bibtex with Writer2Latex?

My plan is to keep my bibliographic data in a separate bibtex file and use it when creating the PDF from TEX file. Therefore I would like to hack latex code directly in OpenOffice such like "\nocite{xyz}" or "\\nocite{xyz}" to distinct it from regular text.

There are several ways to achieve this:

  • you can create a special character style in OpenOffice, and then configure Writer2Latex to treat this as verbatim LaTeX code

This character style could for example format the text in boldface, red, to make it easy to see. So to insert a reference, you would write \cite{xyz} and then apply your character style to this. The configuration should contain

 <style-map name="the style name" class="text" before="" after="" verbatim="true" />
  • or you can have OpenOffice add the LaTeX code, so you only have to write the key

So to insert a reference, you would write xyz and then apply your character style to this. The configuration should contain

 <style-map name="the style name" class="text" before="\cite{" after="}"  />
  • or you can use some special text markup, for example you could write <<<xyz>>> in OpenOffice to represent a reference

Then instruct Writer2Latex to convert this to a reference:

 <string-replace input="<<<" latex-code="\cite{" />
 <string-replace input=">>>" latex-code="}" />
  • or a variant: Write you citation as \\citeTemplate:Xyz and use
 <string-replace input="\\" latex-code="\" />
 <string-replace input="{{" latex-code="{" />
 <string-replace input="}}" latex-code="}" />

you can insert citations in the text like this, as we previously discussed

Bla bla bla ses the reference \\cite {{{1}}} , bla bla bla.

At the point, where you want the bibliography to appear, you add additional LaTeX code:

 \\nociteTemplate:Key1,key2
 \\bibliographystyleTemplate:Plain
 \\bibliographyTemplate:Bibtexfile

Of course plain should be replaced with the BibTeX style you want to use, and bibtexfile with the name of your file.

That should be all. As you probably know, you will have to process the file several times, like this:

 pdflatex document
 bibtex document
 pdflatex document
 pdflatex document

Then all your references should be resolved and inserted.

How to format the title in the default LaTeX style instead of having the title in a small non-serif font?

If your title is formatted with a paragraph style, you can instruct Writer2Latex to generate specific code for this, eg.

 <style-mape name="the style name in OpenOffice" class="paragraph" before="\title{" after="}\maketitle" />

You have to use the english name of the text style:

 <style-mape name="Title" class="paragraph" before="\title{" after="}\maketitle" />

When you use the built in styles, OpenOffice always saves the english style names (to allow better exchange of documents).

Alternatively

 <option name="formatting" value="convert_most" />

which will try to convert more formatting - but this requires a very well structured document.

How to change the width of table borders?

You can change the width by adding e.g.

 <custom-preamble>
 \setlength\arrayrulewidth{0.8pt}
 </custom-preamble>

to the configuration. The standard width is 0.4pt, so this will double the width.

how could I define 1.5 line spacing instead of the default one?

Please try this in the configuration:

 <custom-preamble>
 \renewcommand\baselinestretch{1.25}
 </custom-preamble>

Why are images not embedded but "Warning: Image ignored" displayed instead?

Please try

 <option name="backend" value="pdftex" />
 <option name="backend" value="unspecified" />

This will include your images.

My tables width is too large so that pdflatex displays me several errors that some tables are too width to fit on the page. What to do?

If they are too wide, it's probably because you use different margins in OpenOffice and LaTeX. You can choose to

  • change the margins in OpenOffice and adapt the tables to the new margins
  • let Writer2Latex convert the page layout (<option name="page_formatting" value="convert_all" />)
  • let Writer2Latex produce tables with l, r and c columns rather than p-columns (<option name="simple_table_limit" value="20" />, or some other number which means that all tables in which no cell contains more that 20 characters will be exported with c, r and l-columns.)

Is there a way to tell Writer2Latex or OpenOffice to turn tables by 90° if required?

No, you will have to manually add sidewaystable to the LaTeX file.

how to change the terminology "figure" used in image caption to something else, e.g. "illustration"?

It should work to add some extra code to your preamble:

 <custom-preamble>
 \AtBeginDocument{\renewcommand\figurename{Illustration}}
 </custom-preamble>

For version 0.6 I will add the possibility to set this automatically.

How to let text flow around (small) images?

Text flow around a figure is problematic in LaTeX (that's why I don't try to export this with Writer2Latex). I would recommended the pacakge floatflt.sty for this.

This requires some manual editing of the LaTeX file:

Add the package to the preamble:

 \usepackage{floatflt}

Replace the relevant

 \begin{figure}
 ....
 \end{figure}

with

 \begin{floatingfigure}{5cm}
 ....
 \end{floatingfigure}

(replacing 5cm with the actual width of the figure)

However: For this to work well there has to be a certain amount of text around the figure, and there must be no lists or headings immediately after the figure. Thus there's a chance that 12 small images and not a lot of text will give you trouble.

How to left justify all captions?

You can center the tables as well in your document or:

You can left justify all captions. Writer2Latex currently use a version called caption2, which is obsolete and replaced with a version called caption (this is actually version3). Writer2Latex will be fixed to use the never version of caption.sty soon.

Configure:

 <option name="use_caption2" value="true" />

Then you should add to your custom preamble:

 <custom-preamble>
 \captionsetup[table]{justification=raggedright,singlelinecheck=false}
 </custom-preamble>

But you also need to edit the LaTeX file and replace

 \usepackage{caption2}

with

 \usepackage{caption}

A table could easily break particular cells in two or more lines but exceeds the page width instead. How to fix it?

You should lower the value of the option simple_table_limit, for example

 <option name="simple_table_limit" value="25" />

If all cells in a table contains at most this number of characters, they will be exported as simple tables with one line per cell. This creates slightly better results for these tables, but if the value is too large you will get the results, you see in your example.

The background of embedded images with a transparent background is rendered colourful. How to fix it?

Yes, unfortunately pdfTeX does not support transparent backgrounds, so you have to edit it with some external image tool to replace the transparent color with white.

When processing pdflatex it warns me "No author given". What to do?

This is harmless; it's a warning that there is not given an author name to add below the title.

Charts inserted as OLE objects are rendered "ugly", look like bitmaps and not as vector charts. How to render charts properly?

That's right - in fact the whole diagram is exported as a bitmap. I should really export it as pdf, but this is not yet implemented. Here's a workaround for this problem:

You can create a pdf version as follows:

1. Change the backend option to dvips

 <option name="backend" value="dvips" />

and then export your document. This will generate an eps-file with your diagram.

2. Convert this file to pdf using ghostscript/ghostview

3. Change the backend top pdftex again

 <option name="backend" value="dvips" />

and make sure also to include this option: <option name="remove_graphics_extension" value="true" />

The next time you export your document again, Writer2Latex will generate a png-file with your diagram. Delete the png file before running the document through LaTeX: PdfTeX will then find the pdf version of the image and include it.

This is not very elegant - of course I will implement automatic conversion of vector images to pdf later. This will not be fixed in version 0.5, but it's on my list for version 0.6.

Personal tools