简体   繁体   中英

How to use wildcard * with graphicspath in LaTeX?

如何获得通配符,例如以下代码?

\graphicspath{{1/*/pictures/}}

You can't use wildcards with \\graphicspath . You'll have to be explicit:

\graphicspath{{1/pictures/}{2/pictures/}{3/pictures/}{...etc...}}

I found the LaTeX Wikibook a few months ago. It's a good reference for getting started.

It is true that wildcards can't be used within the \\graphicspath command. However, you can use a workaround based on a bash script if you are running a Unix based OS.

In your example, you can create a script named myGraphicspath.sh :

#!/bin/bash

PATH="./1/*/pictures"

echo -n \\graphicspath{{./}

for i in $PATH; do
    echo -n \{$i/\}
done

echo \}

Put that script in the same folder as your .tex . Now, you can call that script from Latex. Where you would have placed the \\graphicspath command, now you type:

\immediate\write18{./myGraphicspath.sh > myGraphicspath.tex}
\input{myGraphicspath.tex}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM