I am defining a new command, where the input contains backslash, which is to be removed later, hence I am searching for a way to accomplish that. The following example removes backslash when it is in-front of the string, but fails when the slash is in-between a string.
\documentclass{article}
\makeatletter
\newcommand{\removeabs}[1]{%
\ifcat\relax\noexpand#1%
\expandafter\expandafter\expandafter\@gobble\expandafter\string
\fi
#1%
}
\makeatother
\begin{document}
\removeabs{\the slash is removed here}
\removeabs{but not \here}
\end{document}
Does anybody know how to remove the backslash, even if it is in-between a string ?
Why I need this: I am using pythontex to create a_file.tex, which is to be included to the main.tex, and both steps are done using a single new command of form \command{parameters}, where the argument parameters are options to be used inside the pythoncode, as well as the name of the tex file created (a_file.tex). The issue comes when parameters contain slashes,hyphens etc (usual in my case), which are not even allowed as filenames in Windows OS, hence need to be stripped in pythontex code (to save as a file) and in latex (to read the file). An example would be:
\newcommand{\mycommand}[1]{
\begin{pycode}
plot[#1] %Pseudo line
save[#1.tex] %Pseudo line
\end{pycode}
\input{#1.tex}}