I'm using the following code:


%\newcommand{\underscorefix}[1]{\StrSubstitute{#1}{_}{\_}} <-- not working

How can I replace the underscore with backslash underscore for the ucfilespec option?

The reason for that is that I would like to have a command like that:

  • 2
    Please provide complete MWE. Also, when you say it is "not working," do you mean that compile halts with an error, or that it hangs indefinitely, or that it produces an unexpected result? – user139954 Apr 11 '18 at 15:28
  • 1
    Do you need to escape the underscore? I made an experiment passing name_1.dat to the ucfilespec key and I get this in the (uncompressed) PDF file: <</Type/Filespec/F(name_1.dat)/UF(name_1.dat)/EF<</F 1 0 R>>>> – egreg Apr 11 '18 at 22:21

Setting the stringmethod=escape option for \embedfile solved the problem.

Complete code:


Now the filespec and the ucfilespec contains underlines. Before just the filespec.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.