1

I would like to insert this svg file with its style:

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{svg}

\begin{document} \begin{figure}[h!] \centering \scalebox{0.5}{\includesvg{./Test.svg}} \caption{Test} \label{fig:Test} \end{figure} \end{document}

The result is:

enter image description here

I don't understand why the svg package from latex modify my source file without specification.

Zebra125
  • 147
  • Is this any intention to use \scalebox...? – GowriSaro Jan 24 '23 at 11:18
  • @GowriSaro, i tried without \scalebox but same result – Zebra125 Jan 24 '23 at 11:23
  • Did you try using the graphicx package and \includegraphics as an alternative to svg and \includesvg ? Does the same (wrong) conversion occur when compiling the code? – alchemist Jan 24 '23 at 12:37
  • package svg enables LaTeX to typeset any text within the svg (as documented). If this is not desired, you could just use \includesvg[inkscapelatex=false]{./Test.svg} And instead using \scalebox I would recommend to use \includesvg[scale=0.5,inkscapelatex=false]{./Test.svg} instead. – mrpiggi Jan 24 '23 at 13:25
  • @alchemist I didn't use graphix – Zebra125 Jan 24 '23 at 13:34
  • @mrpiggi thanks but I don't get the expected result. I have "-" instead of "-->"and the underlining is missing. – Zebra125 Jan 24 '23 at 13:37
  • Well, then you would have to provide the svg file itself – mrpiggi Jan 24 '23 at 13:39
  • @mrpiggi how please? – Zebra125 Jan 24 '23 at 13:42
  • 1
    Well, you could just open your svg file with any text editor and post the content right here. – mrpiggi Jan 24 '23 at 14:15
  • 1
    What you do only have sense if you want the text of the image replaced by LaTeX text to use the same font size and type that in the rest of the document. So the text size of the original image should match the LaTeX font size, not in the opposite way. If you want the fonts exactly as showed in Inkscape, is just simpler to save your SVG image as PDF (without making a file LaTeX file for text !) and use \includegraphics like you do with PNG or JPG images. – Fran Jan 24 '23 at 22:34

1 Answers1

5

With package svg there are two different approaches regarding the use of fonts:

LaTeX in control

This is the default setting. Any formatting of the fonts in the SVG file is ignored and all text is typeset by LaTeX. Adjustments to the font regarding family, size, weight, shape etc. must be made in LaTeX style directly in the SVG file, using commands such as \small, \huge or \textbf{...} in text fields accordingly.

Inkscape in control

With inkscapelatex=false, LaTeX is disabled for processing text in the SVG file. This can be set for all processed SVG files with \svgsetup{inkscapelatex=false} or individually for certain files by using \includesvg[inkscapelatex=false,...]{...} as needed. In this case, all font formatting remains as it is in the SVG file. This also means, math expressions like $a+b=c$ aren't processed as well and there maybe raises the need to adjust font face, type etc. according to the document if desired.

Note

Regardless of the approach chosen, I recommend to create the SVG graphic preferably in the same size as it should appear in the final output and, if necessary, scaling it only minimally to avoid distorting the chosen fonts in particular.

mrpiggi
  • 645