summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/clrdblpg/clrdblpg.dtx
blob: 0bdc44edaeb7a4bc636a391dc2231007782e514b (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
% \iffalse
% +AMDG  This document was begun on 19 April 1202, the
% feast of St. Anselm, and it is humbly dedicated to him
% and to the Immaculate Heart of Mary for
% their prayers, and to the Sacred Heart of Jesus for His
% mercy.
%
% This document is copyright 2018 by Donald P. Goodman, and is
% released publicly under the LaTeX Project Public License.  The
% distribution and modification of this work is constrained by the
% conditions of that license.  See
% 	http://www.latex-project.org/lppl.txt
% for the text of the license.  This document is released
% under version 1.3 of that license, and this work may be distributed
% or modified under the terms of that license or, at your option, any
% later version.
% 
% This work has the LPPL maintenance status 'maintained'.
% 
% The Current Maintainer of this work is Donald P. Goodman
% (dgoodmaniii@gmail.com).
% 
% This work consists of clrdblpg.dtx, clrdblpg.ins, and
% derived files clrdblpg.sty and clrdblpg.pdf.
% \fi

% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{clrdblpg}[2018/04/21 v1.0 Control page style of blank pages]
%<*driver>
\documentclass{ltxdoc}

\usepackage{doc}
\usepackage{xurl}
\usepackage{luatex85}
\usepackage{lmodern}
\usepackage[]{clrdblpg}
\usepackage[colorlinks]{hyperref}

\begin{document}
\DocInput{clrdblpg.dtx}
\end{document}
%</driver> \fi
%
% \title{The |clrdblpg| Package, v1.0}
% \author{Donald P.\ Goodman III}
% \date{\today}
%
% \maketitle
%
% \begin{abstract}
% \noindent
% This tiny package allows easy manipulation of the headers
% and footers on pages left blank by |\cleardoublepage|.  By
% default, \LaTeX\ has no easy facilities for this.  This
% package uses more or less the algorithm listed in the
% |fancyhdr| package documentation, with some added
% flexibility thrown in.
% \end{abstract}
%
% \tableofcontents
%
% \section{Introduction}
%
% \LaTeX\ clears double pages when using certain classes
% because certain divisions, such as chapters, must normally
% start on recto (odd) pages.  This sometimes results in a
% page which is blank.  However, \LaTeX\ puts the normal
% page dressings on these blank pages.  This might be the
% right decision in certain cases; but in other cases, it's
% certainly wrong.  Yet there is no easy way to change this
% behavior.
%
% \section{Usage}
%
% So here's |clrdblpg|.  This tiny package takes an
% algorithm redefining the normal \LaTeX\ command
% |\cleardoublepage| from the |fancyhdr| documentation (by
% Piet van Oostrum and George Gr{\"a}tzer), but indents it
% better and adds the ability to control which page style
% will be applied to the blank pages.
%
% To see the original algorithm, and the excellent
% |fancyhdr| package which you should almost certainly
% already be using, see \url{http://ctan.org/pkg/fancyhdr}.
%
% To use the package, simply load the package |clrdblpg|
% with the |style| option expressing what page style you
% want.  The default is to set the blank pages as having
% page style |empty|, so if that's what you want, you do not
% need to list an option.
%
% \begin{center}
% \begin{tabular}{lp{0.4\textwidth}}
% |\usepackage{clrdblpg}| & Leaves cleared verso pages
%		empty, with neither header nor footer \\
% |\usepackage[style=empty]{clrdblpg}| & Leaves cleared verso pages
%		empty, with neither header nor footer \\
% |\usepackage[style=plain]{clrdblpg}| & Leaves cleared verso pages
%		with the |plain| style, meaning no header and a
%		centered page number for a footer \\
% \end{tabular}
% \end{center}
%
% Obviously, any page style (defined by \LaTeX, some class
% or package, or you) can be used instead.
%
% And that's it for this little package.
%
% \section{Implementation}
%
% Start with a reasonable default.  I don't personally think
% the \LaTeX\ default here is reasonable, so I've not done
% it.  I think |empty| makes sense; hence, the default.
%    \begin{macrocode}
\def\clrdblpg@pagestyle{empty}%
%    \end{macrocode}
% Require |xkeyval|, and set our package option.
%    \begin{macrocode}
\RequirePackage{xkeyval}
\DeclareOptionX{style}{\def\clrdblpg@pagestyle{#1}}
\ProcessOptionsX
%    \end{macrocode}
% Now define the command.  This is taken directly from the
% documentation of the |fancyhdr| package
% (\url{http://ctan.org/pkg/fancyhdr}),
% but with better
% indentation and the ability to select a pagestyle for the
% blank page.
%    \begin{macrocode}
\def\cleardoublepage{%
	\clearpage%
	\if@twoside%
		\ifodd%
			\c@page%
		\else%
			\hbox{}%
			\vspace*{\fill}%
			\thispagestyle{\clrdblpg@pagestyle}%
			\newpage%
			\if@twocolumn%
				\hbox{}%
				\newpage%
			\fi%
		\fi%
	\fi%
}%
%    \end{macrocode}
% And there's the |clrdblpg| package.  I hope it proves
% useful to someone besides myself.  Happy \TeX{}ing!
%
% \PrintIndex