summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/addlines/addlines.dtx
blob: 97fbd69d528fb5564cca089643825d63afd53e65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
% \iffalse 
%<*internal>
\iffalse
%</internal>
%<*readme>
____________________
The addlines package
v0.2

This package provides the command \addlines for adding 
or removing space in the textblock of the page it's
used on. E.g., adding an extra line of text to the page
so that a section fits better on the next page.

It will also add space to the *facing* page in a 
two-sided document.

An inverse command is provided if you prefer it:
  \removelines{ x } == \addlines{ -x }
  
See addlines.pdf for more info.

______________
Will Robertson
wspr 81 [at] gmail [dot] com

Copyright 2007-2008
Distributed under the LaTeX Project Public License
%</readme>
%<*internal>
\fi
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\preamble

  _______________________________________
  Copyright (C) 2007-2008  Will Robertson

  License information appended.


\endpreamble
\postamble

Copyright (C) 2007-2008 by Will Robertson <wspr81@gmail.com>

Distributable under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
this license is at: http://www.latex-project.org/lppl.txt

This work is "maintained" (as per LPPL maintenance status) 
by Will Robertson.

This work consists of the files addlines.dtx and
                                addlines.ins,
          and the derived files addlines.pdf,
                                addlines.sty, and
                                addlines-example.ltx.

