我创建了一个 switch,当且仅当新几何体应该是双面时才定义。目前,我的代码如下所示:
\ifdefined\@TwosideSwitch%
\typeout{SwitchGiven!}%
\newgeometry{twoside=true, ...}%
\else%
\typeout{Undefined!}%
\newgeometry{twoside=false, ...}%
\fi%
其中...
是关于几何的相同大块选项。这可行,但为了一致性和美观性,我希望它看起来更像这样:
\someMagicWith{\@TwosideSwitch}%
\newgeometry{\applyTwosideAccordingly, ...}%
我试过:
\ifdefined\@TwosideSwitch%
\def\@Twoside{true}%
\else%
\def\@Twoside{false}%
\fi%
\newgeometry{twoside=\@Twoside, ...}%
但显然 geometry 讨厌布尔值的宏。使用现有文档,我发现指定的“twoside”是通过设置另外两个开关来实现的,但这对我来说也不起作用:
\ifdefined\@TwosideSwitch%
\@twosidetrue\@mparswitchtrue%
\else%
\@twosidefalse\@mparswitchfalse%
\fi%
\newgeometry{...}%
这里有专家吗?:)
回答:
太美了!正如@ChristianHupfer 指出的那样,J.Wright写道:
因此,您需要存储键和值并预先扩展:
\def\myvariable{valid-key-name=some-valid-input} \expandafter\KeySettingCommand\expandafter{\myvariable}
所以这可以归结为
\ifdefined\@TwosideSwitch%
\def\@Twoside{twoside=true}%
\else%
\def\@Twoside{twoside=false}%
\fi%
\expandafter\newgeometry%
\expandafter{\@Twoside, ...}%
或更短
\def\@Twoside{twoside=false}%
\ifdefined\@TwosideSwitch%
\def\@Twoside{twoside=true}%
\fi%
\expandafter\newgeometry\expandafter{\@Twoside, ...}%