\ifnum\ltjgetparameter{direction}=3%
\define@key{Gm}{hdivide}{\Gm@parse@divide{#1}{tmargin}{width}{bmargin}}%
\define@key{Gm}{vdivide}{\Gm@parse@divide{#1}{rmargin}{height}{lmargin}}%
-\define@key{Gm}{divide}{\Gm@parse@divide{#1}{lmargin}{width}{rmargin}%
+\define@key{Gm}{divide}{\Gm@parse@divide{#1}{tmargin}{width}{bmargin}%
\Gm@parse@divide{#1}{rmargin}{height}{lmargin}}%
\define@key{Gm}{hmargin}{\Gm@branch{#1}{tmargin}{bmargin}}%
\define@key{Gm}{vmargin}{\Gm@branch{#1}{rmargin}{lmargin}}%
\ifx\Gm@bmargin\@undefined\else\advance\@tempcnta1\relax\fi
\Gm@cnth\@tempcnta
\else
- \ifx\Gm@lmargin\@undefined\else\advance\@tempcnta4\relax\fi
+ \ifx\Gm@rmargin\@undefined\else\advance\@tempcnta4\relax\fi
\ifGm@vbody\advance\@tempcnta2\relax\fi
- \ifx\Gm@rmargin\@undefined\else\advance\@tempcnta1\relax\fi
+ \ifx\Gm@lmargin\@undefined\else\advance\@tempcnta1\relax\fi
\Gm@cntv\@tempcnta
\fi
\ifcase\@tempcnta
^^J\@spaces `#2' (\@nameuse{Gm@#2}) is ignored}%
\Gm@detiv{#2}{#3}{#4}{#2}%
\else\fi}%
+\def\Gm@clean{%
+ \ifnum\Gm@cnth<4\let\Gm@tmargin\@undefined\fi
+ \ifodd\Gm@cnth\else\let\Gm@bmargin\@undefined\fi
+ \ifnum\Gm@cntv<4\let\Gm@rmargin\@undefined\fi
+ \ifodd\Gm@cntv\else\let\Gm@lmargin\@undefined\fi
+ \ifGm@hbody\else
+ \let\Gm@hscale\@undefined
+ \let\Gm@width\@undefined
+ \let\Gm@textwidth\@undefined
+ \fi
+ \ifGm@vbody\else
+ \let\Gm@vscale\@undefined
+ \let\Gm@height\@undefined
+ \let\Gm@textheight\@undefined
+ \fi
+ }%
\def\Gm@adjustpaper{%
\ifdim\paperwidth>\p@\else
\PackageError{geometry}{%
\Gm@adjustmp
\Gm@adjustbody
\Gm@detall{h}{width}{tmargin}{bmargin}%
- \Gm@detall{v}{height}{lmargin}{rmargin}%
+ \Gm@detall{v}{height}{rmargin}{lmargin}%
\setlength\textwidth{\Gm@width}%
\setlength\textheight{\Gm@height}%
\setlength\topmargin{\Gm@tmargin}%