Menu

Configuring export of images and captions

Help
2011-03-24
2013-05-28
  • Stefan Boehme

    Stefan Boehme - 2011-03-24

    Hi,

    I'm using Writer2LaTeX (1.0.2) together with OpenOffice (3.2.1) and (Zotero 2.1). Unfortenately Zotero is not able to insert citations into captions of figures (and will not be able to do this for the near future). This is, of course, no problem of W2L but of Zotero, but I'm really needing this for my thesis and hope to find a way around this problem using W2L.

    I thought I perhaps could use a specific style in OpenOffice instead of the regular caption, and then map it with a style-map in W2L to a LaTeX caption. Would that be possible and how could it be done? I've created an example document.

    The LaTeX-code should result in something like this:

    \documentclass{book}
    \usepackage{graphicx}
    \begin{document}
      \begin{figure}
        \includegraphics{figure.jpg}
        \caption[Short desciption for TOC]{Long caption with citation.}
      \end{figure}
    \end{document}
    

    My captions will be rather long. So for the list of figures I'd like to use a short title. Is it possible to define this short title for LaTeX directly in OpenOffice?

    Thank you very much in advance.
    Cheers, Stefan

     
  • Stefan Boehme

    Stefan Boehme - 2011-03-25

    In the meantime I got a new idee, it's not pretty, but it is working ;-)

    I created three style in OpenOffice: Figure filename, Figure title, Figure description. Instead of inserting the image, I then just write down the filename of it and mark it with the style "Figure filename". The caption is then constructed with the other two styles. The according style map in W2L looks like this:

    <style-map name="Figure filename" class="paragraph-block" before="\begin{figure}[htpb]" after="\end{figure}" next="Figure title;Figure description" line-break="false" />
    <style-map name="Figure filename" class="paragraph" before="\includegraphics[width=\textwidth]{" after="}" line-break="false" />
    <style-map name="Figure title" class="paragraph" before="\caption[" after="]{%" line-break="false" />
    <style-map name="Figure description" class="paragraph" before="" after="}" line-break="false" />
    [/code]
    It creates the required LaTeX-code, with one line break too much so that the layout of the caption in LaTeX is not perfect, but I'm working on that.
    However, you can still insert the image in OpenOffice to get a visual impression of your document. When exporting the document with W2L I choose the following option:
    [code]<option name="image_content" value="ignore" />[/code]
    This way I don't get the image twice into the LaTeX-code.
    So far, so good. But if there is a more elegant solution, I'd still be interested in it very much ;-)
    Cheers, Stefan
    
     

    Related

    Code: code

  • Rainer M. Krug

    Rainer M. Krug - 2011-03-25

    Depending on how far you are with your thesis, and as you seem to have LaTeX knowledge, you could consider using LyX instead of OpenOffice (http://www.lyx.org/). It works perfectly for longer documents and is effectively a frontened to generating LaTeX directly.
    From their webpage:

    LyX combines the power and flexibility of TeX/LaTeX with the ease of use of a graphical interface. This results in world-class support for creation of mathematical content (via a fully integrated equation editor) and structured documents like academic articles, theses, and books. In addition, staples of scientific authoring such as reference list and index creation come standard.

    I wrote my thesis wit LyX and it worked perfectly.
    Cheers,

    Rainer

     
  • Henrik Just

    Henrik Just - 2011-03-25

    Hi Stefan

    Your solution can be improved slightly: Replace the "Figure filename" style with a "Figure" style and modify your definitions like this:

    <style-map name="Figure" class="paragraph-block" before="\begin{figure}[htpb]" after="\end{figure}" next="Figure title;Figure description" line-break="false" />
    <style-map name="Figure" class="paragraph" before="" after="" line-break="false" />
    <style-map name="Figure title" class="paragraph" before="\caption[" after="]{%" line-break="false" />
    <style-map name="Figure description" class="paragraph" before="" after="}" line-break="false" />[/code]
    If you insert your image anchored [i]as character[/i] in the (otherwise empty) paragraph with the Figure style, you will be able to see your images in OOo as well.
    Best regards
    Henrik
    
     
  • Stefan Boehme

    Stefan Boehme - 2011-03-26

    Hi Rainer, Hi Henrik,

    thank you both very much for your comments. I'm still at the very beginning of my writing process. So it would still possible to switch to lyx. I've already installed the current stable release and it works quite nice. With LyZ I can insert my citations from Zotero and the next version of W2L seems to improve this combination (Zotero, LyX, LyZ) even more.

    However, the improved style map from Henrik does exactly what I need. So this would work as well. I even managed to get rid of the unnecessary line break with help of \mbox{}.

    <style-map name="Figure" class="paragraph-block" before="\begin{figure}[htpb]" after="\end{figure}" next="Figure title;Figure description" line-break="false" />
    <style-map name="Figure" class="paragraph" before="" after="" line-break="false" /> <style-map name="Figure title" class="paragraph" before="\caption[" after="]{\mbox{%" line-break="false" />
    <style-map name="Figure description" class="paragraph" before="}" after="}" line-break="false" />[/code]
    Thank you very much!
    Best regards, Stefan
    
     

Log in to post a comment.