| 1 |
% \iffalse |
| 2 |
%<*internal> |
| 3 |
\begingroup |
| 4 |
\input docstrip.tex |
| 5 |
\keepsilent\nopreamble\nopostamble\askforoverwritefalse |
| 6 |
\generate{\file{dtx-style.sty}{\from{\jobname.dtx}{dtx-style}}} |
| 7 |
\endgroup |
| 8 |
\documentclass{ltxdoc} |
| 9 |
\EnableCrossrefs |
| 10 |
\CodelineIndex |
| 11 |
\RecordChanges |
| 12 |
\usepackage{dtx-style} |
| 13 |
\begin{document} |
| 14 |
\DocInput{addlines.dtx} |
| 15 |
\end{document} |
| 16 |
%</internal> |
| 17 |
% \fi |
| 18 |
% |
| 19 |
% \GetFileInfo{\jobname.sty} |
| 20 |
% \CheckSum{0} |
| 21 |
% \makeatletter |
| 22 |
% |
| 23 |
% \title{The \pkg{\jobname} package} |
| 24 |
% \author{Will Robertson\\ \url{http://github.com/wspr/will2e}} |
| 25 |
% \date{\filedate \qquad \fileversion} |
| 26 |
% |
| 27 |
% \maketitle |
| 28 |
% |
| 29 |
% \noindent |
| 30 |
% This is a small package that defines a user command for adding lines |
| 31 |
% to the current (and facing page, if appropriate) as a wrapper around the |
| 32 |
% \LaTeX\ command \cmd\enlargethispage. |
| 33 |
% This is intended to be used in the final typesetting |
| 34 |
% process of a manuscript for running pages long or short in order to |
| 35 |
% fit their material better (starting a paragraph on the next page, |
| 36 |
% for example). |
| 37 |
% |
| 38 |
% \DescribeMacro{\addlines} |
| 39 |
% The \cmd\addlines\ command adds enough vertical space to |
| 40 |
% the current text block to fit in one more line of text. An optional |
| 41 |
% argument specifies the number of lines to add; negative numbers |
| 42 |
% \emph{remove} space, and fractional numbers are fine, too. For |
| 43 |
% example: |
| 44 |
% \begin{center} |
| 45 |
% \begin{tabular}{l>{\itshape\small}l} |
| 46 |
% |\addlines| & adds one line to the current page height\\ |
| 47 |
% |\addlines[2]| & adds two lines to the current page\\ |
| 48 |
% |\addlines[-0.5]| & subtracts half a line from the current page height |
| 49 |
% \end{tabular} |
| 50 |
% \end{center} |
| 51 |
% This command should be placed somewhere near the middle of the page |
| 52 |
% that it is intending to affect, and not be placed in the middle of |
| 53 |
% a paragraph or similar. |
| 54 |
% |
| 55 |
% \DescribeMacro{\addlines*} |
| 56 |
% A starred form of the command (\eg, \verb|\addlines*[2]|) performs |
| 57 |
% the same function as above without any checking and only on the current page. |
| 58 |
% In two-column mode this command adds lines only to the current \emph{column}. |
| 59 |
% |
| 60 |
% \DescribeMacro{\squeezepage} |
| 61 |
% When needing to break troublesome material on a page, it's sometimes necessary |
| 62 |
% to add to the amount of space added by \cmd\addlines, and additionally to ask \LaTeX\ |
| 63 |
% to squeeze the paage up (using shrinkability of the vertical boxes). |
| 64 |
% When used without an optional argument \cmd\squeezepage\ doesn't add any additional |
| 65 |
% space but does try to squeeze the page. |
| 66 |
% \cmd\squeezepage\oarg{lines} adds extra space before doing so. |
| 67 |
% |
| 68 |
% \DescribeMacro{\removelines} |
| 69 |
% For syntactic sugar, \cmd{\addline} is a synonym for \cmd\addlines, |
| 70 |
% and \cmd{\removeline\textcolor{gray}(s\textcolor{gray})} is the opposite of \cmd\addlines. |
| 71 |
% |
| 72 |
% For a double-sided document |
| 73 |
% (\eg, if the class option |[twoside]| is in |
| 74 |
% effect) extra height must be added to \emph{both pages} on a spread |
| 75 |
% for things to look good. If \cmd\addlines\ is called on an even page |
| 76 |
% (\ie, a \emph{verso} or left-side page) it adds the same space to its |
| 77 |
% facing page. Conversely, on an odd page (\ie, a \emph{recto} or right-side |
| 78 |
% page) an error is produced, but the space is still added. |
| 79 |
% |
| 80 |
% For a two-column document the situation is rather more complex --- the \cmd\addlines\ |
| 81 |
% call must be located within the first column, and for a twosided twocolumn layout |
| 82 |
% it must be the first column of the even page. The package attempts to |
| 83 |
% enforce this, calling similar errors if \cmd\addlines\ is found in the wrong |
| 84 |
% location in the source. |
| 85 |
% |
| 86 |
% These errors can be suppressed by loading \pkg{addlines} with the |[draft]| |
| 87 |
% package option. The option that indicates that errors should |
| 88 |
% be shown is |[final]|; this is activated by default but could be overridden with a |[draft]| |
| 89 |
% class option. |
| 90 |
% |
| 91 |
% \subsection*{Notes} |
| 92 |
% This command is a wrapper around the more basic command |
| 93 |
% \cmd\enlargethispage\ (for \cmd\addlines) and \verb|\enlargethispage*| (for \cmd\squeezepage). |
| 94 |
% It uses the \pkg{changepage} package to check if |
| 95 |
% the command is called on an even page, and the \pkg{afterpage} |
| 96 |
% package to add material to a facing odd page if necessary. |
| 97 |
% |
| 98 |
% The \pkg{changepage} mechanism for detecting page number oddness may |
| 99 |
% require more than a single \LaTeX\ compilation to stabilise, so |
| 100 |
% false positives may occur. If \pkg{memoir} is used, its |
| 101 |
% \cmd\strictpagechecktrue\ command is executed. |
| 102 |
% |
| 103 |
% \pkg{afterpage} may conflict poorly with |
| 104 |
% other packages that modify \LaTeX's output routine (\ie, the |
| 105 |
% algorithm used to chunk the document into discrete pages). |
| 106 |
% |
| 107 |
% \subsection*{Change history} |
| 108 |
% \begin{description} |
| 109 |
% \item[0.1] Initial version implementing the basic commands. |
| 110 |
% \item[0.2] Switched from \pkg{chngpage} to \pkg{changepage} and added package options |[draft]| and |[final]|. |
| 111 |
% \item[0.2a] Remove \verb|\usepackage{etex}| for better compatibility with \LaTeX\ 2015. |
| 112 |
% \item[0.3] Added \verb|\addlines*|, \verb|\squeezepage|, and two-column support. |
| 113 |
% \end{description} |
| 114 |
% |
| 115 |
% |
| 116 |
% \StopEventually{} |
| 117 |
% |
| 118 |
% \clearpage |
| 119 |
% \part{\pkg{\jobname} implementation} |
| 120 |
%\iffalse |
| 121 |
%<*package> |
| 122 |
%\fi |
| 123 |
% |
| 124 |
% |
| 125 |
% \begin{macrocode} |
| 126 |
\ProvidesPackage{addlines} |
| 127 |
[2018/12/05 v0.3 Add/remove lines from a page] |
| 128 |
% \end{macrocode} |
| 129 |
% |
| 130 |
% Packages: |
| 131 |
% \begin{macrocode} |
| 132 |
\RequirePackage{afterpage,changepage} |
| 133 |
% \end{macrocode} |
| 134 |
% |
| 135 |
% Option: |
| 136 |
% \begin{macrocode} |
| 137 |
\newif\if@addlines@checkpage@ |
| 138 |
\DeclareOption{final}{\@addlines@checkpage@true} |
| 139 |
\DeclareOption{draft}{\@addlines@checkpage@false} |
| 140 |
\ExecuteOptions{final} |
| 141 |
\ProcessOptions |
| 142 |
% \end{macrocode} |
| 143 |
% |
| 144 |
% \begin{macro}{\addlines} |
| 145 |
% \oarg{Number of lines to add to the text height} |
| 146 |
% \begin{macrocode} |
| 147 |
\newcommand\addlines{\@ifstar\addlines@a\addlines@b} |
| 148 |
\newcommand\addlines@a[1][1]{\addlines@here{#1}} |
| 149 |
\newcommand\addlines@b[1][1]{\addlines@do{#1}} |
| 150 |
\newcommand\addlines@here[1]{\enlargethispage{#1\baselineskip}} |
| 151 |
\newcommand\addlines@do[1]{% |
| 152 |
\if@twocolumn |
| 153 |
\addlines@twocol{#1}% |
| 154 |
\else |
| 155 |
\addlines@onecol{#1}% |
| 156 |
\fi |
| 157 |
} |
| 158 |
% \end{macrocode} |
| 159 |
% |
| 160 |
% \begin{macrocode} |
| 161 |
\newcommand\addlines@onecol[1]{% |
| 162 |
\addlines@here{#1}% |
| 163 |
\if@twoside |
| 164 |
\checkoddpage |
| 165 |
\ifoddpage |
| 166 |
\addlines@error{page} |
| 167 |
\else |
| 168 |
\afterpage{\addlines@here{#1}}% |
| 169 |
\fi |
| 170 |
\fi} |
| 171 |
% \end{macrocode} |
| 172 |
% |
| 173 |
% \begin{macrocode} |
| 174 |
\newcommand\addlines@twocol[1]{% |
| 175 |
\enlargethispage{#1\baselineskip}% |
| 176 |
\if@firstcolumn |
| 177 |
\afterpage{\enlargethispage{#1\baselineskip}}% |
| 178 |
\else |
| 179 |
\addlines@error{column}% |
| 180 |
\fi |
| 181 |
\if@twoside |
| 182 |
\checkoddpage |
| 183 |
\ifoddpage |
| 184 |
\addlines@error{page}% |
| 185 |
\else |
| 186 |
\afterpage{\afterpage{\addlines@here{#1}}}% |
| 187 |
\afterpage{\afterpage{\afterpage{\addlines@here{#1}}}}% |
| 188 |
\fi |
| 189 |
\fi} |
| 190 |
% \end{macrocode} |
| 191 |
% |
| 192 |
% \begin{macrocode} |
| 193 |
\newcommand\addlines@error[1]{% |
| 194 |
\if@addlines@checkpage@ |
| 195 |
\PackageError{addlines} |
| 196 |
{\MessageBreak You're adding lines to the wrong #1} |
| 197 |
{Extra lines need to be added to all columns and both sides of a doublepage spread.^^J |
| 198 |
This error might clear up after a recompile, though.}% |
| 199 |
\fi |
| 200 |
} |
| 201 |
% \end{macrocode} |
| 202 |
% |
| 203 |
% \begin{macrocode} |
| 204 |
\let\addline\addlines |
| 205 |
% \end{macrocode} |
| 206 |
% \end{macro} |
| 207 |
% |
| 208 |
% \begin{macro}{\removelines} |
| 209 |
% \oarg{Number of lines to remove from the text height} |
| 210 |
% Works with negative numbers through the miracles of $\varepsilon$-\TeX. |
| 211 |
% \begin{macrocode} |
| 212 |
\newcommand\removelines{\@ifstar\removelines@a\removelines@b} |
| 213 |
\newcommand\removelines@a[1][1]{\addlines@here{\numexpr -1*(#1) \relax}} |
| 214 |
\newcommand\removelines@b[1][1]{\addlines@do{\numexpr -1*(#1) \relax}} |
| 215 |
\let\removeline\removelines |
| 216 |
% \end{macrocode} |
| 217 |
% \end{macro} |
| 218 |
% |
| 219 |
% \begin{macro}{\squeezepage} |
| 220 |
% \oarg{Number of lines to add to the text height} |
| 221 |
% \begin{macrocode} |
| 222 |
\newcommand\squeezepage[1][0]{\enlargethispage*{#1\baselineskip}} |
| 223 |
% \end{macrocode} |
| 224 |
% \end{macro} |
| 225 |
% |
| 226 |
% |
| 227 |
% Finally, we don't want sloppy page number checking: |
| 228 |
% \begin{macrocode} |
| 229 |
\strictpagechecktrue |
| 230 |
% \end{macrocode} |
| 231 |
% |
| 232 |
%\iffalse |
| 233 |
%</package> |
| 234 |
%\fi |
| 235 |
% |
| 236 |
% |
| 237 |
%\iffalse |
| 238 |
%<*dtx-style> |
| 239 |
% \begin{macrocode} |
| 240 |
\ProvidesPackage{dtx-style} |
| 241 |
|
| 242 |
\errorcontextlines=999 |
| 243 |
|
| 244 |
\def\@dotsep{1000} |
| 245 |
\setcounter{tocdepth}{2} |
| 246 |
\setlength\columnseprule{0.1pt} |
| 247 |
\renewcommand\tableofcontents{\relax |
| 248 |
\begin{multicols}{2}[\section*{\contentsname}]\small |
| 249 |
\@starttoc{toc}\relax |
| 250 |
\end{multicols}} |
| 251 |
|
| 252 |
\setcounter{IndexColumns}{2} |
| 253 |
\renewenvironment{theglossary} |
| 254 |
{\small\list{}{} |
| 255 |
\item\relax |
| 256 |
\glossary@prologue\GlossaryParms |
| 257 |
\let\item\@idxitem \ignorespaces |
| 258 |
\def\pfill{\hspace*{\fill}}} |
| 259 |
{\endlist} |
| 260 |
|
| 261 |
\usepackage{xcolor} |
| 262 |
\usepackage{array,booktabs,calc,enumitem,fancyvrb,ifthen,refstyle,varioref,titlesec,url} |
| 263 |
\usepackage{addlines} |
| 264 |
|
| 265 |
\usepackage[sc,osf]{mathpazo} |
| 266 |
|
| 267 |
\linespread{1.069} % A bit more space between lines |
| 268 |
\frenchspacing % Remove extra space after punctuation |
| 269 |
\setlength\parindent{2em} |
| 270 |
\definecolor{niceblue}{rgb}{0.2,0.4,0.8} |
| 271 |
\def\theCodelineNo{\textcolor{niceblue}{\sffamily\tiny\arabic{CodelineNo}}} |
| 272 |
|
| 273 |
\newcommand*\pkg[1]{\textsf{#1}} |
| 274 |
\let\latin\textit |
| 275 |
\def\eg{\latin{e.g.}} |
| 276 |
\def\Eg{\latin{E.g.}} |
| 277 |
\def\ie{\latin{i.e.}} |
| 278 |
\def\etc{\@ifnextchar.{\latin{etc}}{\latin{etc.}\@}} |
| 279 |
\def\CTAN{\textsc{ctan}} |
| 280 |
|
| 281 |
\def\codeline{\par\hspace{\parindent}}% two \indents in total |
| 282 |
% \end{macrocode} |
| 283 |
%</dtx-style> |
| 284 |
%\fi |
| 285 |
% \typeout{*************************************************************} |
| 286 |
% \typeout{*} |
| 287 |
% \typeout{* To finish the installation you have to move the following} |
| 288 |
% \typeout{* file into a directory searched by XeTeX:} |
| 289 |
% \typeout{*} |
| 290 |
% \typeout{* \space\space\space addlines.sty} |
| 291 |
% \typeout{*} |
| 292 |
% \typeout{*************************************************************} |
| 293 |
\endinput |