How can I conditionally load tikz and draw a TikZ diagram only when preview is not loaded, i.e., AUCTeX is not generating images for other things (e.g., mathematical formulas)?
MWE:
\documentclass{amsart}
\usepackage{tikz} %*
\begin{document}
\[ a^2 + b^2 = c^2 \]
\begin{figure}[htbp]
\begin{tikzpicture} %*
\draw (0, 0) -- (1, 1); %*
\end{tikzpicture} %*
\end{figure}
\end{document}
I'd like to exclude the lines with %* when AUCTeX generates images.
Addendum: AUCTeX loads preview by using \AtBeginDocument, like this:
latex -ini -interaction=nonstopmode "&latex" prv_hoge.ini "\nonstopmode\nofiles\PassOptionsToPackage{active,tightpage,auctex}{preview}\AtBeginDocument{\ifx\ifPreview\undefined\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\fi}" "\input" mwe.tex
So branching by using \@ifpackageloaded in the preamble doesn't quite work. What's an alternative?