Unfortunately, I cannot write a better title for the question.
I am trying to parametrize my workflow, where I will allow myself to override page margins from the command line with the following:
xelatex "\newcommand{\mygeometry}{margin=2cm}\input{myfile.tex}"
Where in myfile.tex I have the defaults and actual application using \newgeometry command:
\providecommand{\mygeometry}{margin=3cm}
% ...
\newgeometry{\mygeometry}
I get the following error when trying to process this:
! Package xkeyval Error: `margin=2cm' undefined in families `Gm'.
As I understand, geometry uses xkeyval to parse arguments in its command set, and the kind of constructs like \newgeometry{\myargs} do not work as intended, because the value of \myargs is somehow not parsed by xkeyval, instead being understood verbatim, with = sign not having any effect, i.e. being interpreted as part of the argument(s).
How can I fix this? I would like to pass custom geometry to my .tex from command line, this has to do with me needing to produce different versions of the layout for different intentions.
Everything works if I simply use \newgeometry{margin=2cm}, i.e. substitute the value myself in the file.
\expandafter\newgeometry\expandafter{\mygeometry}fix it? – Steven B. Segletes Apr 14 '14 at 13:21\typeinvariables in conjunction with a Makefile can help also. – Apr 14 '14 at 13:28