14

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.

texpakc
  • 143

1 Answers1

19

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

\IfFileExists{foobar.sty}{true}{false}

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

  • Is kpsewhich available only if some TeX distribution is installed? I'm thinking to use it to test if there is TeX compiler installed. – Sigur Nov 05 '16 at 23:03
  • 1
    @Sigur: yes. You might get better results with trying to run which tex and checking the return code of that, assuming unix. – Ulrich Schwarz Nov 06 '16 at 06:53