12

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.

16

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 5 '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 6 '16 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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