From 7189045dcbf98604e22d04c1064843841bfaac4d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 22 Jul 2009 22:43:45 +0000 Subject: new latex package changelayout 0.1 (21jul09) git-svn-id: svn://tug.org/texlive/trunk@14369 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/changelayout/changelayout.sty | 413 +++++++++++++++++++++ 1 file changed, 413 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/changelayout/changelayout.sty (limited to 'Master/texmf-dist/tex/latex/changelayout') diff --git a/Master/texmf-dist/tex/latex/changelayout/changelayout.sty b/Master/texmf-dist/tex/latex/changelayout/changelayout.sty new file mode 100644 index 00000000000..a385e5df7f7 --- /dev/null +++ b/Master/texmf-dist/tex/latex/changelayout/changelayout.sty @@ -0,0 +1,413 @@ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++% +% 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}} +\@ifclassloaded{memoir}{% + \cpl@err{This package can't be used with\MessageBreak + memoir class. I've therefore exited} + \expandafter\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'} + \expandafter\endinput% + }{} +} +\newrobustcmd*\csmdef[1]{\expandafter\csname#1\endcsname} +\newrobustcmd*\cpl@numexpr[2]{% + \ifstrempty{#2}{% + \cpl@err{You can't assign empty argument\MessageBreak + to number}}{} + \ifcsundef{#1}{% + \expandafter\newcount\csname#1\endcsname% + \csmdef{#1}=\the\numexpr#2\relax + }{\csmdef{#1}=\the\numexpr#2\relax} +} +\newrobustcmd*\cpl@dimexpr[2]{% + \ifstrempty{#2}{% + \cpl@err{You can't assign empty argument\MessageBreak + to dimension}}{} + \ifcsundef{#1}{% + \expandafter\newdimen\csname#1\endcsname% + \csmdef{#1}=\the\dimexpr#2\relax + }{\csmdef{#1}=\the\dimexpr#2\relax} +} +\newrobustcmd\cpl@changetext{% + \@colht=\textheight% + \@colroom=\textheight% + \vsize=\textheight% + \columnwidth=\textwidth% + \if@twocolumn + \cpl@dimexpr{dimen@}{(\columnwidth-\columnsep)/2} + \columnwidth=\dimen@% + \@firstcolumntrue + \fi + \hsize=\columnwidth% + \linewidth=\hsize% +} +\protected@edef\cpl@setdefault{% + \noexpand\cpl@dimexpr{cpl@orig@paperwidth}{\paperwidth}% + \noexpand\cpl@dimexpr{cpl@orig@paperheight}{\paperheight}% + \noexpand\cpl@dimexpr{cpl@orig@textheight}{\textheight}% + \noexpand\cpl@dimexpr{cpl@orig@textwidth}{\textwidth}% + \noexpand\cpl@dimexpr{cpl@orig@oddsidemargin}{\oddsidemargin}% + \noexpand\cpl@dimexpr{cpl@orig@evensidemargin}{\evensidemargin}% + \noexpand\cpl@dimexpr{cpl@orig@topmargin}{\topmargin}% + \noexpand\cpl@dimexpr{cpl@orig@headsep}{\headsep}% + \noexpand\cpl@dimexpr{cpl@orig@headheight}{\headheight}% + \noexpand\cpl@dimexpr{cpl@orig@footskip}{\footskip}% + \noexpand\cpl@dimexpr{cpl@orig@footins}{\skip\footins}% + \noexpand\cpl@dimexpr{cpl@orig@marginparwidth}{\marginparwidth}% + \noexpand\cpl@dimexpr{cpl@orig@marginparsep}{\marginparsep}% + \noexpand\cpl@dimexpr{cpl@orig@marginparpush}{\marginparpush}% + \noexpand\cpl@dimexpr{cpl@orig@columnsep}{\columnsep}% + \noexpand\cpl@dimexpr{cpl@orig@columnseprule}{\columnseprule}% + \noexpand\cpl@dimexpr{cpl@orig@linewidth}{\linewidth}% + \noexpand\cpl@dimexpr{cpl@orig@hoffset}{\hoffset}% + \noexpand\cpl@dimexpr{cpl@orig@voffset}{\voffset}% + \noexpand\cpl@numexpr{cpl@orig@mag}{\mag}% +} +\@onlypreamble\cpl@setdefault% +\cpl@setdefault% +\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 +\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% +}% +\protected@edef\cpl@resetdefault{% + \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@changetext% + \noexpand\cpl@info{Default layout parameters reset} +} +\def\cpl@content{No content} +\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@hoffset{\hoffset} +\def\cpl@voffset{\voffset} +\def\cpl@textcolor{black} +\define@boolkey+[KV]{changelay}[cpl@]{reset}[true]{% + \cpl@resetdefault}{\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@]{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@]{hoffset}[\hoffset]{} +\define@cmdkey[KV]{changelay}[cpl@]{voffset}[\voffset]{} +\def\do#1{\csdef{cpl@x@#1}{\z@}} +\docsvlist{textheight,textwidth,evensidemargin,oddsidemargin,topmargin,% + headheight,headsep,footskip,footins,topsep,listparindent,% + parindent,parsep,parskip,leftmargin,rightmargin,columnwidth,% + columnsep,columnseprule,marginparwidth,marginparsep,hoffset,voffset% +} +\define@cmdkeys[KV@X]{changelay}[cpl@x@]{% + textheight,textwidth,evensidemargin,oddsidemargin,topmargin,% + headheight,headsep,footskip,footins,topsep,listparindent,% + parindent,parsep,parskip,leftmargin,rightmargin,columnwidth,% + columnsep,columnseprule,marginparwidth,marginparsep,hoffset,voffset% +}[\z@] +\DeclareOptionX*{\cpl@warn{Unknown option '\CurrentOption' ignored}} +\ExecuteOptionsX{} +\ProcessOptionsX*\relax +\cpl@numexpr{cpl@cnt@a}{\z@} +\cpl@numexpr{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 + \cpl@protected@write{16}{}{\cpl@print@defaultparams} +\fi +\AtEndDocument{% + \ifcpl@logfinal + \immediate\write16{\cpl@print@finalparams} + \fi +} +\newrobustcmd\changetextlayout[1]{% + \setkeys[KV]{changelay}{#1}% + \setlength\textheight{\cpl@textheight}% + \setlength\textwidth{\cpl@textwidth}% + \setlength\evensidemargin{\cpl@evensidemargin}% + \setlength\oddsidemargin{\cpl@oddsidemargin}% + \setlength\columnsep{\cpl@columnsep}% + \setlength\columnseprule{\cpl@columnseprule}% + \cpl@changetext% + \setlength\marginparwidth{\cpl@marginparwidth}% + \setlength\marginparsep{\cpl@marginparsep}% + \setlength{\footskip}{\cpl@footskip} + \setlength{\skip\footins}{\cpl@footins} +} +\newrobustcmd\changepagelayout[1]{% + \setkeys[KV]{changelay}{#1}% + \setlength\textheight{\cpl@textheight}% + \setlength\textwidth{\cpl@textwidth}% + \setlength\evensidemargin{\cpl@evensidemargin}% + \setlength\oddsidemargin{\cpl@oddsidemargin}% + \setlength\columnsep{\cpl@columnsep}% + \setlength\columnseprule{\cpl@columnseprule}% + \cpl@changetext% + \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}% +} +\newrobustcmd\adjusttextlayout[1]{% + \setkeys[KV@X]{changelay}{#1}% + \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}% + \cpl@changetext% + \addtolength\topmargin{\cpl@x@topmargin}% + \addtolength\headsep{\cpl@x@headsep}% + \addtolength\marginparwidth{\cpl@x@marginparwidth}% + \addtolength\marginparsep{\cpl@x@marginparsep}% + \addtolength\footskip{\cpl@x@footskip}% + \addtolength{\skip\footins}{\cpl@x@footins} +} +\newrobustcmd\adjustpagelayout[1]{% + \setkeys[KV@X]{changelay}{#1}% + \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}% + \cpl@x@changetext% + \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}% +} +\newenvironment{cpl@adjustwidth}[2]{% + \begin{list}{}{% + \topsep=\z@% + \partopsep=\z@% + \listparindent=\parindent% + \parsep=\parskip% + \itemsep=\z@% + \setlength\leftmargin{#1}% + \setlength\rightmargin{#2}% + }% + \item[]}% +{\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[]}% +{\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 \ No newline at end of file -- cgit v1.2.3