6

How to check if a specific package is used by a LaTeX document. For example in the below document (intentionally written in an ugly but technically correct format), the packages fontenc, inputenc, csquotes, babel, libertine, amsmath, biblatex, filecontents, tikz are used but lettrine, cleveref, tocloft are not used (because they are in a comment area).

    \documentclass[ngerman]{article}
    \usepackage[T1]{fontenc, 
    %babel,
    }
    %\usepackage{cleveref}
    \usepackage
[utf8
]
{inputenc}
    \usepackage{babel, csquotes

    tikz, 
               % lettrine
    amsmath,libertine
    }

    \usepackage[backend=biber, style=authortitle]{biblatex} 
    \usepackage
    {
    filecontents,

    %tocloft}
    }


    \begin{document}

    \end{document}

1 Answer 1

6

You should look into TeX-active-styles variable. For this document its value is

("url" "ifthen" "logreq" "kvoptions" "keyval" "etoolbox" "biblatex"
 "libertine" "amsopn" "amsbsy" "amstext" "amsmath" "tikz" "csquotes"
 "ngerman" "babel" "" "fontenc" "art10" "article" "latex2e" "z"
 "LATEX")

Then the function you should use is member:

(member "fontenc" TeX-active-styles)

This is the same check you should do for classes (see also this question).

In addition, if you want to check whether a certain option has been passed to package there is LaTeX-provided-package-options-member

(LaTeX-provided-package-options-member "fontenc" "T1")
1
  • Thank you very much for mentioning TeX-active-styles. I found it very useful variable. This correctly answers the question without using regular expressions.
    – Name
    Sep 7, 2015 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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