I am trying to make a command that looks like this:

        scale = 0.7,
        pagecommand = 

such that


includes the pdf and prints the filename on top of the page.

I get the error File ended while scanning use of \@xverbatim. I also tried it without the verbatim:

\newcommand{\pdf}[1]{\includepdf[scale=0.7,pagecommand= #1 ]{#1}}

This displays the pdf correctly, but when the filename has an underscore (eg test_file.pdf), I get errors Missing $ inserted and the filename is not displayed correctly. How can I fix this?

  • 4
    You can't use verbatim as the argument to another command. What you need is \texttt{\detokenize{#1}}. – egreg Dec 5 '16 at 13:40
  • @egreg An answer? – Henri Menke Dec 5 '16 at 15:59

verbatim, like \verb, cannot be used in the argument to another command.

What you seem to need is just


so the underscore becomes printable:

    scale = 0.7,
    pagecommand = \texttt{\detokenize{#1}},

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.