\endpostamble
\askforoverwritefalse
\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}}
\generate{\file{\jobname-example.ltx}{\from{\jobname.dtx}{example}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}}
\nopreamble\nopostamble
\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}}
\generate{\file{prepare.sh}{\from{\jobname.dtx}{prepare}}}
\generate{\file{dtx-style.sty}{\from{\jobname.dtx}{dtx-style}}}
\endgroup
\immediate\write18{makeindex -s gind.ist -o \jobname.ind  \jobname.idx}
\immediate\write18{makeindex -s gglo.ist -o \jobname.gls  \jobname.glo}
%</internal>
%
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\usepackage{dtx-style}
\begin{document}
  \DocInput{addlines.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{\jobname.sty}
% \CheckSum{0}
% \makeatletter
%
% \title{The \pkg{\jobname} package}
% \author{Will Robertson}
% \date{\filedate \qquad \fileversion}
%
% \maketitle
%
% \noindent
% This is a small package that defines a user command for adding lines
% to the current (and facing page, if appropriate). This is intended to be used in the 
% final typesetting
% process of a manuscript for running pages long or short in order to
% fit their material better (starting a paragraph on the next page,
% for example).
%
% The \cmd\addlines\ command adds enough vertical space to
% the current text block to fit in one more line of text. An optional
% argument specifies the number of lines to add; negative numbers
% \emph{remove} space, and fractional numbers are fine, too. For
% example:
% \begin{center}
% \begin{tabular}{l>{\itshape\small}l}
%  |\addlines| & adds one line to the current page height\\
%  |\addlines[2]| & adds two lines to the current page\\
%  |\addlines[-1]| & subtracts one line from the current page height
% \end{tabular}
% \end{center}
%
% The command should be placed somewhere near the middle of the page
% that it is intending to affect. Too near the top and it may not be
% seen in time (\LaTeX's page breaking routine is asynchronous).
%
% For syntactic sugar, \cmd{\addline} is a synonym for \cmd\addlines,
% and \cmd{\removeline\textcolor{gray}(s\textcolor{gray})} is the opposite of \cmd\addlines.
%
% As alluded to in the introduction, for a double-sided document 
% (\eg, if the class option |[twoside]| is in
% effect) extra height must be added to \emph{both pages} on a spread
% for things to look good. If \cmd\addlines\ is called on an even page
% (\ie, a \emph{verso} or left-side page) it adds the same space to its
% facing page. Conversely, on an odd page (\ie, a \emph{recto} or right-side
% page) an error is produced, but the space is still added.
%
% These errors can be suppressed by loading \pkg{addlines} with the |[draft]|
% package option. The option that indicates that errors should
% be shown is |[final]|; this is activated by default but could be overridden with a |[draft]| 
% class option.
%
% \subsection*{Notes}
% This command is a wrapper around the more basic command
% \cmd\enlargethispage. It uses the \pkg{changepage} package to check if
% the command is called on an even page, and the \pkg{afterpage}
% package to add material to a facing odd page if necessary.
%
% The \pkg{changepage} mechanism for detecting page number oddness may
% require more than a single \LaTeX\ compilation to stabilise, so
% false positives may occur. If \pkg{memoir} is used, its
% \cmd\strictpagechecktrue\ command is executed.
%
% \pkg{afterpage} may conflict poorly with
% other packages that modify \LaTeX's output routine (\ie, the
% algorithm used to chunk the document into discrete pages).
%
% Uses $\varepsilon$-\TeX\ because I'm lazy.
%
% \subsection*{Example document}
% 
%    \begin{macrocode}
%<*example>
\documentclass[twoside]{article}
\usepackage[a5paper,width=30em,lines=30]{geometry}
\usepackage{lipsum}
\usepackage{addlines}
\begin{document}
\lipsum[1-5]

\emph{Here is the command used correctly on an even page.}
\addlines

\lipsum[6-15]

\emph{Here is the command used erroneously on an odd page.}
\addlines

\lipsum[16-20]
\end{document}
%</example>
%    \end{macrocode}
%
% \subsection*{Change history}
% \begin{description}
% \item[0.1] Initial version implementing the basic commands.
% \item[0.2] Switched from \pkg{chngpage} to \pkg{changepage} and added package options |[draft]| and |[final]|.
% \end{description}
% 
% 
%
% \StopEventually{}
%
% \clearpage
% \part{\pkg{\jobname} implementation}
%\iffalse
%<*package>
%\fi
%
%
%    \begin{macrocode}
\ProvidesPackage{addlines}
  [2008/08/16 v0.2 Add/remove lines from a page]
%    \end{macrocode}
%
% Packages:
%    \begin{macrocode}
\RequirePackage{etex,afterpage,changepage}
%    \end{macrocode}
%
% Option:
%    \begin{macrocode}
\newif\if@addlines@checkpage@
\DeclareOption{final}{\@addlines@checkpage@true}
\DeclareOption{draft}{\@addlines@checkpage@false}
\ExecuteOptions{final}
\ProcessOptions
%    \end{macrocode}
%
% \begin{macro}{\addlines}
% \oarg{Number of lines to add to the text height}
%    \begin{macrocode}
\newcommand\addlines[1][1]{%
  \enlargethispage{#1\baselineskip}%
  \if@addlines@checkpage@
    \if@twoside
      \checkoddpage
      \ifoddpage
        \PackageError{addlines}
          {You're adding lines to the wrong page}
          {Extra lines need to be added to both sides of a doublepage spread.^^J
           This error might clear up after a recompile, though.}%
      \else
        \afterpage{\enlargethispage{#1\baselineskip}}%
      \fi
    \fi
  \fi}
\let\addline\addlines
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\removelines}
% \oarg{Number of lines to remove from the text height}
% Works with negative numbers through the miracles of $\varepsilon$-\TeX.
%    \begin{macrocode}
\newcommand\removelines[1][1]{%
  \addlines[\numexpr -1*(#1) \relax]}
\let\removeline\removelines
%    \end{macrocode}
% \end{macro}
%
% Finally, we don't want sloppy page number checking:
%    \begin{macrocode}
\strictpagechecktrue
%    \end{macrocode}
%
%\iffalse
%</package>
%\fi
%
%
%\iffalse
%<*dtx-style>
%    \begin{macrocode}
\ProvidesPackage{dtx-style}

\errorcontextlines=999

\def\@dotsep{1000}
\setcounter{tocdepth}{2}
\setlength\columnseprule{0.1pt}
\renewcommand\tableofcontents{\relax
  \begin{multicols}{2}[\section*{\contentsname}]\small
    \@starttoc{toc}\relax
  \end{multicols}}

\setcounter{IndexColumns}{2}
\renewenvironment{theglossary}
  {\small\list{}{}
     \item\relax
     \glossary@prologue\GlossaryParms 
     \let\item\@idxitem \ignorespaces 
     \def\pfill{\hspace*{\fill}}}
  {\endlist}

\usepackage{xcolor}
\usepackage{array,booktabs,calc,enumitem,fancyvrb,addlines,ifthen,refstyle,varioref,titlesec,url}

\usepackage[sc,osf]{mathpazo}

\linespread{1.069}      % A bit more space between lines
\frenchspacing         % Remove extra space after punctuation
\setlength\parindent{2em}
\definecolor{niceblue}{rgb}{0.2,0.4,0.8}
\def\theCodelineNo{\textcolor{niceblue}{\sffamily\tiny\arabic{CodelineNo}}}

\newcommand*\name[1]{{#1}}
\newcommand*\pkg[1]{\textsf{#1}}
\newcommand*\feat[1]{\texttt{#1}}
\newcommand*\opt[1]{\texttt{#1}}
\newcommand*\note[1]{\unskip\footnote{#1}}
\let\latin\textit
\def\eg{\latin{e.g.}}
\def\Eg{\latin{E.g.}}
\def\ie{\latin{i.e.}}
\def\etc{\@ifnextchar.{\latin{etc}}{\latin{etc.}\@}}
\def\CTAN{\textsc{ctan}}

\newcounter{argument}
\g@addto@macro\endmacro{\setcounter{argument}{0}}
\newcommand*\darg[1]{%
  \stepcounter{argument}%
  {\ttfamily\char`\#\theargument~:~}#1\par\noindent\ignorespaces}
\newcommand*\doarg[1]{%
  \stepcounter{argument}%
  {\ttfamily\makebox[0pt][r]{[}\char`\#\theargument]:~}#1\par\noindent\ignorespaces}

\def\codeline{\par\hspace{\parindent}}% two \indents in total
%    \end{macrocode}
%</dtx-style>
%<*prepare>
rm addlines.zip
latex addlines.dtx
mv README.txt README

zip addlines.zip addlines.dtx addlines.ins addlines.pdf README
%</prepare>
%\fi
% \typeout{*************************************************************}
% \typeout{*}
% \typeout{* To finish the installation you have to move the following}
% \typeout{* file into a directory searched by XeTeX:}
% \typeout{*}
% \typeout{* \space\space\space addlines.sty}
% \typeout{*}
% \typeout{*************************************************************}
\endinput