4

This is my foo.sty package:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{foo}
\usepackage{pgfopts}
\pgfkeys{
  /foo/.cd,
  anonymous/.store in=\fooanon,
}
\ProcessPgfOptions{/foo}
\endinput

This is the document:

\documentclass[anonymous]{acmart}
\usepackage{./foo}
\begin{document}
\ifdefined\fooanon YES \else NO \fi
\end{document}

It prints YES, while I didn't provide the anonymous option to my package. Somehow it took it from the list of options I provided to the acmart class. Why and how to get rid of this "side effect"?

yegor256
  • 12,021

1 Answers1

6

Like the standard \ProcessOptions command, \ProcessPgfOptions treats the optional argument to \documentclass as containing global options. It therefore examines those as well as package-specific ones. (This is the way for example draft is propagated from the global option list to graphics, etc.) If you want to examine only the list explicitly given for the package, use \ProcessPgfPackageOptions.

yegor256
  • 12,021
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036