| 1 |
|
| 2 |
%%%%%%%%%1%%%%%%%%%2%%%%%%%%%3%%%%%%%%%4%%%%%%%%%5 |
| 3 |
% Please see the accompanying README for author, |
| 4 |
% license, documentation and installation information |
| 5 |
%%%%%%%%%1%%%%%%%%%2%%%%%%%%%3%%%%%%%%%4%%%%%%%%%5 |
| 6 |
|
| 7 |
\RequirePackage{filecontents} |
| 8 |
\begin{filecontents}{changepage.sty} |
| 9 |
\NeedsTeXFormat{LaTeX2e} |
| 10 |
\ProvidesPackage{changepage}[2009/10/20 v1.0c check page and change page layout] |
| 11 |
|
| 12 |
% Don't use this with memoir |
| 13 |
\newcommand*{\cp@whoopsusingmemoir}{} |
| 14 |
\@ifclassloaded{memoir}{\def\cp@whoopsusingmemoir{\endinput}} |
| 15 |
\cp@whoopsusingmemoir |
| 16 |
|
| 17 |
% New \verb|\if| for the strict option |
| 18 |
\newif\ifstrictpagecheck |
| 19 |
\strictpagecheckfalse |
| 20 |
|
| 21 |
% User commands for switching strict page checking on/off |
| 22 |
\newcommand*{\strictpagecheck}{\strictpagechecktrue} |
| 23 |
\newcommand*{\easypagecheck}{\strictpagecheckfalse} |
| 24 |
|
| 25 |
% Declare and process options |
| 26 |
\DeclareOption{strict}{\strictpagechecktrue} |
| 27 |
\ProcessOptions\relax |
| 28 |
|
| 29 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 30 |
%% New commands for strict checking of odd/even page. |
| 31 |
%% Works by writing a label and then checking its pageref. |
| 32 |
|
| 33 |
\newif\ifoddpage |
| 34 |
\newcounter{cp@cntr} |
| 35 |
\newcount\cp@tempcnt % instead of \verb|\@memcnta| |
| 36 |
\newcommand{\cplabel}{^_} |
| 37 |
|
| 38 |
\gdef\thepmemc@@page{\the\c@page} |
| 39 |
|
| 40 |
\long\def\pmemprotected@write#1#2#3{% modified \verb|\protected@write| |
| 41 |
\begingroup |
| 42 |
\let\thepmemc@@page\relax |
| 43 |
#2% |
| 44 |
\let\protect\@unexpandable@protect |
| 45 |
\edef\reserved@a{\write#1{#3}}% |
| 46 |
\reserved@a |
| 47 |
\endgroup |
| 48 |
\if@nobreak\ifvmode\nobreak\fi\fi} |
| 49 |
|
| 50 |
\newcommand*{\pmemlabel}[1]{\@bsphack |
| 51 |
\pmemprotected@write\@auxout{}% |
| 52 |
{\string\newpmemlabel{#1}{\thepmemc@@page}}% |
| 53 |
\@esphack} |
| 54 |
|
| 55 |
\newcommand*{\newpmemlabel}[2]{{\global\@namedef{m@#1}{#2}}} |
| 56 |
\newcommand*{\pmemlabelref}[1]{% |
| 57 |
\expandafter\ifx\csname m@#1\endcsname\relax |
| 58 |
0% % 0 if there is no label yet in the aux file |
| 59 |
\else |
| 60 |
\csname m@#1\endcsname |
| 61 |
\fi} |
| 62 |
|
| 63 |
\DeclareRobustCommand{\checkoddpage}{% |
| 64 |
\oddpagefalse% |
| 65 |
\ifstrictpagecheck% |
| 66 |
\stepcounter{cp@cntr}\pmemlabel{\cplabel\thecp@cntr}% |
| 67 |
\cp@tempcnt=\pmemlabelref{\cplabel\thecp@cntr}\relax |
| 68 |
\ifodd\cp@tempcnt\oddpagetrue\fi |
| 69 |
\else |
| 70 |
\ifodd\c@page\oddpagetrue\fi |
| 71 |
\fi} |
| 72 |
|
| 73 |
% End newcommands for strict checking of odd/even page. |
| 74 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 75 |
|
| 76 |
% Copy of some of the code from the ifmtarg package to save requiring ifmtarg |
| 77 |
\begingroup |
| 78 |
\catcode`\Q=3 |
| 79 |
\long\gdef\@ifmtarg#1{\@xifmtarg#1QQ\@secondoftwo\@firstoftwo\@nil} |
| 80 |
\long\gdef\@xifmtarg#1#2Q#3#4#5\@nil{#4} |
| 81 |
\endgroup |
| 82 |
|
| 83 |
% Set the page output parameters |
| 84 |
\DeclareRobustCommand{\ch@ngetext}{% |
| 85 |
\setlength{\@colht}{\textheight}\setlength{\@colroom}{\textheight}% |
| 86 |
\setlength{\vsize}{\textheight}\setlength{\columnwidth}{\textwidth}% |
| 87 |
\if@twocolumn% |
| 88 |
\advance\columnwidth-\columnsep \divide\columnwidth\tw@% |
| 89 |
\@firstcolumntrue% |
| 90 |
\fi% |
| 91 |
\setlength{\hsize}{\columnwidth}% |
| 92 |
\setlength{\linewidth}{\hsize}} |
| 93 |
|
| 94 |
\DeclareRobustCommand{\changetext}[5]{% |
| 95 |
\@ifmtarg{#1}{}{\addtolength{\textheight}{#1}}% |
| 96 |
\@ifmtarg{#2}{}{\addtolength{\textwidth}{#2}}% |
| 97 |
\@ifmtarg{#3}{}{\addtolength{\evensidemargin}{#3}}% |
| 98 |
\@ifmtarg{#4}{}{\addtolength{\oddsidemargin}{#4}}% |
| 99 |
\@ifmtarg{#5}{}{\addtolength{\columnsep}{#5}}% |
| 100 |
\ch@ngetext} |
| 101 |
|
| 102 |
\DeclareRobustCommand{\changepage}[9]{% |
| 103 |
\@ifmtarg{#1}{}{\addtolength{\textheight}{#1}}% |
| 104 |
\@ifmtarg{#2}{}{\addtolength{\textwidth}{#2}}% |
| 105 |
\@ifmtarg{#3}{}{\addtolength{\evensidemargin}{#3}}% |
| 106 |
\@ifmtarg{#4}{}{\addtolength{\oddsidemargin}{#4}}% |
| 107 |
\@ifmtarg{#5}{}{\addtolength{\columnsep}{#5}}% |
| 108 |
\ch@ngetext% |
| 109 |
\@ifmtarg{#6}{}{\addtolength{\topmargin}{#6}}% |
| 110 |
\@ifmtarg{#7}{}{\addtolength{\headheight}{#7}}% |
| 111 |
\@ifmtarg{#8}{}{\addtolength{\headsep}{#8}}% |
| 112 |
\@ifmtarg{#9}{}{\addtolength{\footskip}{#9}}} |
| 113 |
|
| 114 |
\newenvironment{adjustwidth}[2]{% |
| 115 |
\begin{list}{}{% |
| 116 |
\topsep\z@% |
| 117 |
\listparindent\parindent% |
| 118 |
\parsep\parskip% |
| 119 |
\@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}% |
| 120 |
{\setlength{\leftmargin}{#1}}% |
| 121 |
\@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}% |
| 122 |
{\setlength{\rightmargin}{#2}}% |
| 123 |
} |
| 124 |
\item[]}{\end{list}} |
| 125 |
|
| 126 |
\newenvironment{adjustwidth*}[2]{% |
| 127 |
\begin{list}{}{% |
| 128 |
\topsep\z@% |
| 129 |
\listparindent\parindent% |
| 130 |
\parsep\parskip% |
| 131 |
\checkoddpage |
| 132 |
\ifoddpage% odd numbered page |
| 133 |
\@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}% |
| 134 |
{\setlength{\leftmargin}{#1}}% |
| 135 |
\@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}% |
| 136 |
{\setlength{\rightmargin}{#2}}% |
| 137 |
\else% even numbered page |
| 138 |
\@ifmtarg{#2}{\setlength{\leftmargin}{\z@}}% |
| 139 |
{\setlength{\leftmargin}{#2}}% |
| 140 |
\@ifmtarg{#1}{\setlength{\rightmargin}{\z@}}% |
| 141 |
{\setlength{\rightmargin}{#1}}% |
| 142 |
\fi} |
| 143 |
\item[]}{\end{list}} |
| 144 |
|
| 145 |
\endinput |
| 146 |
|
| 147 |
\end{filecontents} |
| 148 |
%%%%%%%%%1%%%%%%%%%2%%%%%%%%%3%%%%%%%%%4%%%%%%%%%5 |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
\begin{filecontents}{chngpage.sty} |
| 154 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 155 |
% PLEASE NOTE: |
| 156 |
% THIS PACKAGE IS DEPRECATED IN FAVOUR OF CHANGEPAGE.STY FOR REASONS |
| 157 |
% OF COMPATIBILITY WITH THE MEMOIR CLASS. The two are equivalent; |
| 158 |
% please do not use this one for new documents or packages. |
| 159 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 160 |
% |
| 161 |
\NeedsTeXFormat{LaTeX2e} |
| 162 |
\ProvidesPackage{chngpage}[2009/10/20 v1.2b change page layout] |
| 163 |
|
| 164 |
%% Note: internal package commands all include the string |cp@|. |
| 165 |
%% New \cs{if} for the strict option. |
| 166 |
\newif\ifcpstrict |
| 167 |
\cpstrictfalse |
| 168 |
|
| 169 |
%% Declare and process options. |
| 170 |
\DeclareOption{strict}{\cpstricttrue} |
| 171 |
\ProcessOptions\relax |
| 172 |
|
| 173 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 174 |
% New commands for strict checking of odd/even page. |
| 175 |
% Works by writing a label and then checking its pageref. |
| 176 |
% |
| 177 |
% Rewritten in v1.2 to handle roman, Roman, etc page numbers |
| 178 |
% as well as arabic; also eliminates special code to handle |
| 179 |
% hyperref. Based on the code in the memoir class. |
| 180 |
|
| 181 |
\newif\ifcpoddpage |
| 182 |
\newcounter{cp@cnt} |
| 183 |
\newcounter{cp@tempcnt} |
| 184 |
\newcommand{\cplabelprefix}{^_} |
| 185 |
|
| 186 |
\gdef\thecp@page{\the\c@page} |
| 187 |
\long\def\cp@protected@write#1#2#3{% % modified \cs{protected@write} |
| 188 |
\begingroup |
| 189 |
\let\thecp@page\relax |
| 190 |
#2% |
| 191 |
\let\protect\@unexpandable@protect |
| 192 |
\edef\reserved@a{\write#1{#3}}% |
| 193 |
\reserved@a |
| 194 |
\endgroup |
| 195 |
\if@nobreak\ifvmode\nobreak\fi\fi} |
| 196 |
|
| 197 |
\DeclareRobustCommand{\checkoddpage}{% |
| 198 |
\cpoddpagefalse |
| 199 |
\stepcounter{cp@cnt}\cplabel{\cplabelprefix\thecp@cnt}% |
| 200 |
\c@cp@tempcnt=\cp@labelref{\cplabelprefix\thecp@cnt}\relax |
| 201 |
\ifodd\c@cp@tempcnt\cpoddpagetrue\fi} |
| 202 |
|
| 203 |
\newcommand{\cplabel}[1]{\@bsphack |
| 204 |
\cp@protected@write\@auxout{}% |
| 205 |
{\string\newcplabel{#1}{\thecp@page}}% |
| 206 |
\@esphack} |
| 207 |
|
| 208 |
\newcommand{\newcplabel}[2]{{\global\@namedef{p@#1}{#2}}} |
| 209 |
|
| 210 |
\newcommand{\cp@labelref}[1]{% |
| 211 |
\expandafter\ifx\csname p@#1\endcsname\relax |
| 212 |
0% % 0 if there is no label yet in aux file |
| 213 |
\else |
| 214 |
\csname p@#1\endcsname |
| 215 |
\fi} |
| 216 |
|
| 217 |
% End newcommands for strict checking of odd/even page. |
| 218 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 219 |
|
| 220 |
% Copy of some of the code from the ifmtarg package to save requiring ifmtarg. |
| 221 |
\begingroup |
| 222 |
\catcode`\Q=3 |
| 223 |
\long\gdef\@ifmtarg#1{\@xifmtarg#1QQ\@secondoftwo\@firstoftwo\@nil} |
| 224 |
\long\gdef\@xifmtarg#1#2Q#3#4#5\@nil{#4} |
| 225 |
\endgroup |
| 226 |
|
| 227 |
% Set the page output parameters. |
| 228 |
\DeclareRobustCommand{\ch@ngetext}{% |
| 229 |
\setlength{\@colht}{\textheight}\setlength{\@colroom}{\textheight}% |
| 230 |
\setlength{\vsize}{\textheight}\setlength{\columnwidth}{\textwidth}% |
| 231 |
\if@twocolumn% |
| 232 |
\advance\columnwidth-\columnsep \divide\columnwidth\tw@% |
| 233 |
\@firstcolumntrue% |
| 234 |
\fi% |
| 235 |
\setlength{\hsize}{\columnwidth}% |
| 236 |
\setlength{\linewidth}{\hsize}% |
| 237 |
} |
| 238 |
|
| 239 |
\DeclareRobustCommand{\changetext}[5]{% |
| 240 |
\@ifmtarg{#1}{}{\addtolength{\textheight}{#1}}% |
| 241 |
\@ifmtarg{#2}{}{\addtolength{\textwidth}{#2}}% |
| 242 |
\@ifmtarg{#3}{}{\addtolength{\evensidemargin}{#3}}% |
| 243 |
\@ifmtarg{#4}{}{\addtolength{\oddsidemargin}{#4}}% |
| 244 |
\@ifmtarg{#5}{}{\addtolength{\columnsep}{#5}}% |
| 245 |
\ch@ngetext% |
| 246 |
} |
| 247 |
|
| 248 |
\DeclareRobustCommand{\changepage}[9]{% |
| 249 |
\@ifmtarg{#1}{}{\addtolength{\textheight}{#1}}% |
| 250 |
\@ifmtarg{#2}{}{\addtolength{\textwidth}{#2}}% |
| 251 |
\@ifmtarg{#3}{}{\addtolength{\evensidemargin}{#3}}% |
| 252 |
\@ifmtarg{#4}{}{\addtolength{\oddsidemargin}{#4}}% |
| 253 |
\@ifmtarg{#5}{}{\addtolength{\columnsep}{#5}}% |
| 254 |
\ch@ngetext% |
| 255 |
\@ifmtarg{#6}{}{\addtolength{\topmargin}{#6}}% |
| 256 |
\@ifmtarg{#7}{}{\addtolength{\headheight}{#7}}% |
| 257 |
\@ifmtarg{#8}{}{\addtolength{\headsep}{#8}}% |
| 258 |
\@ifmtarg{#9}{}{\addtolength{\footskip}{#9}}% |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
\newenvironment{adjustwidth}[3][\@empty]{% |
| 263 |
\begin{list}{}{% |
| 264 |
\topsep\z@% |
| 265 |
\listparindent\parindent% |
| 266 |
\parsep\parskip% |
| 267 |
\@ifmtarg{#2}{\setlength{\leftmargin}{\z@}}{\setlength{\leftmargin}{#2}}% |
| 268 |
\@ifmtarg{#3}{\setlength{\rightmargin}{\z@}}{\setlength{\rightmargin}{#3}}% |
| 269 |
\ifx\@empty #1\relax \else |
| 270 |
\cpoddpagefalse |
| 271 |
\ifcpstrict\checkoddpage\else |
| 272 |
\ifodd\c@page\cpoddpagetrue\fi |
| 273 |
\fi |
| 274 |
\ifcpoddpage\else % even numbered page |
| 275 |
\@ifmtarg{#3}{\setlength{\leftmargin}{\z@}}{\setlength{\leftmargin}{#3}}% |
| 276 |
\@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}{\setlength{\rightmargin}{#2}}% |
| 277 |
\fi |
| 278 |
\fi} |
| 279 |
\item[]}{\end{list}} |
| 280 |
|
| 281 |
\endinput |
| 282 |
\end{filecontents} |
| 283 |
%%%%%%%%%1%%%%%%%%%2%%%%%%%%%3%%%%%%%%%4%%%%%%%%%5 |
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
% Conditionally compile the documentation & generate the .ins file: |
| 288 |
\providecommand\changepageCompile{Y} |
| 289 |
\makeatletter |
| 290 |
\if\changepageCompile N |
| 291 |
\expandafter\@@end |
| 292 |
\fi |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
\begin{filecontents*}{changepage.ins} |
| 297 |
%&latex |
| 298 |
\def\changepageCompile{N} |
| 299 |
\input changepage.tex |
| 300 |
\csname@@end\endcsname |
| 301 |
\end{filecontents*} |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
\makeatletter |
| 307 |
\documentclass{article} |
| 308 |
|
| 309 |
\usepackage[it,medium]{titlesec} |
| 310 |
|
| 311 |
\usepackage{bigfoot,xcolor} |
| 312 |
\usepackage[colorlinks,linktocpage]{hyperref} |
| 313 |
|
| 314 |
\usepackage{gmdoc} |
| 315 |
\usepackage{gmverb} |
| 316 |
\dekclubs |
| 317 |
\stanzaskip=\bigskipamount |
| 318 |
\CodeSpacesGrey |
| 319 |
|
| 320 |
\usepackage{tocloft,varwidth} |
| 321 |
\setcounter{tocdepth}{1} |
| 322 |
\def\tocwidthA{0.55} |
| 323 |
\def\tocwidthB{0.44} |
| 324 |
\def\cftpartfont{\scshape} |
| 325 |
\def\cftsecfont{\small} |
| 326 |
\cftbeforesecskip=0pt |
| 327 |
\def\cftpartleader{} |
| 328 |
\def\cftpartafterpnum{\cftparfillskip} |
| 329 |
\def\cftsecleader{} |
| 330 |
\def\cftsecafterpnum{\cftparfillskip} |
| 331 |
|
| 332 |
\DeclareRobustCommand\pkg{\textsf} |
| 333 |
\def\pkgopt#1{\texttt{[#1]}} |
| 334 |
\newcommand\chng[1]{\marginpar{\footnotesize\raggedright\textsf{#1}}} |
| 335 |
|
| 336 |
\def\PDF{\textsc{pdf}} |
| 337 |
\def\PS{\textsc{ps}} |
| 338 |
\def\DVI{\textsc{dvi}} |
| 339 |
\def\EPS{\textsc{eps}} |
| 340 |
|
| 341 |
\usepackage{amsmath,listings} |
| 342 |
\lstset{basicstyle=\ttfamily,columns=fullflexible} |
| 343 |
|
| 344 |
\begingroup |
| 345 |
\usepackage{chngpage} |
| 346 |
\GetFileInfo{chngpage.sty} |
| 347 |
\global\let\chngpagev\fileversion |
| 348 |
\endgroup |
| 349 |
\usepackage{changepage} |
| 350 |
\usepackage[T1]{fontenc} |
| 351 |
\usepackage{microtype} |
| 352 |
\usepackage{lmodern} |
| 353 |
\usepackage[sc,osf]{mathpazo} |
| 354 |
\linespread{1.1} |
| 355 |
\frenchspacing |
| 356 |
|
| 357 |
\GetFileInfo{changepage.sty} |
| 358 |
\begin{document} |
| 359 |
{\addtocontents{toc}{\protect\begin{varwidth}[t]{\tocwidthA\linewidth}}} |
| 360 |
|
| 361 |
\title{The \pkg{changepage} and \pkg{chngpage} packages} |
| 362 |
\author{% |
| 363 |
Author: Peter Wilson, Herries Press\\ |
| 364 |
Maintainer: Will Robertson\\ |
| 365 |
\texttt{will dot robertson at latex-project dot org}% |
| 366 |
} |
| 367 |
\date{\chngpagev\ and \fileversion, \filedate} |
| 368 |
|
| 369 |
\maketitle |
| 370 |
|
| 371 |
\begin{abstract} |
| 372 |
\noindent Provides command |
| 373 |
|\ifoddpage| to detect the current page `side', |
| 374 |
environment |adjustwidth| to locally change the margins of the text, |
| 375 |
and commands |\changetext| and |\changepage| for more |
| 376 |
radical changes to the page design mid-way through a document. |
| 377 |
|
| 378 |
\pkg{changepage} is the new version of \pkg{chngpage} to be |
| 379 |
compatible with \pkg{memoir}. \pkg{chngpage} is now deprecated |
| 380 |
for this reason. |
| 381 |
\end{abstract} |
| 382 |
|
| 383 |
\tableofcontents |
| 384 |
|
| 385 |
\part{User documentation} |
| 386 |
|
| 387 |
Load the package like this: |
| 388 |
\begin{verbatim} |
| 389 |
\usepackage[strict]{changepage} |
| 390 |
\end{verbatim} |
| 391 |
Or for deprecated uses: |
| 392 |
\begin{verbatim} |
| 393 |
\usepackage[strict]{chngpage} |
| 394 |
\end{verbatim} |
| 395 |
|
| 396 |
\section{Detecting odd or even pages} |
| 397 |
|
| 398 |
The |\checkoddpage| command can be used anywhere in the body of |
| 399 |
a document to determine if \TeX\ is typesetting on an odd or |
| 400 |
even numbered page. If on an odd page then |\ifoddpage| is |
| 401 |
set \meta{true}, otherwise (on an even page) |\ifoddpage| is set |
| 402 |
\meta{false}. |
| 403 |
|
| 404 |
\chng{Use \cs{ifcpoddpage} instead if you're using chngpage.} |
| 405 |
|
| 406 |
Strict page checking works by the |\checkoddpage| command generating |
| 407 |
a label and then checking the |\pageref| for the label (actually, a special |
| 408 |
version of |\pageref| is required and is used internally by |\checkoddpage|). |
| 409 |
This mechanism requires at least two \LaTeX\ passes to ensure that |
| 410 |
the labels have settled (on the initial pass there will be no labels |
| 411 |
in the *.aux file to be checked). |
| 412 |
|
| 413 |
The label identifier is composed of the command |\cplabel| |
| 414 |
and an automatically generated number. |\cplabel|, initially |
| 415 |
defined as `|^_|', can be changed in the preamble if it will cause |
| 416 |
a clash with any author-defined labels. The default labels will |
| 417 |
be of the form `|^_|\meta{N}' where \meta{N} is a positive integer. |
| 418 |
|
| 419 |
\chng{For chngpage, use \cs{cplabelprefix} instead of \cs{cplabel}.} |
| 420 |
|
| 421 |
The package option `strict' turns on strict page checking --- the default |
| 422 |
is not to use strict checking. Strict page checking can be turned on or |
| 423 |
off at any time by the commands |\strictpagecheck| or |\easypagecheck|. |
| 424 |
The easy page check just tests the page number to see if it is odd or even, |
| 425 |
which does not always give the correct result because of \TeX's asynchronous |
| 426 |
output mechanism. |
| 427 |
|
| 428 |
|
| 429 |
\section{Adjusting the margins} |
| 430 |
|
| 431 |
Within an |adjustwidth| environment the left and right margins can be |
| 432 |
adjusted. The environment takes two required length arguments: |
| 433 |
\begin{quote} |
| 434 |
\cs{begin}|{adjustwidth}|\marg{leftmargin}\marg{rightmargin} |
| 435 |
\end{quote} |
| 436 |
A positive length value will increase the relevant margin (shortening |
| 437 |
the text lines) while a negative length value will decrease the margin |
| 438 |
(lengthening text lines). An empty length argument means no change |
| 439 |
to the margin. At the end of the environment the margins revert to |
| 440 |
their original values. |
| 441 |
|
| 442 |
For example, to extend the text into the right margin: |
| 443 |
\begin{quote} |
| 444 |
|\begin{adjustwidth}{}{-8em}| |
| 445 |
\end{quote} |
| 446 |
The starred version, |adjustwidth*|, causes the values of the |
| 447 |
margins to switch between odd and even pages. |
| 448 |
|
| 449 |
\chng{For chngpage use \cs{begin}\texttt{\{adjustwidth\}[]} |
| 450 |
instead of \cs{begin}\texttt{\{adjustwidth*\}}.} |
| 451 |
|
| 452 |
For example, if the document is being set twosided it might be |
| 453 |
advantageous to have any wider text extending into the outside |
| 454 |
margin: |
| 455 |
\begin{quote} |
| 456 |
|\begin{adjustwidth*}{}{-8em}| |
| 457 |
\end{quote} |
| 458 |
To have the adjusted text horizontally centered with respect to |
| 459 |
any surrounding text, the margins should be adjusted equally: |
| 460 |
\begin{quote} |
| 461 |
|\begin{adjustwidth}{-4em}{-4em}| |
| 462 |
\end{quote} |
| 463 |
For interest, \cs{begin}|{quotation}| is pretty much equivalent to |
| 464 |
\begin{quote} |
| 465 |
|\begin{adjustwidth}{2.5em}{2.5em}| |
| 466 |
\end{quote} |
| 467 |
The environment may also be used inside a float if the contents are |
| 468 |
a bit too wide for the text block, but can still fit within the physical |
| 469 |
page: |
| 470 |
\begin{verbatim} |
| 471 |
\begin{figure} |
| 472 |
\begin{adjustwidth}{-2em}{-2em} |
| 473 |
\includegraphics{wide} |
| 474 |
\caption{Wide figure} |
| 475 |
\end{adjustwidth} |
| 476 |
\end{figure} |
| 477 |
\end{verbatim} |
| 478 |
Sometimes, because of the asynchronous nature of the TeX output |
| 479 |
routine, the margin switching may be incorrect (like |\marginpar| sometimes) |
| 480 |
near the top of a page. This can be corrected by using the package |
| 481 |
option `strict' (i.e., |\usepackage[strict]{chngpage}|), which causes |
| 482 |
adjustwidth to use the |\checkoddpage| command (see below). |
| 483 |
|
| 484 |
A disadvantage of the strict option is that the package generates |
| 485 |
a new label for each adjustwidth environment, and \TeX\ may run out |
| 486 |
of space if there are an excessive number of labels in the document. |
| 487 |
|
| 488 |
Whether or not the strict option is used, `strict adjustwidths' |
| 489 |
can be turned on by putting the command |\strictpagecheck| before |
| 490 |
the environment, and turned off by using |\easypagecheck|. |
| 491 |
|
| 492 |
\chng{In chngpage, use \cs{cpstricttrue} and \cs{cpstricttrue} |
| 493 |
instead of \cs{strictpagecheck} and \cs{easypagecheck}.} |
| 494 |
|
| 495 |
\textsc{note:} |
| 496 |
In a twocolumn document, the adjustwidth environment |
| 497 |
treats both columns equally. For example, if the width is meant |
| 498 |
to be wider at the outer margin, then on odd pages the extra width |
| 499 |
will be at the right of any column, and on even pages the extra |
| 500 |
will be at the left of any column. You can get interesting effects |
| 501 |
by careful hand tuning on two column pages. |
| 502 |
|
| 503 |
|
| 504 |
\section{Changing the text block} |
| 505 |
|
| 506 |
The |\changetext| command is for changing the size and horizontal position |
| 507 |
of the text block on a page. The command takes 5 arguments, each of which |
| 508 |
is a length or is empty. i.e., |
| 509 |
\begin{quote} |
| 510 |
\cmd\changetext\marg{text height}\marg{text width}\marg{even-side margin} |
| 511 |
\newline\null\hfill\marg{odd-side margin}\marg{column sep.} |
| 512 |
\end{quote} |
| 513 |
The given lengths are added to the corresponding current lengths and |
| 514 |
the remainder of the current page is typeset using the changed text block |
| 515 |
layout. The new layout remains in effect until another |\change...| command |
| 516 |
is issued. |
| 517 |
|
| 518 |
|
| 519 |
\section{Changing the entire page design} |
| 520 |
|
| 521 |
The |\changepage| command is for changing the general layout of |
| 522 |
a page. The command takes 9 arguments, each of which is a length or is empty. |
| 523 |
The first 5 arguments are the same as for |\changetext| and have the same effect. |
| 524 |
The last four arguments are: |
| 525 |
\begin{quote} |
| 526 |
\cmd\changepage\meta{5 args}\marg{topmargin}\marg{headheight}\marg{headsep}\marg{footskip} |
| 527 |
\end{quote} |
| 528 |
These lengths are added to the corresponding current lengths and |
| 529 |
thus modify the vertical positions of the elements of the page. The |
| 530 |
remainder of the current page is typeset using the changed text block |
| 531 |
and page layout. The new layout remains in effect until another |
| 532 |
|\change...| command is issued. |
| 533 |
|
| 534 |
\begin{itemize} |
| 535 |
\item[\textsc{note} 1] Not supplying a value for a length argument is equivalent |
| 536 |
to giving it a zero length value. |
| 537 |
|
| 538 |
\item[\textsc{note} 2] For any given page, everything is constant except for the textwidth |
| 539 |
and columnsep (for example, what is the meaning of two |
| 540 |
topmargins on a single column page?). |
| 541 |
It is therefore best to change anything else at the |
| 542 |
start of a new page. Further, any changes only apply to whole |
| 543 |
paragraphs. If you want an odd shaped paragraph use either |
| 544 |
the \pkg{hanging} package or the \TeX\ |\parshape| command. |
| 545 |
\end{itemize} |
| 546 |
For example, to change from single column pages to double column |
| 547 |
pages where the text block is both shorter and wider, then to revert |
| 548 |
back to the initial layout: |
| 549 |
\begin{verbatim} |
| 550 |
... single column normal page |
| 551 |
\newpage % or \clearpage |
| 552 |
\changetext{-5\baselineskip}{10em}{-5em}{-5em}{} |
| 553 |
\twocolumn |
| 554 |
... two column pages |
| 555 |
\clearpage |
| 556 |
\changetext{5\baselineskip}{-10em}{5em}{5em}{} |
| 557 |
\onecolumn |
| 558 |
... normal pages |
| 559 |
\end{verbatim} |
| 560 |
Note the adjustments to the margins which will keep the vertical centerline |
| 561 |
of the textblock at the same position on the page. |
| 562 |
|
| 563 |
As another example, to increase the width of a single paragraph: |
| 564 |
\begin{verbatim} |
| 565 |
\changetext{0pt}{5em}{}{}{}% |
| 566 |
Start of wider paragraph text ... |
| 567 |
... end of paragraph. |
| 568 |
|
| 569 |
\changetext{0pt}{-5em}{}{}{} |
| 570 |
Start of a normal paragraph ... |
| 571 |
\end{verbatim} |
| 572 |
Under some circumstances you can include a |\change...| command as part of |
| 573 |
the argument to |\afterpage| (from the \pkg{afterpage} package) and it may work. |
| 574 |
Similarly it may work in a heading style used for |\thispagestyle| to change |
| 575 |
a single page. |
| 576 |
|
| 577 |
{\addtocontents{toc}{\protect\end{varwidth}\protect\hfill}} |
| 578 |
{\addtocontents{toc}{\protect\begin{varwidth}[t]{\protect\tocwidthB\protect\linewidth}}} |
| 579 |
\clearpage |
| 580 |
\parindent=0pt |
| 581 |
|
| 582 |
\part{Implementation} |
| 583 |
\section{The \pkg{changepage} package} |
| 584 |
\DocInput{changepage.sty} |
| 585 |
|
| 586 |
\clearpage |
| 587 |
\section{The \pkg{chngpage} package} |
| 588 |
\DocInput{chngpage.sty} |
| 589 |
|
| 590 |
{\addtocontents{toc}{\protect\end{varwidth}}} |
| 591 |
|
| 592 |
\end{document} |