I am looking for a way to easily define and evaluate additional global document options.
Right now I am using
\documentclass[12pt,ngerman]{scrartcl}
as the first line of my documents, I'd like to add more variables, for instance board or management and later use switches like \ifoption{management}{then text}{else text}
I have found the ifdraft package by Heiko Oberdiek which implements the desired behavior for draft and final options and was able to adjust if for the variable state:
\documentclass[state]{article}
\makeatletter
\newif\if@state
\newif\if@option@state
\DeclareOption{state}{%
\@statetrue
\@option@statetrue
}
\ProcessOptions*\relax
\newcommand*{\ifstate}{%
\if@state
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\makeatother
\begin{document}
\ifstate{State was set}{State was not set}
\end{document}
Is there a way to generalize this? For example by simply defining a command \newglobal{state} and encapsulating the rest in a package?
\ProcessOptionsshould belong in a class or package, not in a document. – egreg Sep 27 '14 at 10:30\newifis pretty flexible... – Bordaigorl Sep 27 '14 at 14:57