I would like to be able to detect if the standalone
package was used with [preview=false]
or [preview=true]
. Not too concerned if this setting was a default or user defined.
Based on How can one undefine an already processed class option?, the macro @classoptionslist
is supposed to be a comma separated list of options passed to the class. I attempted to detect if this macro had the string preview=true
in it, but this does not yield the correct results. The following always prints Package Option: [preview=false]
.
\documentclass[preview=true]{standalone}% Does not work
%\documentclass[preview=false]{standalone}% works
\usepackage{xstring}
\makeatletter%
\newcommand*{\DetectPreviewOption}{%
\IfSubStr{@classoptionslist}{preview=true}{true}{false}%
}%
\makeatother%
\begin{document}
Package Option: [preview=\DetectPreviewOption].
\end{document}
\newcommand*{\DetectPreviewOption}{% \ifsa@preview\relax true\else false\fi% }%
isn't the right one?@classoptionslist
in the 7th line of your example, that should then be:\IfSubStr{\@classoptionslist}{preview=true}{true}{false}%
?@classoptionslist
.\@classoptionslist
(not@classoptionslist
).