The geometry package:

Package lengths are not saved as lengths.

  • Examples: layoutheight, tmargin

The following only affect the complete layout:

  • \savegeometry
  • \loadgeometry
  • \restoregeometry

Question 1

Is it possible to set the package such that
lengths which are not native to Latex may be called?

  • Examples: \layoutheight, \tmargin

Question 2

Is it possible to elegantly save/load/restore specific geometry options only?
Similar to \newgeometry{<options>}?

  • \savegeometry[<options>]{name}
  • \loadgeometry[<options>]{name}
  • \restoregeometry[<options>]

Alternative: [\newlength --> setlength Method]

A method exists which creates the lengths and uses them recursively.
I demonstrate this below in the MWE.

It is not entirely elegant.

I wish I could, in the preamble:

% or
\savegeometry[vmargin, hmargin]{originalMargins}

Then, after changing the page size mid-document,

\loadgeometry[vmargin, hmargin]{original}
% or
% or especially (without the need to \save):
\restoregeometry[vmargin, hmargin]



\usepackage{geometry}                   % margin/page layout settings
\usepackage{scrlayer-scrpage}           % improved header commands. [supercedes `fancyhdr' package].

% Margin Settings:
\newlength{\xhmargin   } \setlength{\xhmargin   }{0.750in}
\newlength{\xtmargin   } \setlength{\xtmargin   }{0.750in}
\newlength{\xbmargin   } \setlength{\xbmargin   }{1.000in}
\newlength{\xheadheight} \setlength{\xheadheight}{2.700em}
\newlength{\xheadsep   } \setlength{\xheadsep   }{0.150in}
\newlength{\xfootheight} \setlength{\xfootheight}{2.700em}
\newlength{\xfootskip  } \setlength{\xfootskip  }{0.800in}

\KOMAoptions{headheight = \xheadheight , 
             footheight = \xfootheight , 
             DIV        = current      }

\geometry{letterpaper                ,
          hmargin      = \xhmargin   ,
          tmargin      = \xtmargin   ,
          bmargin      = \xbmargin   ,
          headsep      = \xheadsep   ,
          footskip     = \xfootskip  }

%Initialize headers and footers
\chead{\normalfont Header 1 \\ Header 2}
\cfoot{\normalfont Footer 1 \\ Footer 2}
\ofoot{\normalfont Page \thepage}




%\pdfpagewidth  = 11.0in     % [\pdfpagewidth and \pdfpageheight are superceded by KOMAoptions].
%\pdfpageheight = 17.0in
\KOMAoptions{paper      = 11in:17in    ,
             pagesize                  ,
             headheight = \xheadheight , 
             footheight = \xfootheight , 
             DIV        = current      }
%\restoregeometry            % [cannot be used: restores letterpaper also.]
\newgeometry{layoutwidth  = 11.00in,
             layoutheight = 17.00in, 
             hmargin      = \xhmargin   ,
             tmargin      = \xtmargin   ,
             bmargin      = \xbmargin   ,
             headsep      = \xheadsep   ,
             footskip     = \xfootskip  }






%\pdfpagewidth  = 08.5in     % [\pdfpagewidth and \pdfpageheight are superceded by KOMAoptions].
%\pdfpageheight = 11.0in
\KOMAoptions{paper = 8.5in:11in,
             pagesize          ,
             DIV=current       }



  • 1
    \paperwidth is standard.... geometry doesn't support changing the paper size mid-document. Does KOMA support this? Note that mixing KOMA config with geometry like this is asking for trouble really. You can ignore KOMA's config and use geometry, but mixing them seems like a recipe for problems.... – cfr Jun 19 '15 at 19:25
  • Oop. I'll edit the paperwidth out. As for the KOMA, MScharrer is all about it. He posts this solution everywhere: tex.stackexchange.com/questions/6834/… @MartinScharrer. – kando Jun 19 '15 at 19:56
  • KOMA aside, I put the alternative in, to keep this geometry focused : j [Unless you know of a method to set custom margins in KOMA - despite every attempt KOMA is making to get me to use its default margins.] – kando Jun 19 '15 at 19:59
  • I am interested in the background, why do you want to do this? Maybe How remove margin in a paragraph that continues in two pages with different margin? and Italic or font change for a whole section can be of help for your use case? – Johannes_B Jun 19 '15 at 20:23
  • I don't advice you to use this unless you know (deeply) what you do. – touhami Jun 20 '15 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.