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 am writing a program, and I want it to do different things depending on which LaTeX packages have been installed. My current solution is to automatically generate simple .tex files that \usepackage the packages I care about and then automatically check if pdflatex can compile them or not. This solution seems slow and fragile. What is a better solution?

Edit: The program I am writing is in Python.

share|improve this question
Sorry, you want to check this from a program/script and not from inside a LaTeX document? The latter would be shown in Conditional “if a package is available”. –  Martin Scharrer Oct 17 '11 at 18:33
See also Generate list of all installed (La)TeX files which has a similar background, i.e. a script which wants to get a list of all installed LaTeX packages. In your case you would just need to check that list. However, this is platform and probably LaTeX distribution dependent. –  Martin Scharrer Oct 17 '11 at 19:11

1 Answer 1

up vote 11 down vote accepted

Do you want to detect from inside LaTeX? If so, there is


If you're external, there is kpsewhich foobar.sty, which gives you the path to the foobar.sty that latex would use.

share|improve this answer

Your Answer


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.