On September 3, 2003 05:09 pm, Angus Leeming wrote:
> Johnathan Burchill wrote:
> > It seems LaTeX has a problem with doesn't like filenames with "_" in
> > them when you pass the filename through the newcommand. Latex wants to
> > put $ $ around the _ because that is the "subscript" command in math
> > mode. So you could get around this with code like:
>
> [details elided]
>
> > You have access to the basename of the pstex_t file, right?
>
> Right, but its pretty standard to have file names with underscores:
>
> \begin{center}\xfiginput{q13_graph}\end{center}
>
> Unfortunately, I can't use \verb in a command argument...
> \verb|q13_graph.pstex_t|
Oh, I see.
\includegraphics[draft]{filename} prints the filename instead of the
figure, so there is obviously a way to print arbitrary characters in a
verbatim way, without using verbatim.
This works, it's based on \includegraphics[draft] from
graphics/graphics.sty:
<preamble>
\def\stripprefix#1>{}
\newcommand*{\xfiginput}[1]{%
\edef\tempfilename{#1}%
\InputIfFileExists{#1}{}{%
\fbox{Could not find file
\ttfamily\expandafter\stripprefix\meaning\tempfilename
!}}}
</preamble>
That was fun.
JB
--
Johnathan K. Burchill, Ph.D.
Department of Physics and Astronomy
University of Calgary
2500 University Drive N.W.
Calgary, AB T2N 1N4
Canada
(403) 217-4286
[EMAIL PROTECTED]