0

I am trying to get different size fonts in a tex file exported from inkscape. The idea is that my figure might have header text that should be bigger than other text. For example, I have this in inkscape:

What it looks like as an svg

which ends up looking like this:

What it looks like after going through latex

I'm not looking for full control of the text size before exporting but if i could get 2 or 3 differences i could scale the whole image to get what i need.

Here are the three files (svg, tex that's exported, minimal doc):

svg:

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="249"
   height="128.25"
   id="svg4384"
   version="1.1"
   inkscape:version="0.48.3.1 r9886"
   sodipodi:docname="New document 11">
  <defs
     id="defs4386" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="1.6006032"
     inkscape:cx="166.8913"
     inkscape:cy="76.406645"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     fit-margin-top="0"
     fit-margin-left="0"
     fit-margin-right="0"
     fit-margin-bottom="0"
     inkscape:window-width="1366"
     inkscape:window-height="709"
     inkscape:window-x="0"
     inkscape:window-y="27"
     inkscape:window-maximized="1" />
  <metadata
     id="metadata4389">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(-121.4375,-132.9375)">
    <g
       id="g4406"
       transform="translate(18.742934,-6.8724092)">
      <text
         sodipodi:linespacing="125%"
         id="text4392"
         y="195.21933"
         x="140"
         style="font-size:28px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
         xml:space="preserve"><tspan
           y="195.21933"
           x="140"
           id="tspan4394"
           sodipodi:role="line">Header Text.</tspan></text>
      <text
         sodipodi:linespacing="125%"
         id="text4396"
         y="220.1759"
         x="198.05034"
         style="font-size:14px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
         xml:space="preserve"><tspan
           y="220.1759"
           x="198.05034"
           id="tspan4398"
           sodipodi:role="line">Smaller text.</tspan></text>
      <text
         sodipodi:linespacing="125%"
         id="text4400"
         y="241.41789"
         x="237.41049"
         style="font-size:14px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
         xml:space="preserve"><tspan
           style="font-size:8px"
           y="241.41789"
           x="237.41049"
           id="tspan4402"
           sodipodi:role="line">Some even smaller.</tspan></text>
      <rect
         ry="6.6343722"
         y="151.45181"
         x="121.82908"
         height="109.33378"
         width="213.04468"
         id="rect4404"
         style="color:#000000;fill:none;stroke:#000000;stroke-width:0.78299999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.56600001, 1.56600001;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
    </g>
  </g>
</svg>

inkscape latex:

%% Creator: Inkscape inkscape 0.48.3.1, www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'sample.eps' (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
%%
\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}{171.05bp}%
    \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.51505408)%
    \put(0,0){\includegraphics[width=\unitlength]{sample.eps}}%
    \put(0.08681672,0.3085328){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Header Text.}}}%
    \put(0.35831787,0.19181103){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Smaller text.}}}%
    \put(0.54240511,0.09246236){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{Some even smaller.}}}%
  \end{picture}%
\endgroup%

sample latex doc:

\documentclass{article}

\usepackage{graphicx}
\usepackage{color}


\begin{document}

\begin{figure}
    \centering
    \def\svgwidth{\columnwidth}
    \input{sample.eps_tex}
\end{figure}

\end{document}
0

Since inkscape just moves your text as is, i was able to simply embed latex into the text itself. This isn't the most elegant solution but it does work.

The only "gotcha" is that the text location is based on where in the svg the text starts. So if you start your text with a latex command that gets interpreted, the text will end up where the latex starts. This makes text in a block somewhat more difficult to place. I found it easier to lay out the diagram with the default sized text first and then go back and add {\huge Header text} or {\footnotesize Smaller text}. YMMV.

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.