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}