File name with an underscore looks like it gets split in IfFileExists,

David Carlisle d.p.carlisle at gmail.com
Sun Nov 7 17:15:17 CET 2021


to test if pmg_ratios.svg exists you need  the argument pmg_ratios.svg
not pmg\_ratios.svg but you are also typesetting the filename (assuming the
non standard command \bf is defined) the _ will generate an error as it is
a math subscript.

You can use   \textbf{\detokenize{ pmg_ratios.svg}} \IfFileExists{
pmg_ratios.sv}{yes}{no} to make the tokens safe for typesetting in text
mode.


On Sun, 7 Nov 2021 at 16:00, Mike Marchywka <marchywka at hotmail.com> wrote:

> In an earlier email exchange someone
> suggested  IfFileExists
> to get a file name in the fls file without including it in the output
> document,
>
> This seems to work well and I created a command to do that,
>
> % for archiving and file list
> \newcommand{\mjmusesitem}[2]{
>
> \item {\bf #1 } : 1 is #1 and 2 is  #2 xxx
> \IfFileExists{#1}{}{{\bf not found} }
>
> } % mjmuses
>
> However, when there is an underscore in the file the result seems odd.
> For example,
>
> \mjmusesitem{./keep/violinxxx.svg}{ Original scalable artwork }
> \mjmusesitem{./keep/kmboth.svg}{ Original scalable artwork }
> \mjmusesitem{./keep/pmg\_ratios.svg}{ Original scalable artwork }
> %\mjmusesitem{./keep/pmg_ratios.svg}{ Original scalable artwork }
> \mjmusesitem{./keep/r1vr2na.svg}{ Original scalable artwork }
> \mjmusesitem{./keep/r1vr2.svg}{ Original scalable artwork }
> \mjmusesitem{./keep/pmg\_ratio.svg}{ Original scalable artwork }
>
> produces this output, note the stray "ratios.svg" appearing twice,
>
> 5. ./keep/violinxxx.svg : 1 is ./keep/violinxxx.svg and 2 is Original
> scalable artwork xxx
> 6. ./keep/kmboth.svg : 1 is ./keep/kmboth.svg and 2 is Original scalable
> artwork xxx
> 7. ./keep/pmg ratios.svg : 1 is ./keep/pmg ratios.svg and 2 is Original
> scalable artwork xxx ratios.svg not
> found
> 8. ./keep/r1vr2na.svg : 1 is ./keep/r1vr2na.svg and 2 is Original scalable
> artwork xxx
> 9. ./keep/r1vr2.svg : 1 is ./keep/r1vr2.svg and 2 is Original scalable
> artwork xxx
> 10. ./keep/pmg ratio.svg : 1 is ./keep/pmg ratio.svg and 2 is Original
> scalable artwork xxx ratio.svg not
> found
>
> Any idea what is going on here?
>
> Thanks.
>
>
>
>  Mike Marchywka
> 306 Charles Cox Drive
> Canton, GA 30115
> 470-758-0799
> 404-788-1216
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20211107/ad88a4c9/attachment.html>


More information about the texhax mailing list.