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}
\paperwidthis standard....geometrydoesn't support changing the paper size mid-document. Does KOMA support this? Note that mixing KOMA config withgeometrylike this is asking for trouble really. You can ignore KOMA's config and usegeometry, but mixing them seems like a recipe for problems.... – cfr Jun 19 '15 at 19:25\pdfpagewidth(andheight) or\KOMAoptions. If one is using DIV-style margins, he or she is good to go withDIV=current. If one is usinggeometryto 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