1

Is there a possibility to place text on a svg vector image without using Inkscape?

For me it is much more convenient to change the text quickly using \overpic and \put than opening Inkscape and generating the pdf_tex file every time.

Or is that just the only way to do it? Thanks!

  • 1
    See tex.stackexchange.com/questions/171483/… The answer there uses \stackinset of the stackengine package. – Steven B. Segletes Sep 10 '19 at 11:47
  • Brilliant! This works for me: \stackinset{l}{20pt}{b}{20pt}{test}{% \includesvg[width=0.15\linewidth, svgpath=images/]{test-svg} } The only thing is that relative placements (relative to the image size) are not possible as far as I understood the documentation. So I have to adjust the text every time I change the scaling. Do you wanna add your anser as an Answer @Steven – ro-bb Sep 10 '19 at 12:29
  • Where can I find an example svg image to use in my MWE? – Steven B. Segletes Sep 10 '19 at 12:41
  • I created one on draw.io Do you need an actual download link? It should work with an arbitrary SVG file – ro-bb Sep 10 '19 at 12:47
  • Well, I haven't used inkscape, and I can't find anything on the web that identifies as an svg. – Steven B. Segletes Sep 10 '19 at 12:48
3

Here, I use \stackinset to achieve the goal (stackengine package)

I provide \scaledinset in response to the OP's comment. Thus, rather than #2 and #4 being physical x and y distances, they represent a fraction of the overall width and height of the graphical object.

I also use a standard graphic, rather than an svg, for this demonstration.

\documentclass[standard]{letter}
\usepackage{svg}
\usepackage[usestackEOL]{stackengine}
\usepackage{graphicx}
\newcommand\scaledinset[6]{%
  \setbox0=\hbox{#6}%
  \stackinset{#1}{#2\wd0}{#3}{#4\ht0}{#5}{#6}
}
\begin{document}
\scaledinset{l}{.5}{b}{.7}{test}{\includegraphics[width=0.15\linewidth]{example-image}}

\scaledinset{l}{.5}{b}{.7}{test}{\includegraphics[width=0.45\linewidth]{example-image}}
\end{document}

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.