1

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:

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

Then, after changing the page size mid-document,

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

MWE

\documentclass{scrartcl}

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

% 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  }
%\usepackage{showframe}
\savegeometry{default}




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


\begin{document}
Original

\lipsum


\clearpage




%\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  }

Altered

\lipsum

\vspace{+4em}

\lipsum




\clearpage




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

Original

\lipsum

\end{document}
kando
  • 1,338
  • 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: http://tex.stackexchange.com/questions/6834/change-paper-size-in-mid-document @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 00:02
  • @Johannes_B : Currently, altering the page size mid-document can be accomplished with \pdfpagewidth (and height) or \KOMAoptions. If one is using DIV-style margins, he or she is good to go with DIV=current. If one is using geometry to set specific margins (please, hold your fire), he or she must reset the layout and the margins manually. This is inelegant, as layout lengths should have the option of easily being set to the current paper size lengths, and margin lengths should have the option of easily being set to the previous margin lengths (including the header/footer lengths). – kando Jun 22 '15 at 13:17
  • @Johannes_B : An additional issue with manual settings is that, should the user change the default margins later, each of the manual settings must be discovered and altered also, if consistency is desired. – kando Jun 22 '15 at 13:21

0 Answers0