I am developing a complex system that does a bunch of things with included PDFs. So complicated that I want to define a macro. Unfortunately, many of my users have filenames that have spaces and underbars in them. I haven't been able to figure out how to create a macro that runs \includepdf with the filename as a macro that allows files that include spaces.
That is, I want to get this program to work:
\documentclass[10pt]{book}
\usepackage{pdfpages}
\newcommand{\mycommand}[1]{
Including file: #1 (on next page).
\clearpage
\includepdf{#1}
}
\begin{document}
\mycommand{demo_include1.pdf}
\end{document}
But the errors I get are:
! Missing $ inserted.
<inserted text>
$
l.11 \mycommand{demo_include1.pdf}
? ^D
! Emergency stop.
<inserted text>
$
l.11 \mycommand{demo_include1.pdf}
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on d.log.
So how do I fix my LaTeX file?
\clearpage. Maybe it only works for images, though. – cfr Feb 18 '17 at 03:53fontenc. – cfr Feb 18 '17 at 03:56Including file: #1 (on next page).when the#1has an underscore in it. – jon Feb 18 '17 at 03:57