[Tex/LaTex] Adding latex to figures from Inkscape


I have been using psfrag to add latex to figures for a while. I make my figures in Inkscape and compile in MikTex using texniccenter. I switched laptops and installed the latest Inkscape and MikTex and then psfrag stopped working. I then downgraded Inkscape to this: Inkscape 0.48.0 r9654. To no avail. Has anyone had problems like this with psfrag? What is the standard way to add latex to our figures?

Here is the code I use to swap latex into my diagrams. Am I doing anything wrong?



% [font=small,labelfont=bf] Required for specifying captions to tables and figures



\psfrag{1}{\Huge $hasA$}
\includegraphics[height= 3cm]{images/HasaConstruction.eps}
\caption{something something}

Best Answer

Instead of using psfrag I would simply export the image as pdf+tex from inkscape.

For example if your image looks like this in inkscape:

enter image description here

you can save it as .pdf and select the option "omit text in pdf and create latex file" during the export:

enter image description here

This will produce two files: a pdf with just the red ellipse but without the text and a .pdf_tex file that contains the following code:

%% Creator: Inkscape inkscape 0.92.2, www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'drawing.pdf' (pdf, eps, ps)
%% To include the image in your LaTeX document, write
%%   \input{<filename>.pdf_tex}
%%  instead of
%%   \includegraphics{<filename>.pdf}
%% To scale the image, write
%%   \def\svgwidth{<desired width>}
%%   \input{<filename>.pdf_tex}
%%  instead of
%%   \includegraphics[width=<desired width>]{<filename>.pdf}
%% Images with a different path to the parent latex file can
%% be accessed with the `import' package (which may need to be
%% installed) using
%%   \usepackage{import}
%% in the preamble, and then including the image with
%%   \import{<path to file>}{<filename>.pdf_tex}
%% Alternatively, one can specify
%%   \graphicspath{{<path to file>/}}
%% For more information, please see info/svg-inkscape on CTAN:
%%   http://tug.ctan.org/tex-archive/info/svg-inkscape
    \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
    \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
      \setlength{\unitlength}{\unitlength * \real{\svgscale}}%

(if you need to adjust the colour or position of the text, you can simply edit this file, just make sure you are not overwriting the adjusted file in case you export again from inkscape)

This file can now easily be included in your latex document




\caption{something something}


After compiling with pdflatex (or xe/lualtex) the result looks like this:

enter image description here