Install inkscape2tikz. The following example is taken from inkscape2tikz home page.
Using inkscape2tikz we export this in to tikz code:
\documentclass{article}
\usepackage{tikz}
\usepackage{charter} %%%% Added for demo of fonts
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\definecolor{cff8080}{RGB}{255,128,128}
\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1]
\begin{scope}[draw=black,line join=round,miter limit=4.00,line width=3.200pt]
\path[draw=black,fill=cff8080,line join=round,even odd rule,line cap=butt,miter
limit=4.00,line width=3.200pt] (91.0455,165.7194) rectangle
(250.7252,347.8104);
\path[draw=black,line join=round,even odd rule,line cap=butt,miter
limit=4.00,line width=3.200pt] (168.0839,258.1656) .. controls
(169.6992,260.2725) and (166.0408,261.3824) .. (164.5822,260.8503) .. controls
(160.6293,259.4083) and (160.6636,254.1057) .. (162.7146,251.1621) .. controls
(166.3833,245.8967) and (174.0594,246.2369) .. (178.5892,250.1116) .. controls
(185.2369,255.7979) and (184.5602,266.1224) .. (178.8226,272.1726) .. controls
(171.1753,280.2366) and (158.1221,279.2067) .. (150.5752,271.5890) .. controls
(141.0782,262.0028) and (142.4690,246.1872) .. (151.9759,237.1551) .. controls
(163.4900,226.2161) and (182.0854,227.9716) .. (192.5962,239.3729) .. controls
(204.9828,252.8090) and (202.8604,274.1941) .. (189.5613,286.1796) .. controls
(174.2071,300.0173) and (150.0257,297.5267) .. (136.5682,282.3277) .. controls
(121.2770,265.0577) and (124.1368,238.0757) .. (141.2372,223.1481) .. controls
(160.4213,206.4017) and (190.2069,209.6312) .. (206.6032,228.6342) .. controls
(224.8061,249.7311) and (221.2064,282.3227) .. (200.3000,300.1866);
\end{scope}
\end{tikzpicture}
\end{document}
Call this file as image.tex
(say). Following is your main.tex
file. Put image.tex
and main.tex
in the same folder. For this example, I have added image.tex
by filecontents
.
\documentclass{article}
\usepackage{graphicx}
\usepackage{charter} %%%% Added for demo of fonts Keep this in image.tex also to have same fonts
\usepackage{filecontents}
\begin{filecontents*}{image.tex}
\documentclass{article} %%% tex file for image begins
\usepackage{tikz}
\usepackage{charter} %%%% Added for demo of fonts
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\definecolor{cff8080}{RGB}{255,128,128}
\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1]
\begin{scope}[draw=black,line join=round,miter limit=4.00,line width=3.200pt]
\path[draw=black,fill=cff8080,line join=round,even odd rule,line cap=butt,miter
limit=4.00,line width=3.200pt] (91.0455,165.7194) rectangle
(250.7252,347.8104);
\path[draw=black,line join=round,even odd rule,line cap=butt,miter
limit=4.00,line width=3.200pt] (168.0839,258.1656) .. controls
(169.6992,260.2725) and (166.0408,261.3824) .. (164.5822,260.8503) .. controls
(160.6293,259.4083) and (160.6636,254.1057) .. (162.7146,251.1621) .. controls
(166.3833,245.8967) and (174.0594,246.2369) .. (178.5892,250.1116) .. controls
(185.2369,255.7979) and (184.5602,266.1224) .. (178.8226,272.1726) .. controls
(171.1753,280.2366) and (158.1221,279.2067) .. (150.5752,271.5890) .. controls
(141.0782,262.0028) and (142.4690,246.1872) .. (151.9759,237.1551) .. controls
(163.4900,226.2161) and (182.0854,227.9716) .. (192.5962,239.3729) .. controls
(204.9828,252.8090) and (202.8604,274.1941) .. (189.5613,286.1796) .. controls
(174.2071,300.0173) and (150.0257,297.5267) .. (136.5682,282.3277) .. controls
(121.2770,265.0577) and (124.1368,238.0757) .. (141.2372,223.1481) .. controls
(160.4213,206.4017) and (190.2069,209.6312) .. (206.6032,228.6342) .. controls
(224.8061,249.7311) and (221.2064,282.3227) .. (200.3000,300.1866);
\end{scope}
\end{tikzpicture}
\end{document}
\end{filecontents*} %%% tex file for image ends
% compile with pdflatex
\immediate\write18{pdflatex image}
% convert to PNG
\makeatletter
\immediate\write18{convert -density 500 -alpha on image.pdf image.png}
\makeatother
%
\begin{document}
\includegraphics[width=5cm]{image} %%% insert .png file
\end{document}
This assumes that you have imagemagick installed.
Best Answer
This was a known bug in the Inkscape pdf export (which is used by the
svg
package), see https://gitlab.com/inkscape/inkscape/-/issues/1984. The issue has been fixed in Inkscape itself (see https://gitlab.com/marcjeanmougin/inkscape/-/commit/9b5de7815fcd93c2801c7fb8703491125ef906b5) so at some point this will probably be picked up by Overleaf and the svg will render correctly.In the meantime the bug report also provided a workaround: replace all instances of
context-stroke
in the SVG source by a fixed color, for example#000000
(black). In your SVG there were eight instances. I replaced them below:Then the conversion process does not crash anymore.
To make the LaTeX output a bit nicer I suggest to make the font small and sans serif:
Result:
To improve it further you can edit the SVG in Inkscape to center the labels, or even to export to a PDF directly from Inkscape and include the PDF with
\includegraphics
instead of the conversion with thesvg
package, then you have more control over the result.Note: I think the second node should be labeled Arduino and not Ardunino.