3

I am following the CTAN documentation for exporting an SVG image with LaTeX symbols from Inkscape to embed as an EPS figure in my latex document. MWE is below:

\documentclass[]{article}
\usepackage{epsfig,graphicx,amsmath,amsfonts}
\usepackage{xcolor,import}
\usepackage{transparent}
\begin{document}
 \begin{figure}[h] 
  \centering  
   \def\svgwidth{70mm}  
    \import{}{foo.eps_tex}  
 \end{figure}
\end{document}

where the file foo.eps_tex is generated from Inkscape (File → Save As... → Encapsulated PostScript (*.eps) → EPS+LaTeX). The original Inkscape drawing is shown below: enter image description here

and the resulting image in the PDF (LaTeX + DVItoPs + PStoPDF ) is as seen below: enter image description here

Though, more or less, the symbols are pretty much where I wanted them, they are not placed exactly at the place as per the original SVG drawing. Of course, I could always go back to my drawing, tweak a little and generate the PDF to see if it looks OK. However, I have many such figures to make and this process is not desirable. How do I get my LaTeX symbols not float when I export the SVG? The foo.eps_tex file is appended below.

\begingroup%
\makeatletter%
\providecommand\color[2][]{%
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package  'color.sty' is not loaded}%
\renewcommand\color[2][]{}%
}%
\providecommand\transparent[1]{%
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
\renewcommand\transparent[1]{}%
}%
\providecommand\rotatebox[2]{#2}%
\ifx\svgwidth\undefined%
\setlength{\unitlength}{495.90927734bp}%
\ifx\svgscale\undefined%
  \relax%
\else%
  \setlength{\unitlength}{\unitlength * \real{\svgscale}}%
\fi%
\else%
\setlength{\unitlength}{\svgwidth}%
\fi%
\global\let\svgwidth\undefined%
\global\let\svgscale\undefined%
\makeatother%
\begin{picture}(1,0.91319971)%
\put(0,0){\includegraphics[width=\unitlength]{foo.eps}}%
\put(0.12591704,0.64997299){\color[rgb]{0,0,0}\makebox(0,0) [lb]{\smash{$\Gamma_s$}}}%
\put(0.12401264,0.02224006){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{$\Omega_ \infty$}}}%
\put(0.45672106,0.40227734){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{$\Omega_s$}}}%
\put(0.22841188,0.84721223){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{$p^{\mathrm{inc}}$}}}%
\put(0.70651045,0.02827193){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{$\Gamma_s^e$
$\mbox{Element}$}}}%
\put(0.86737431,0.22302397){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{$\mbox{Node}$}}}%
\end{picture}%
\endgroup%

The reason for using \import instead of \input is to be able to provide the path for the figure data. For example if the Inkscape file foo.svg and the corresponding foo.eps_tex are located in ./Chapter1/ then I would use (also see a similar question here)

\import{./Chapter1/}{foo.eps_tex} 
  • I realize that it would be ideal to add the text while still in Inkscape, but if no good solutions arise, are you amenable to adding the text after the fact, on the LaTeX end? If so, see for example tex.stackexchange.com/questions/171483/… – Steven B. Segletes Apr 28 '14 at 12:15
  • The latex math symbols are added while in Inkscape! – user1234 Apr 28 '14 at 12:22
  • please post the foo.eps_tex file, also why use \import not \input (and don't use epsfig package, ever, unless using a document from 1990) – David Carlisle Apr 28 '14 at 14:07
  • Yes, epsfig is not really needed. – user1234 Apr 28 '14 at 14:34
  • Why couldn't you use the path with \input? \input(Chapter1/foo.eps_tex} ? Since all he text is positioned at absolute coordinates by inkskape there's not much you could do at the text level. If you change the (0,0) in the first \put you will move the image relative to the text so you may find values that work for all your examples if they are all displaced by the same amount. – David Carlisle Apr 28 '14 at 15:14
1

The .eps_tex file is indeed informative but adjusting the \put coordinates did not help much and besides I do not know how to automate the process. I however tried exporting .ps file instead of .eps file, i.e., File → Save As... → PostScript (*.ps) → PS+LaTeX. See how a .eps export and .ps export compare in the resulting LaTeX compiled final PDF file.

This is the original SVG drawing:enter image description here

This is how the .eps figure looks in the LaTeX compiled PDF enter image description here,

Finally this is how a .ps figure looks in the LaTex compiled PDF enter image description here

There is a little bit of x and y shifts in both .eps and .ps exports, however, .ps looks much closer to the original SVG drawing in Inkscape. For example, look at the $\Gamma_s$ symbol in the original SVG drawing. It is moved to the other side of the curve in the .eps whereas its position is more or less the same in .ps export. Surprisingly, when I look at the .eps_tex and .ps_tex files for the \put data, both the files are identical! I cannot understand why the symbols move in .eps file so much- any explanation?. I think exporting the file in .ps format solves my problem for the time being.

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.