使用通用方法評估全域文件選項

使用通用方法評估全域文件選項

我正在尋找一種輕鬆定義和評估其他全域文件選項的方法。

現在我正在使用

\documentclass[12pt,ngerman]{scrartcl}

作為我的文件的第一行,我想添加更多變量,例如boardor management,稍後使用類似的開關\ifoption{management}{then text}{else text}

我找到了Heiko Oberdiek 的包,它實現了和選項ifdraft所需的行為,並且能夠調整變數的 if :draftfinalstate

\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}

有沒有辦法概括這一點?例如,透過簡單地定義一個命令\newglobal{state}並將其餘命令封裝在一個套件中?

相關內容