svg package \includesvg with underscores in svg

To my amazement it was as easy as changing \includesvg[pretex=\escapeus]{mysvgfile} to \escapeus{\includesvg{mysvgfile}}.

\escapeus expects to be passed some TeX as #1, on which it operates to remove the underscores. You can see by feeding it an empty argument {} that the errors above are removed, only to be replaced by the original error when the underscore is encountered. However the \escapeus command can handle being passed the entire result of the \includesvg command.


You can also use the parameter inkscapelatex=false. This will tell LaTeX not to render the text.

So this should work:

\documentclass{article}
\usepackage{svg}

\begin{document}

\begin{figure}
    \centering
    \includesvg[inkscapelatex=false, width=\linewidth]{pic}
    \caption{caption}
    \label{img:label}
\end{figure}

\end{document}

Source: package documentation