8

I'm trying to import a graphic created in LibreOffice Draw in a LaTeX document.

So far I've tried the Way:

  1. Export Document to SVG file.
  2. Open with Inkscape and Export using eps+latex
  3. Including resulting xxx.eps_tex in latex

Although the SVG seems to be just fine (also in Inkscape), the exported positions of the text are bad:

\begin{picture}(1,0.73115748)%
   \put(0,0){\includegraphics[width=\unitlength]{ModeDispersion.eps}}%
   \put(-0.05241193,0.78432034){\makebox(0,0)[lb]{\smash{Cladding (air)}}}%
   \put(-0.05241193,0.78432034){\makebox(0,0)[lb]{\smash{Substrate}}}%
   \put(-0.05241193,0.78432034){\makebox(0,0)[lb]{\smash{In}}}%
   \put(-0.05472789,0.25830639){\makebox(0,0)[lb]{\smash{Out}}}%
   \put(-0.05472789,0.25830639){\makebox(0,0)[lb]{\smash{Single-mode}}}%
\end{picture}%

and so on. Same for pdf+latex.

Original LibreOffice (version 4.0.1.2) file and exported SVG: ODG SVG

I can't attach the files created by Inkscape (version 0.48.3.1), as stackoverflow told me that I would need at least ten reputations to do so...

Does anyone know how to solve this problem?

edit: Shown in inkscpae:

Inkscape
(source: x-linux.de)

Processed using latex:

LaTeX
(source: x-linux.de)

migrated from stackoverflow.com Mar 30 '13 at 13:32

This question came from our site for professional and enthusiast programmers.

4
  • The graphics figure Work flow adopted by you .odg-->.svg--> eps+tex/pdf+tex is not optimal due to conversion inefficiency of respective editor.

  • The recommended choice of figure format is .pdf always except for screenshots (.png) and photos (.jpg) assuming pdflatex engine.

  • Adopt a 'single' conversion step to generate figure.pdf. Either .svg to .pdf or .odg to .pdf not combine them.

  • Inkscape exports to .pdf with latex fonts(latin modern) or close enough, similarly LibreOffice. I have successfully changed the fonts and exported your drawing using Libreoffice to .pdf. You can even draw in Inkscape and export to pdf also.

enter image description here

  • Ok, it seems that I have no choice but to dig into drawing diagramms directly with LaTeX (what is surely not the worst). I was just curious to know who is guiltily in case of the text items. Is LibreOffice that bad guy who messes around with the svg-standard? I don't think so, because Inkscpae can actually show me the correct image, but export of all texts written in Office is wrong. On the other hand it has really surprised me that text that has been later added directly in inkscpae performs well... – MrD Mar 31 '13 at 10:48
  • Who is guilty ? 'Ourselves' for using wrong tools in wrong combination for wrong purpose, when they are best tools in latex graphic packages – texenthusiast Mar 31 '13 at 15:11
  • Ok...I will be looking into pstricks. Thanks. Was just wondering if the svg is wrong or if it is exported badly. – MrD Mar 31 '13 at 17:19
0

Why don't you export your drawing as .png and the incorporate it like this?

\documentclass{article}

\usepackage{pgf}

\begin{document}

\begin{center}
  \pgfimage[width=0.6\textwidth]{myshapes.png}
\end{center}

\end{document}

You will need to use pdflatex to compile your .tex file.

You can get the whole bunch of files for the above solution here.

  • There are several disadvatages using a PNG-image, as I want everything to be included as vectro graphics. Also Text should be treated by latex itselt, so it will get the same text shape as the rest of the document. Also I mentioned that the filesize is about to explode if I would only use images, as I will need many of them. – MrD Mar 30 '13 at 16:03
0

When exporting from LibreOffice, the SVG XML gets exported as:

<svg>
   <text>
      <tspan>
         <tspan>
            <tspan>
            </tspan>
         </tspan>
      </tspan>
   </text>
</svg>

The problem is that PDF Export only look coordinate in to text mark. I just copied the x,y coordinate do text markup.

I made a quick fix using python and I am sharing at gitgub:

https://github.com/thalesmaoa/libreoffice-Calc-SVG-Latex

The result is exactly what I was looking for:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.