Difference between revisions of "Writer2Latex"
Line 1: | Line 1: | ||
'''This page contains several QA regarding [http://www.hj-gym.dk/~hj/writer2latex/ writer2latex] for advanced users. Work is in progress...''' | '''This page contains several QA regarding [http://www.hj-gym.dk/~hj/writer2latex/ writer2latex] for advanced users. Work is in progress...''' | ||
+ | |||
+ | |||
+ | ===Q: List of tables or list of figures does not work. What to do?=== | ||
+ | |||
+ | A: If you don't have a list of tables in your document, you will have to help w2l to identify the captions: | ||
+ | |||
+ | <option name="table_sequence_name" value="Table" /> | ||
+ | |||
+ | (the value should be the name of the sequence name in OOo). | ||
+ | |||
+ | Likewise you shoud add | ||
+ | |||
+ | <option name="figures_sequence_name" value="Illustration" /> | ||
+ | |||
+ | if you have image captions. | ||
+ | |||
+ | ===Q: 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. | ||
+ | |||
+ | ===Q: How to implement marginal notes with w2l like the \marginpar{...} in LaTeX?=== | ||
+ | |||
+ | A: 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 OOo: | ||
+ | <option name="notes" value="marginpar" /> | ||
+ | |||
+ | In all cases you must ensure that there is sufficient room in the margin; by changing the margin in OOo or in the converted LaTeX file. | ||
+ | |||
+ | ===Q: Is it possible to hack latex code directly in OOo? How to use bibtex with w2l?=== | ||
+ | |||
+ | A: 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 OOo 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 OOo, and then configure w2l 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 OOo 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 OOo to represent a reference | ||
+ | Then instruct w2l to convert this to a reference: | ||
+ | <string-replace input="<<<" latex-code="\cite{" /> | ||
+ | <string-replace input=">>>" latex-code="}" /> | ||
+ | |||
+ | * or a variant: Write you citation as \\cite{{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{{key}}, bla bla bla. | ||
+ | |||
+ | At the point, where you want the bibliography to appear, you add additional LaTeX code: | ||
+ | |||
+ | \\nocite{{key1,key2}} | ||
+ | \\bibliographystyle{{plain}} | ||
+ | \\bibliography{{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. | ||
+ | |||
+ | ===Q: How to format the title in the default LaTeX style instead of having the title in a small non-serif font?=== | ||
+ | |||
+ | A: If your title is formatted with a paragraph style, you can instruct w2l to generate specific code for this, eg. | ||
+ | <style-mape name="the style name in OOo" 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, OOo 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. | ||
+ | |||
+ | ===Q: How to change the width of table borders?=== | ||
+ | A: 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. | ||
+ | |||
+ | ===Q: how could I define 1.5 line spacing instead of the default one?=== | ||
+ | |||
+ | A: Please try this in the configuration: | ||
+ | |||
+ | <custom-preamble> | ||
+ | \renewcommand\baselinestretch{1.25} | ||
+ | </custom-preamble> | ||
+ | |||
+ | ===Q: Why are images not embedded but "Warning: Image ignored" displayed instead?=== | ||
+ | |||
+ | A: Please try | ||
+ | <option name="backend" value="pdftex" /> | ||
+ | <option name="backend" value="unspecified" /> | ||
+ | This will include your images. | ||
+ | |||
+ | ===Q: 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?=== | ||
+ | |||
+ | A: If they are too wide, it's probably because you use different margins in OOo and LaTeX. | ||
+ | You can choose to | ||
+ | * change the margins in OOo and adapt the tables to the new margins | ||
+ | * let w2l convert the page layout (<option name="page_formatting" value="convert_all" />) | ||
+ | * let w2l 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.) | ||
+ | |||
+ | ===Q: Is there a way to tell w2l or OOo to turn tables by 90° if required?=== | ||
+ | A: No, you will have to manually add sidewaystable to the LaTeX file. | ||
===Q: how to change the terminology "figure" used in image caption to something else, e.g. "illustration"?=== | ===Q: how to change the terminology "figure" used in image caption to something else, e.g. "illustration"?=== |
Revision as of 08:53, 19 August 2007
This page contains several QA regarding writer2latex for advanced users. Work is in progress...
Q: List of tables or list of figures does not work. What to do?
A: If you don't have a list of tables in your document, you will have to help w2l to identify the captions:
<option name="table_sequence_name" value="Table" />
(the value should be the name of the sequence name in OOo).
Likewise you shoud add
<option name="figures_sequence_name" value="Illustration" />
if you have image captions.
Q: 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.
Q: How to implement marginal notes with w2l like the \marginpar{...} in LaTeX?
A: 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 OOo: <option name="notes" value="marginpar" />
In all cases you must ensure that there is sufficient room in the margin; by changing the margin in OOo or in the converted LaTeX file.
Q: Is it possible to hack latex code directly in OOo? How to use bibtex with w2l?
A: 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 OOo 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 OOo, and then configure w2l 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 OOo 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 OOo to represent a reference
Then instruct w2l 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 {{#switch:{{{1}}} | shift = ⇧ Shift | up = ↑ | down = ↓ | > = → | < = ← | enter = ↵ Enter | cmd = ⌘ Cmd | command = ⌘ Cmd | opt = ⌥ Opt | option = ⌥ Opt | tab = Tab ⇆ | backspace = ← Backspace | << = ← Backspace | bs = ← Backspace | * = * | # = # | ; = ; | : = : | #default = {{{1}}} }} {{#if:| + {{#switch:{{{2}}} | shift = ⇧ Shift | up = ↑ | down = ↓ | > = → | < = ← | enter = ↵ Enter | cmd = ⌘ Cmd | command = ⌘ Cmd | opt = ⌥ Opt | option = ⌥ Opt | tab = Tab ⇆ | backspace = ← Backspace | << = ← Backspace | bs = ← Backspace | * = * | # = # | ; = ; | : = : | #default = {{{2}}} }} }}{{#if:| + {{#switch:{{{3}}} | shift = ⇧ Shift | up = ↑ | down = ↓ | > = → | < = ← | enter = ↵ Enter | cmd = ⌘ Cmd | command = ⌘ Cmd | opt = ⌥ Opt | option = ⌥ Opt | tab = Tab ⇆ | backspace = ← Backspace | << = ← Backspace | bs = ← Backspace | * = * | # = # | ; = ; | : = : | #default = {{{3}}} }} }}{{#if:| + {{#switch:{{{4}}} | shift = ⇧ Shift | up = ↑ | down = ↓ | > = → | < = ← | enter = ↵ Enter | cmd = ⌘ Cmd | command = ⌘ Cmd | opt = ⌥ Opt | option = ⌥ Opt | tab = Tab ⇆ | backspace = ← Backspace | << = ← Backspace | bs = ← Backspace | * = * | # = # | ; = ; | : = : | #default = {{{4}}} }} }}{{#if:| + {{#switch:{{{5}}} | shift = ⇧ Shift | up = ↑ | down = ↓ | > = → | < = ← | enter = ↵ Enter | cmd = ⌘ Cmd | command = ⌘ Cmd | opt = ⌥ Opt | option = ⌥ Opt | tab = Tab ⇆ | backspace = ← Backspace | << = ← Backspace | bs = ← Backspace | * = * | # = # | ; = ; | : = : | #default = {{{5}}} }} }}{{#if:| + {{#switch:{{{6}}} | shift = ⇧ Shift | up = ↑ | down = ↓ | > = → | < = ← | enter = ↵ Enter | cmd = ⌘ Cmd | command = ⌘ Cmd | opt = ⌥ Opt | option = ⌥ Opt | tab = Tab ⇆ | backspace = ← Backspace | << = ← Backspace | bs = ← Backspace | * = * | # = # | ; = ; | : = : | #default = {{{6}}} }} }}, 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.
Q: How to format the title in the default LaTeX style instead of having the title in a small non-serif font?
A: If your title is formatted with a paragraph style, you can instruct w2l to generate specific code for this, eg. <style-mape name="the style name in OOo" 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, OOo 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.
Q: How to change the width of table borders?
A: 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.
Q: how could I define 1.5 line spacing instead of the default one?
A: Please try this in the configuration:
<custom-preamble> \renewcommand\baselinestretch{1.25} </custom-preamble>
Q: Why are images not embedded but "Warning: Image ignored" displayed instead?
A: Please try <option name="backend" value="pdftex" /> <option name="backend" value="unspecified" /> This will include your images.
===Q: 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?===
A: If they are too wide, it's probably because you use different margins in OOo and LaTeX. You can choose to
- change the margins in OOo and adapt the tables to the new margins
- let w2l convert the page layout (<option name="page_formatting" value="convert_all" />)
- let w2l 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.)
Q: Is there a way to tell w2l or OOo to turn tables by 90° if required?
A: No, you will have to manually add sidewaystable to the LaTeX file.
Q: how to change the terminology "figure" used in image caption to something else, e.g. "illustration"?
A: 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.
Q: How to let text flow around (small) images?
A: Text flow around a figure is problematic in LaTeX (that's why I don't try to export this with w2l). 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.
Q: How to left justify all captions?
A: You can center the tables as well in your document or:
You can left justify all captions. W2l currently use a version called caption2, which is obsolete and replaced with a version called caption (this is actually version3). w2l 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}
Q: A table could easily break particular cells in two or more lines but exceeds the page width instead. How to fix it?
A: 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.
Q: The background of embedded images with a transparent background is rendered colourful. How to fix it?
A: 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.
Q: When processing pdflatex it warns me "No author given". What to do?
A: This is harmless; it's a warning that there is not given an author name to add below the title.
Q: Charts inserted as OLE objects are still rendered "ugly", look like bitmaps and not as vector charts. What to do?
A: This will not be fixed in version 0.5, but it's on my list for version 0.6.