Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have several plots saved as .pdf in a folder and I would like to know if there is a way of adding all of them in a document at once, without typing the path to each file.

share|improve this question
2  
short answer no, longer answer, if you are prepared to allow latex to escape to the shell and run system commands, and don't mind your document being system dependent you could get it to run ls *.pdf(or whatever is needed) and construct the list. (or you could just do this before starting latex) –  David Carlisle Feb 18 at 17:39
add comment

1 Answer 1

up vote 9 down vote accepted

It is best to do this externally to latex (although you can use the shell-escape (write18) feature to execute the commands from within latex if you want.

I'll assume bash syntax but other command line systems can do similar.

Suppose you have a directory/folder img with three pdf files

$ ls img
a.pdf  b.pdf  other.pdf

and you want to include them in alphabetic order (or any other order you can achieve by using arguments to ls or some other command)

then executing

ls img/*.pdf | sed -e "s/.*/\\\\includegraphics{\\0}/" > img/imglist.tex

would leave a file img/imglist.tex that looks like

\includegraphics{img/a.pdf}
\includegraphics{img/b.pdf}
\includegraphics{img/other.pdf}

so you just need \input{img/imglist} in your main file, and arrange to regenerate imglist.tex every time you update the image directory (or every time you run latex).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.