%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% % This is file 'changelayout.sty', version 0.1. % % % % This package can be used to change page and text layout on the fly, % % (ie, for specific pages, and, of course, for the entire document). % % It is an extension of Peter Wilson's 'changepage' package. % % % % Copyright (c) 2009 Ahmed Musa (a.musa@rocketmail.com). % % % % This work may be distributed and/or modified for commercial and % % non-commercial purposes. % % % % The LPPL maintenance status of this software is 'author-maintained'. % % % % This software is provided 'as it is', without warranty of any kind, % % either expressed or implied, including, but not limited to, the % % implied warranties of merchantability and fitness for a particular % % purpose. % %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% \ProvidesPackage{changelayout}[2009/06/25 v0.1 Change page layout on the fly] \NeedsTeXFormat{LaTeX2e} \RequirePackage{etoolbox} \RequirePackage{xkeyval} \newrobustcmd\cpl@warn[1]{\PackageWarningNoLine{changelayout}{#1}} \newrobustcmd\cpl@info[1]{\PackageInfo{changelayout}{#1\@gobble}} \newrobustcmd\cpl@err[1]{\PackageError{changelayout}{#1}{\@ehc}} \let\cpl@xp\expandafter \def\cpl@glet#1#2{\@ifdefinable#1{\global\let#1#2}} \@ifclassloaded{memoir}{% \cpl@err{This package can't be used with\MessageBreak memoir class. I've therefore exited} \cpl@xp\endinput% }{} \@ifpackageloaded{xcolor}{% \cpl@info{You've already loaded 'xcolor'\MessageBreak package with options that possibly\MessageBreak differ from my options.\MessageBreak I've not reloaded 'xcolor'} }{% \RequirePackage[dvipsnames*,svgnames*,x11names*,table,hyperref]{xcolor} \cpl@info{'xcolor' package loaded with\MessageBreak options 'dvipsnames*', 'svgnames*',\MessageBreak 'x11names*', 'table', 'hyperref'} } \AtEndPreamble{% \@ifpackageloaded{changepage}{% \cpl@err{This package is a replacement for\MessageBreak 'changepage' package.\MessageBreak It can't be used with 'changepage'} \cpl@xp\endinput% }{} } \newrobustcmd*\cpl@numdef[2]{% \ifstrempty{#2}{\cpl@err{You can't assign empty argument\MessageBreak to number}}{} \ifundef{#1}{\newcount#1\relax #1=\z@\relax}{}% #1=\numexpr#2\relax } \newrobustcmd*\cpl@csnumdef[1]{\cpl@xp\cpl@numdef\csname#1\endcsname} \newrobustcmd*\cpl@dimdef[2]{% \ifstrempty{#2}{\cpl@err{You can't assign empty argument\MessageBreak to dimension}}{} \ifundef{#1}{\newdimen#1\relax #1=\z@\relax}{}% #1=\dimexpr#2\relax } \newrobustcmd*\cpl@csdimdef[1]{\cpl@xp\cpl@dimdef\csname#1\endcsname} \newrobustcmd\cpl@changelayout{% \@colht=\textheight% \@colroom=\textheight% \vsize=\textheight% \columnwidth=\textwidth% \if@twocolumn \cpl@csdimdef{dimen@}{(\columnwidth-\columnsep)/2} \columnwidth=\dimen@% \@firstcolumntrue \fi \hsize=\columnwidth% \linewidth=\hsize% } \newrobustcmd\cpl@getdefaults{\begingroup \protected@edef\@tempa{\endgroup \noexpand\cpl@csdimdef{cpl@orig@paperwidth}{\paperwidth}% \noexpand\cpl@csdimdef{cpl@orig@paperheight}{\paperheight}% \noexpand\cpl@csdimdef{cpl@orig@textheight}{\textheight}% \noexpand\cpl@csdimdef{cpl@orig@textwidth}{\textwidth}% \noexpand\cpl@csdimdef{cpl@orig@oddsidemargin}{\oddsidemargin}% \noexpand\cpl@csdimdef{cpl@orig@evensidemargin}{\evensidemargin}% \noexpand\cpl@csdimdef{cpl@orig@topmargin}{\topmargin}% \noexpand\cpl@csdimdef{cpl@orig@headsep}{\headsep}% \noexpand\cpl@csdimdef{cpl@orig@headheight}{\headheight}% \noexpand\cpl@csdimdef{cpl@orig@footskip}{\footskip}% \noexpand\cpl@csdimdef{cpl@orig@footins}{\skip\footins}% \noexpand\cpl@csdimdef{cpl@orig@marginparwidth}{\marginparwidth}% \noexpand\cpl@csdimdef{cpl@orig@marginparsep}{\marginparsep}% \noexpand\cpl@csdimdef{cpl@orig@marginparpush}{\marginparpush}% \noexpand\cpl@csdimdef{cpl@orig@columnsep}{\columnsep}% \noexpand\cpl@csdimdef{cpl@orig@columnseprule}{\columnseprule}% \noexpand\cpl@csdimdef{cpl@orig@linewidth}{\linewidth}% \noexpand\cpl@csdimdef{cpl@orig@hoffset}{\hoffset}% \noexpand\cpl@csdimdef{cpl@orig@voffset}{\voffset}% \noexpand\cpl@csnumdef{cpl@orig@mag}{\mag}% }\@tempa% } \@onlypreamble\cpl@getdefaults\relax \AtEndPreamble{\cpl@getdefaults}% \long\def\cpl@print@defaultparams{% ^^J*******************************************************^^J% Original page layout dimensions and booleans^^J% (changelayout package)^^J% \string\paperwidth\space\space\the\cpl@orig@paperwidth^^J% \string\paperheight\space\space\the\cpl@orig@paperheight^^J% \string\textwidth\space\space\the\cpl@orig@textwidth^^J% \string\textheight\space\space\the\cpl@orig@textheight^^J% \string\oddsidemargin\space\space\the\cpl@orig@oddsidemargin^^J% \string\evensidemargin\space\space\the\cpl@orig@evensidemargin^^J% \string\topmargin\space\space\the\cpl@orig@topmargin^^J% \string\headheight\space\space\the\cpl@orig@headheight^^J% \string\headsep\space\space\the\cpl@orig@headsep^^J% \string\footskip\space\space\the\cpl@orig@footskip^^J% \string\marginparwidth\space\space\the\cpl@orig@marginparwidth^^J% \string\marginparsep\space\space\the\cpl@orig@marginparsep^^J% \string\columnsep\space\space\the\cpl@orig@columnsep^^J% \string\columnseprule\space\space\the\cpl@orig@columnseprule^^J% \string\skip\string\footins\space\space\the\cpl@orig@footins^^J% \string\hoffset\space\space\the\cpl@orig@hoffset^^J% \string\voffset\space\space\the\cpl@orig@voffset^^J% \string\mag\space\space\the\cpl@orig@mag^^J% \if@twocolumn\string\@twocolumntrue\space\fi% \if@twoside\string\@twosidetrue\space\fi% \if@mparswitch\string\@mparswitchtrue\space\fi% \if@reversemargin\string\@reversemargintrue\space\fi^^J% (1in=72.27pt, 1cm=28.45pt)^^J% *******************************************************^^J% }% \@onlypreamble\cpl@print@defaultparams\relax \long\def\cpl@print@finalparams{% ^^J+++++++++++++++++++++++++++++++++++++++++++++++++++++++^^J% Final page layout dimensions and booleans^^J% (changelayout package)^^J% \string\paperwidth\space\space\the\paperwidth^^J% \string\paperheight\space\space\the\paperheight^^J% \string\textwidth\space\space\the\textwidth^^J% \string\textheight\space\space\the\textheight^^J% \string\oddsidemargin\space\space\the\oddsidemargin^^J% \string\evensidemargin\space\space\the\evensidemargin^^J% \string\topmargin\space\space\the\topmargin^^J% \string\headheight\space\space\the\headheight^^J% \string\headsep\space\space\the\headsep^^J% \string\footskip\space\space\the\footskip^^J% \string\marginparwidth\space\space\the\marginparwidth^^J% \string\marginparsep\space\space\the\marginparsep^^J% \string\columnsep\space\space\the\columnsep^^J% \string\columnseprule\space\space\the\columnseprule^^J% \string\skip\string\footins\space\space\the\footins^^J% \string\hoffset\space\space\the\hoffset^^J% \string\voffset\space\space\the\voffset^^J% \string\mag\space\space\the\mag^^J% \if@twocolumn\string\@twocolumntrue\space\fi% \if@twoside\string\@twosidetrue\space\fi% \if@mparswitch\string\@mparswitchtrue\space\fi% \if@reversemargin\string\@reversemargintrue\space\fi^^J% (1in=72.27pt, 1cm=28.45pt)^^J% +++++++++++++++++++++++++++++++++++++++++++++++++++++++^^J% }% \newrobustcmd\cpl@backtodefaults{\begingroup \protected@edef\@tempa{\endgroup \noexpand\setlength{\paperwidth}{\cpl@orig@paperwidth}% \noexpand\setlength{\paperheight}{\cpl@orig@paperheight}% \noexpand\setlength{\textheight}{\cpl@orig@textheight}% \noexpand\setlength{\textwidth}{\cpl@orig@textwidth}% \noexpand\setlength{\linewidth}{\cpl@orig@linewidth}% \noexpand\setlength{\oddsidemargin}{\cpl@orig@oddsidemargin}% \noexpand\setlength{\evensidemargin}{\cpl@orig@evensidemargin}% \noexpand\setlength{\topmargin}{\cpl@orig@topmargin}% \noexpand\setlength{\headsep}{\cpl@orig@headsep}% \noexpand\setlength{\headheight}{\cpl@orig@headheight}% \noexpand\setlength{\footskip}{\cpl@orig@footskip}% \noexpand\setlength{\skip\footins}{\cpl@orig@footins}% \noexpand\setlength{\marginparwidth}{\cpl@orig@marginparwidth}% \noexpand\setlength{\marginparsep}{\cpl@orig@marginparsep}% \noexpand\setlength{\marginparpush}{\cpl@orig@marginparpush}% \noexpand\setlength{\columnsep}{\cpl@orig@columnsep}% \noexpand\setlength{\columnseprule}{\cpl@orig@columnseprule}% \noexpand\setlength{\hoffset}{\cpl@orig@hoffset}% \noexpand\setlength{\voffset}{\cpl@orig@voffset}% \noexpand\mag=\cpl@orig@mag% \noexpand\cpl@changelayout% \noexpand\cpl@info{Layout parameters reset to defaults}% }\@tempa% } \def\cpl@content{No content} \def\cpl@paperheight{\paperheight} \def\cpl@paperwidth{\paperwidth} \def\cpl@textheight{\textheight} \def\cpl@textwidth{\textwidth} \def\cpl@evensidemargin{\evensidemargin} \def\cpl@oddsidemargin{\oddsidemargin} \def\cpl@topmargin{\topmargin} \def\cpl@headheight{\headheight} \def\cpl@headsep{\headsep} \def\cpl@footskip{\footskip} \def\cpl@footins{\skip\footins} \def\cpl@topsep{\topsep} \def\cpl@listparindent{\listparindent} \def\cpl@parindent{\parindent} \def\cpl@parsep{\parsep} \def\cpl@parskip{\parskip} \def\cpl@leftmargin{\leftmargin} \def\cpl@rightmargin{\rightmargin} \def\cpl@columnwidth{\columnwidth} \def\cpl@columnsep{\columnsep} \def\cpl@columnseprule{\columnseprule} \def\cpl@marginparwidth{\marginparwidth} \def\cpl@marginparsep{\marginparsep} \def\cpl@marginparsep{\marginparpush} \def\cpl@hoffset{\hoffset} \def\cpl@voffset{\voffset} \def\cpl@textcolor{black} \define@boolkey+[KV]{changelay}[cpl@]{reset}[true]{% \cpl@backtodefaults}{\cpl@warn{Erroneous value for 'reset' ignored}} \define@boolkeys[KV]{changelay}[cpl@]{switchadjust,logdefault,% logfinal,strictcheck,oddpage}[true]{} \define@cmdkey[KV]{changelay}[cpl@]{content}[]{} \define@cmdkey[KV]{changelay}[cpl@]{textcolor}[black]{} \define@cmdkey[KV]{changelay}[cpl@]{paperheight}[\paperheight]{} \define@cmdkey[KV]{changelay}[cpl@]{paperwidth}[\paperwidth]{} \define@cmdkey[KV]{changelay}[cpl@]{textheight}[\textheight]{} \define@cmdkey[KV]{changelay}[cpl@]{textwidth}[\textwidth]{} \define@cmdkey[KV]{changelay}[cpl@]{evensidemargin}[\evensidemargin]{} \define@cmdkey[KV]{changelay}[cpl@]{oddsidemargin}[\oddsidemargin]{} \define@cmdkey[KV]{changelay}[cpl@]{topmargin}[\topmargin]{} \define@cmdkey[KV]{changelay}[cpl@]{headheight}[\headheight]{} \define@cmdkey[KV]{changelay}[cpl@]{headsep}[\headsep]{} \define@cmdkey[KV]{changelay}[cpl@]{footskip}[\footskip]{} \define@cmdkey[KV]{changelay}[cpl@]{footins}[\skip\footins]{} \define@cmdkey[KV]{changelay}[cpl@]{topsep}[\topsep]{} \define@cmdkey[KV]{changelay}[cpl@]{listparindent}[\parindent]{} \define@cmdkey[KV]{changelay}[cpl@]{parindent}[\parindent]{} \define@cmdkey[KV]{changelay}[cpl@]{parsep}[\parsep]{} \define@cmdkey[KV]{changelay}[cpl@]{parskip}[\parskip]{} \define@cmdkey[KV]{changelay}[cpl@]{leftmargin}[\leftmargin]{} \define@cmdkey[KV]{changelay}[cpl@]{rightmargin}[\rightmargin]{} \define@cmdkey[KV]{changelay}[cpl@]{columnwidth}[\columnwidth]{} \define@cmdkey[KV]{changelay}[cpl@]{columnsep}[\columnsep]{} \define@cmdkey[KV]{changelay}[cpl@]{columnseprule}[\columnseprule]{} \define@cmdkey[KV]{changelay}[cpl@]{marginparwidth}[\marginparwidth]{} \define@cmdkey[KV]{changelay}[cpl@]{marginparsep}[\marginparsep]{} \define@cmdkey[KV]{changelay}[cpl@]{marginparpush}[\marginparpush]{} \define@cmdkey[KV]{changelay}[cpl@]{hoffset}[\hoffset]{} \define@cmdkey[KV]{changelay}[cpl@]{voffset}[\voffset]{} \def\do#1{\csdef{cpl@x@#1}{\z@}} \docsvlist{paperheight,paperwidth,textheight,textwidth,evensidemargin,% oddsidemargin,topmargin,headheight,headsep,footskip,footins,topsep,% listparindent,parindent,parsep,parskip,leftmargin,rightmargin,% columnwidth,columnsep,columnseprule,marginparwidth,marginparsep,% marginparpush,hoffset,voffset% } \define@cmdkeys[KV@X]{changelay}[cpl@x@]{% paperheight,paperwidth,textheight,textwidth,evensidemargin,% oddsidemargin,topmargin,headheight,headsep,footskip,footins,% topsep,listparindent,parindent,parsep,parskip,leftmargin,rightmargin,% columnwidth,columnsep,columnseprule,marginparwidth,marginparsep,% marginparpush,hoffset,voffset% }[\z@] \DeclareOptionX*{\cpl@warn{Unknown option '\CurrentOption' ignored}} \ExecuteOptionsX{} \ProcessOptionsX*\relax \cpl@csnumdef{cpl@cnt@a}{\z@} \cpl@csnumdef{cpl@mem@c@page}{\z@} \def\cpl@xlabel{_x_} \gdef\thecpl@mem@c@page{\the\c@page} \long\def\cpl@afterelsefi#1\else#2\fi{\fi#1} \newrobustcmd\cpl@protected@write[3]{% \begingroup \let\thecpl@mem@c@page\relax #2% \let\protect\@unexpandable@protect \csedef{@tempa}{\write#1{#3}}\@tempa% \endgroup \if@nobreak\ifvmode\nobreak\fi\fi } \ifcpl@strictcheck\if@filesw\cpl@afterelsefi \def\cpl@mem@label#1{% \@bsphack \cpl@protected@write\@auxout{}% {\cpl@new@mem@label{#1}{\thecpl@mem@c@page}}% \@esphack } \else \cpl@err{nofiles: I need to write in the .aux file} \fi\fi \def\cpl@new@mem@label#1#2{\csgdef{m@#1}{#2}} \def\cpl@mem@labelref#1{0\csuse{m@#1}} \newrobustcmd\checkifoddpage{% \cpl@oddpagefalse% \ifcpl@strictcheck \global\advance\cpl@cnt@a\@ne \cpl@mem@label{\cpl@xlabel\the\cpl@cnt@a}% \cpl@mem@c@page=\cpl@mem@labelref{\cpl@xlabel\the\cpl@cnt@a}\relax \ifodd\cpl@mem@c@page\cpl@oddpagetrue\fi \else \ifodd\c@page\cpl@oddpagetrue\fi \fi } \ifcpl@logdefault \AtBeginDocument{\cpl@protected@write{16}{}{\cpl@print@defaultparams}} \fi \ifcpl@logfinal \AtEndDocument{\immediate\write16{\cpl@print@finalparams}} \fi \newrobustcmd\changepagelayout[1]{% \setkeys[KV]{changelay}{#1}% \setlength\paperheight{\cpl@paperheight}% \setlength\paperwidth{\cpl@paperwidth}% \setlength\textheight{\cpl@textheight}% \setlength\textwidth{\cpl@textwidth}% \setlength\evensidemargin{\cpl@evensidemargin}% \setlength\oddsidemargin{\cpl@oddsidemargin}% \setlength\columnsep{\cpl@columnsep}% \setlength\columnseprule{\cpl@columnseprule}% \setlength\topmargin{\cpl@topmargin}% \setlength\headheight{\cpl@headheight}% \setlength\headsep{\cpl@headsep}% \setlength\footskip{\cpl@footskip}% \setlength{\skip\footins}{\cpl@footins} \setlength\marginparwidth{\cpl@marginparwidth}% \setlength\marginparsep{\cpl@marginparsep}% \setlength\marginparpush{\cpl@x@marginparpush}% \cpl@changelayout% } \cpl@glet\changetextlayout\changepagelayout \newrobustcmd\adjustpagelayout[1]{% \setkeys[KV@X]{changelay}{#1}% \addtolength\paperheight{\cpl@x@paperheight}% \addtolength\paperwidth{\cpl@x@paperwidth}% \addtolength\textheight{\cpl@x@textheight}% \addtolength\textwidth{\cpl@x@textwidth}% \addtolength\evensidemargin{\cpl@x@evensidemargin}% \addtolength\oddsidemargin{\cpl@x@oddsidemargin}% \addtolength\columnsep{\cpl@x@columnsep}% \setlength\columnseprule{\cpl@x@columnseprule}% \addtolength\topmargin{\cpl@x@topmargin}% \addtolength\headheight{\cpl@x@headheight}% \addtolength\headsep{\cpl@x@headsep}% \addtolength\footskip{\cpl@x@footskip}% \setlength{\skip\footins}{\cpl@x@footins}% \addtolength\marginparwidth{\cpl@x@marginparwidth}% \addtolength\marginparsep{\cpl@x@marginparsep}% \addtolength\marginparpush{\cpl@x@marginparpush}% \cpl@changelayout% } \cpl@glet\adjusttextlayout\adjustpagelayout \newenvironment{cpl@adjustwidth}[2]{% \begin{list}{}{% \topsep=\z@% \partopsep=\z@% \listparindent=\parindent% \parsep=\parskip% \itemsep=\z@% \setlength\leftmargin{#1}% \setlength\rightmargin{#2}% }% \item[]\ignorespaces}% {\end{list}\ignorespacesafterend} \newenvironment{cpl@adjustwidth*}[2]{% \begin{list}{}{% \topsep=\z@% \partopsep=\z@% \listparindent=\parindent% \parsep=\parskip% \itemsep=\z@% \checkifoddpage% \ifcpl@oddpage \setlength\leftmargin{#1}% \setlength\rightmargin{#2}% \else \setlength\leftmargin{#2}% \setlength\rightmargin{#1}% \fi }\item[]\ignorespaces}% {\end{list}\ignorespacesafterend} \newrobustcmd\adjusttextwidth[1]{% \setkeys[KV]{changelay}{#1}% \ifcpl@switchadjust \begin{cpl@adjustwidth*}{\cpl@leftmargin}{\cpl@rightmargin}% \textcolor{\cpl@textcolor}{\cpl@content}% \end{cpl@adjustwidth*}\relax \else \begin{cpl@adjustwidth}{\cpl@leftmargin}{\cpl@rightmargin}% \textcolor{\cpl@textcolor}{\cpl@content}% \end{cpl@adjustwidth}\relax \fi } \newrobustcmd*\resetdefault{\setkeys[KV]{changelay}{reset=true}} \endinput