# Input of pdf_tex error with usepackage{underscore} input

i have a problem i now solved by myself. It took some days, so i want to pretend others to make the same fault.

I want to input a .pdf and .pdf_tex file from Inkscape into Latex an compile it with pdflatex. Therefore i use the \input command. But there is this erreor message:

"! Missing \endcsname inserted. \unhbox l.15 \input{Belastungsart2.pdf_tex}? "

Here is the Code:

\documentclass[
final               % Status des Dokuments (draft-> nur Rahmen der Bilder)
]{scrreprt}

\usepackage[T1]{fontenc}                    % T1 Schriftcodierung
\usepackage[ngerman]{babel}             % deutsche Silbentrennung einbinden
\usepackage[utf8]{inputenc}             % deutsche Umlaute erkennen und darstellen
\usepackage{color}

\usepackage{underscore}                     %Unterstrich im Text als Unterstrich machen

\begin{document}

\input{Belastungsart2.pdf_tex}
\end{document}


The content of "Belastungsart2.pdf_tex" is this one:


\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}%
\newcommand*\fsize{\dimexpr\f@size pt\relax}%
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}%
\ifx\svgwidth\undefined%
\setlength{\unitlength}{260.95278915bp}%
\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.23962115)%
\lineheight{1}%
\setlength\tabcolsep{0pt}%
\put(0.49704523,0.1373812){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}$\sigma$\end{tabular}}}}%
\put(0.59934306,0.14224841){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}$\gamma$\end{tabular}}}}%
\put(0.60374442,0.09517703){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}$\tau$\end{tabular}}}}%
\end{picture}%
\endgroup%


Sorry, but I couldnt minimize the content of the .pdf_tex file. When i comment out the \usepackage{underscore} command, everything is working fine. No error message at all. When i paste the content of Belastungsart.pdf_tex into the main-code everything is working fine. When i rename the .pdf_tex file to an .tex file, everything is working fine.

Is there a way to use the package underscore and place the \input{.pdf_tex} in Latex at the same time?

Thanks for help Nelson

This issue is described in the manual of the underscore package.

You code contains the command \input{Belastungsart2.pdf_tex}. This command contains an underscore character, which causes the input to fail because the underscore package changes the interpretation of this character. As mentioned in the manual, it works if you explicitly state that this underscore is a literal underscore, using the \string command.

MWE:

\documentclass[
final               % Status des Dokuments (draft-> nur Rahmen der Bilder)
]{scrreprt}

\usepackage[T1]{fontenc}                    % T1 Schriftcodierung
\usepackage[ngerman]{babel}             % deutsche Silbentrennung einbinden
\usepackage[utf8]{inputenc}             % deutsche Umlaute erkennen und darstellen
\usepackage{color}

\usepackage{underscore}                     %Unterstrich im Text als Unterstrich machen

\begin{document}

\input{Belastungsart2.pdf\string_tex}
\end{document}


Another possible solution, also mentioned in the manual, is to use \usepackage[strings]{underscore}. With that option you can use underscores as normal in file names, so \input{Belastungsart2.pdf_tex} will work. However, this is more risky, because the option will modify a lot of internal code, which may cause other problems. Therefore, if you only have a few underscores for filenames etc, it is probably better to use the \string solution.

• Thank you Marijn. That was a very fast answer. I also read the underscore-package manual afterwards, but I didnt get it. Your first solution with \input{Belastungsart2.pdf\string_tex} works fine for me. The \usepackage[string]{underscore}-Soution create failures on my computer. Nov 27, 2020 at 14:56
• @Nelson maybe you forgot the s - it is \usepackage[strings]{underscore}, not \usepackage[string]{underscore} as you wrote in your comment. Nov 27, 2020 at 15:11
• Thats the point, thank you very much Nov 30, 2020 at 8:07