I created a switch which is defined iff a new geometry should be twosided. Currently, my code looks like this:
\ifdefined\@TwosideSwitch%
\typeout{SwitchGiven!}%
\newgeometry{twoside=true, ...}%
\else%
\typeout{Undefined!}%
\newgeometry{twoside=false, ...}%
\fi%
where ...
are identical big chunks of options regarding geometry. This works, but for the sake of consistency and beauty, I want it to look more like this:
\someMagicWith{\@TwosideSwitch}%
\newgeometry{\applyTwosideAccordingly, ...}%
I tried:
\ifdefined\@TwosideSwitch%
\def\@Twoside{true}%
\else%
\def\@Twoside{false}%
\fi%
\newgeometry{twoside=\@Twoside, ...}%
But apparently geometry hates macros for boolean values. Using the available documentation I discovered a specified "twoside" is implemented as setting two other switches, but that does not work for me either:
\ifdefined\@TwosideSwitch%
\@twosidetrue\@mparswitchtrue%
\else%
\@twosidefalse\@mparswitchfalse%
\fi%
\newgeometry{...}%
Any experts here? :)
ANSWER:
Beautiful! As @ChristianHupfer pointed out, J.Wright wrote:
As a result, you need to either store both the key and value and pre-expand:
\def\myvariable{valid-key-name=some-valid-input} \expandafter\KeySettingCommand\expandafter{\myvariable}
So this boils down to
\ifdefined\@TwosideSwitch%
\def\@Twoside{twoside=true}%
\else%
\def\@Twoside{twoside=false}%
\fi%
\expandafter\newgeometry%
\expandafter{\@Twoside, ...}%
or shorter
\def\@Twoside{twoside=false}%
\ifdefined\@TwosideSwitch%
\def\@Twoside{twoside=true}%
\fi%
\expandafter\newgeometry\expandafter{\@Twoside, ...}%
xkeyval
keys, however,geometry
useskeyval
instead: Perhaps the solution by J. Wright might help: tex.stackexchange.com/questions/152020/… – user31729 Sep 16 '14 at 21:17\newif\ifSwitch
with\Switchtrue
and\Switchfalse
for setting your switches. – user30471 Sep 16 '14 at 21:18\gdef\mysides{twoside}
,gdef\mysides{oneside}
,\newgeometry{\mysides,...}
. [Untested as no MWE provided.] – cfr Sep 16 '14 at 22:17geometry
package suffice as an MWE, i didn't include one explicitly. I'll do so in every future post, though. @Christian Hupfer: This solved my problem, Answer is now added in Question. However I wonder if I should rather answer my own question using that; it seems to me that'd be your part (no metadiscussion intended) – LDericher Sep 16 '14 at 22:49