Debian Codegraph @

texmf-dist/source/latex/quotchap/quotchap.dtx

raw
1 % \iffalse meta-comment
2 %
3 % This file is part of the QUOTCHAP package, a package for creating
4 % decorative chapter headings with quotations, a postscript output
5 % device is needed.
6 % Copyright (C) 1998 - 2010 Karsten Tinnefeld.
7 % Copyright (C) 2011 - 2020 Jan Klever.
8 %
9 % This file is NOT part of the LaTeX2e system, but intended for use with it.
10 %
11 % This document is free software; you can redistribute it and/or modify it
12 % under the terms of the GNU Library General Public License as published by
13 % the Free Software Foundation; either version 2 of the License, or (at your
14 % option) any later version.
15 %
16 % This document is distributed in the hope that it will be useful, but WITHOUT
17 % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 % more details.
20 %
21 % You should have received a copy of the GNU General Public License somehow;
22 % if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
23 % Cambridge, MA 02139, USA.
24 %
25 % INSTALLATION:
26 %%%%%%%%%%%%%%%
27 %
28 % Install this style by running the file `quotchap.ins' through' TeX. This will
29 % create the file `quotchap.sty' and, if your docstrip.cfg is set up the right
30 % way (has a \BaseDirectory{<path to my texmf directory>}, see the
31 % docstrip-documentation), automatically moved to \$TEXMF/tex/latex/misc.
32 %
33 % The documentation is created by running `latex quotchap.dtx`. This
34 % does not need the file quotchap.sty nor postscript fonts, but Frank
35 % Mittelbach's multicol package should exist.
36 %
37 \NeedsTeXFormat{LaTeX2e}[1996/12/01]
38 %<*dtx>
39 \ProvidesFile{quotchap.dtx}
40 %</dtx>
41 %<!driver>\ProvidesPackage{quotchap}
42 %<driver>\ProvidesFile{quotchap.drv}
43 % \fi
44 % \ProvidesFile{quotchap.dtx}
45 [2020/11/13 v1.3 Decorative Chapter Headings with Quotes]
46 %
47 % \iffalse
48 %<*driver>
49 \documentclass{ltxdoc}
50 \usepackage{multicol}
51 \GetFileInfo{quotchap.dtx}
52 \newcommand*{\docdate}{2020/11/13}
53 \RecordChanges
54 \begin{document}
55 \DocInput{\filename}
56 \end{document}
57 %</driver>
58 % \fi
59 %
60 % \CheckSum{210}
61 %
62 % \DoNotIndex{\@M,\@afterindentfalse,%
63 % \@topnum,\advance,\AtEndOfPackage,\baselineskip,\begin,\bigskip,%
64 % \c@secnumdepth,%
65 % \cleardoublepage,\clearpage,\color,\copy,\CurrentOption,\DeclareOption,%
66 % \def,%
67 % \definecolor,\edef,\else,\end,\fi,\fontsize,\footnotesize,%
68 % \global,\hbox,\huge,\@ifundefined,\if@mainmatter,\if@openright,%
69 % \IfFileExists,\ifnum,\ignorespacesafterend,%
70 % \ignorespaces,\interlinepenalty,\leftmargin,\let,\m@ne,%
71 % \MessageBreak,\newcommand,\newenvironment,\newif,\newsavebox,%
72 % \nobreak,\PackageError,\PackageWarning,\par,\ProcessOptions,%
73 % \providecommand,\qquad,%
74 % \raggedleft,\relax,\renewcommand,\RequirePackage,\secdef,\selectfont,%
75 % \setbox,\slshape,\smallskip,\thechapter,\thispagestyle,\unskip,%
76 % \upshape,\usefont,\vbox,\vspace,\vss,\verb,\z@}
77 %
78 % \date{printed \today}
79 % \title{The \texttt{quotchap} package\thanks{%
80 % This file has version number \fileversion,
81 % last revised on \filedate, documentation dated \docdate.}}
82 % \author{Karsten Tinnefeld\thanks{%
83 % Thanks to Stefan Mintert for the chapter number layout
84 % idea basing on his \protect\textsf{iNA}\protect\texttt{book}
85 % class.}\and Jan Klever\\\texttt{[email protected]}}
86 % \maketitle
87 %
88 % \begin{abstract}
89 % This document describes the \texttt{quotchap} package. This package
90 % redefines the |\chapter| and |\chapter*| commands to
91 % create fancy chapter head pages with huge chapter numbers
92 % (possibly greyed) and provides commands for adding quotations in the
93 % upper left corner of these pages. It was written by Karsten Tinnefeld,
94 % who abandoned to work on it. This package is now maintained by Jan Klever.
95 % \end{abstract}
96 %
97 % \section{Introduction}
98 %
99 % \texttt{quotchap} is designed to do visual formatting and build some fancy
100 % and attractive chapter headings for documents. It buries the original
101 % |\chapter|[|*|]-commands to provide a new style: Chapter number and title
102 % are set flush right, on separate lines, and much huger as normal: The title
103 % is to be |\Huge|, the number is set in $100$pt size, and possibly in $60\%$
104 % grey (not to blacken the page more than necessary). This means, of course,
105 % that some scalable font had to be chosen. We offer package options for all the
106 % postscript fonts in the \textsc{psnfss} package and some other common fonts,
107 % defaulting to Adobe's Bookman for matters of personal taste. You can choose
108 % any font for the chapter number by using the command |\qsetcnfont|.
109 %
110 % \section{Quotations}
111 %
112 % This package provides the feature to include some quotations right before
113 % the beginning of the chapter. An environment is given to save quotes to be
114 % used at the beginning of the next chapter, and an additional command gives
115 % an easy way to provide author information to the quotes.
116 %
117 % \DescribeEnv{savequote}
118 % The |savequote| environment should appear at the top level, not in
119 % the document's preamble (i.e., after |\begin{document}|) and before
120 % the start of the chapter you want to decorate. It has one optional
121 % argument that provides the width
122 % of the quotation paragraph. The default is $10$cm (approx.
123 % $3.94$in). Possibly you may want to set your quote in ``quotation
124 % marks'', as these marks differ from country to country, it is left
125 % to you.
126 %
127 % \DescribeMacro{qauthor}
128 % Each quotation can consist of several paragraphs, but must end with
129 % a |\qauthor{A. U. Thor}| command. This is not only provided to
130 % uphold the principles of ``honour whom honour is due'' but to provide
131 % the right author name formatting and inter quotation spacing. The
132 % quotes can follow each other immediately.
133 %
134 % The whole bunch of quotation is deleted after it has been printed
135 % once, so you have to rewrite them when you find no way past
136 % repeating them. When you give no quotations for some chapter, the
137 % upper left area of the corresponding page will be simply void.
138 %
139 % \DescribeMacro{qsetcnfont}
140 % If you want to use a font for the chapter number, that is not
141 % available as package optionen, you can set it with
142 % |\qsetcnfont{<family>}|. For example: |\qsetcnfont{pzc}|
143 % to use Zapf Chancery.
144 %
145 % \DescribeMacro{quotefont}
146 % The font for quotations can be set globally with |\quotefont|. For
147 % example: |\renewcommand\quotefont{\sffamily\slshape}|. The default
148 % is |\slshape|.
149 %
150 % \DescribeMacro{qauthorfont}
151 % The font for the author of the quote can be set globally with
152 % |\qauthorfont|. For example: |\renewcommand\qauthorfont{\scshape}|.
153 % The default ist |\upshape|.
154 % \section{Examples}
155 %
156 % Let's take a look at an example:\medskip
157 %
158 % \begin{multicols}{2}
159 % \begin{verbatim}
160 %\begin{savequote}[45mm]
161 % ---When shall we three meet again
162 % in thunder, lightning, or in rain?
163 %
164 % ---When the hurlyburly's done,
165 % when the battle's lost and won.
166 % \qauthor{Shakespeare, Macbeth}
167 % Cookies! Give me some cookies!
168 % \qauthor{Cookie Monster}
169 %\end{savequote}
170 %
171 %\chapter{Classic Sesame Street}
172 % \end{verbatim}
173 %
174 % \vfill
175 % \begin{minipage}[t]{45mm}\footnotesize\slshape
176 % ---When shall we three meet again
177 % in thunder, lightning, or in rain?
178 %
179 % ---When the hurlyburly's done,
180 % when the battle's lost and won.\par\smallskip
181 % {\raggedleft\upshape
182 % Shakespeare, Macbeth\qquad\hbox{}\par}\bigskip
183 % Cookies! Give me some cookies!\par\smallskip
184 % {\raggedleft\upshape
185 % Cookie Monster\qquad\hbox{}\par}
186 % \end{minipage}\bigskip
187 %
188 % \noindent (chapter start page not demonstrated---try for yourself.)
189 % \vfill
190 % \end{multicols}
191 %
192 % \section{Document Options}
193 % Printing the chapter number in bold and that big a font uses quite
194 % some ink on the paper. Thus it is strongly recommended to
195 % use the \textbf{grey} option (which is enabled by default and
196 % disabled by specifying \textbf{nogrey}) that improves the quality by
197 % printing the number in $60\%$ grey. The \texttt{color} package is used to
198 % set the colour |chaptergrey|, redefining this colour may produce even more
199 % colourful effects.
200 %
201 % The \texttt{color} package is |\Require|d without any option, if
202 % you want to specify some, include the color package before the
203 % quotchap package.
204 %
205 % The other options are used to select a title font, they are all
206 % self-explaining and thus simply listed here:
207 % \begin{description}
208 % \item[avantgarde] Adobe's Avantgarde
209 % \item[beramono] Bera Mono
210 % \item[berasans] Bera Sans
211 % \item[beraserif] Bera Serif
212 % \item[biolinum] Biolinum
213 % \item[bookman] Adobe's Bookman (default)
214 % \item[charter] Bitstream's Charter BT
215 % \item[courier] Adobe's Courier
216 % \item[helvetica] Adobe's Helvetica
217 % \item[kpfonts] Kp-Fonts
218 % \item[libertine] Libertine
219 % \item[lmodern] Latin Modern
220 % \item[newcentury] Adobe's New Century Schoolbook
221 % \item[palatino] Adobe's Palatino
222 % \item[times] Adobe's Times
223 % \item[utopia] Adobe's Utopia
224 % \end{description}
225 %
226 % \StopEventually{}
227 %
228 % \section{Implementation}
229 %
230 % Ok, here comes the code.
231 %
232 % \subsection{Option parsing}
233 % The first part is about parsing the options. We may not
234 % |\RequirePackage|s in here and thus define a flag: |@usecolor| is
235 % true whenever the \textbf{grey} option is specified.
236 %
237 % \begin{macrocode}
238 \newif\if@usecolor\@usecolortrue
239 \DeclareOption{grey}{\@usecolortrue}
240 \DeclareOption{nogrey}{\@usecolorfalse}
241 % \end{macrocode}
242 %
243 % For the fonts, there follows a bunch of options that are all meant
244 % to be specified exclusively. It would have been possible to use
245 % |\newcommand| to ensure this, but it gives cryptic errors. Rather
246 % check this first.
247 %
248 % \begin{macrocode}
249 \newcommand*{\@newfontcmd}{\@ifundefined{@defaultcnfont}{\newcommand*}{%
250 \PackageWarning{quotchap}{%
251 You have tried to specify more than one font to be\MessageBreak
252 used for the chapter numbers. I ignore the font\MessageBreak
253 `\CurrentOption'}
254 \providecommand*}}
255 % \end{macrocode}
256 %
257 % Next is defining the font options. We set |\@defaultcnfont|
258 % according to Karl Berry's font name scheme. Providing more than one
259 % font gives an error (due to defining an already defined command);
260 % the options exclude each other.
261 %
262 % \begin{macrocode}
263 \DeclareOption{avantgarde}{\@newfontcmd{\@defaultcnfont}{pag}}
264 \DeclareOption{beramono}{\@newfontcmd{\@defaultcnfont}{fvm}}
265 \DeclareOption{berasans}{\@newfontcmd{\@defaultcnfont}{fvs}}
266 \DeclareOption{beraserif}{\@newfontcmd{\@defaultcnfont}{fve}}
267 \DeclareOption{biolinum}{\@newfontcmd{\@defaultcnfont}{LinuxBiolinumO-LF}}
268 \DeclareOption{bookman}{\@newfontcmd{\@defaultcnfont}{pbk}}
269 \DeclareOption{charter}{\@newfontcmd{\@defaultcnfont}{bch}}
270 \DeclareOption{courier}{\@newfontcmd{\@defaultcnfont}{pcr}}
271 \DeclareOption{helvetica}{\@newfontcmd{\@defaultcnfont}{phv}}
272 \DeclareOption{kpfonts}{\@newfontcmd{\@defaultcnfont}{jkp}}
273 \DeclareOption{libertine}{\@newfontcmd{\@defaultcnfont}{LinuxLibertineO-LF}}
274 \DeclareOption{lmodern}{\@newfontcmd{\@defaultcnfont}{lmr}}
275 \DeclareOption{newcentury}{\@newfontcmd{\@defaultcnfont}{pnc}}
276 \DeclareOption{palatino}{\@newfontcmd{\@defaultcnfont}{ppl}}
277 \DeclareOption{times}{\@newfontcmd{\@defaultcnfont}{ptm}}
278 \DeclareOption{utopia}{\@newfontcmd{\@defaultcnfont}{put}}
279 % \end{macrocode}
280 %
281 % We can now let the options be processed. If no postscript font has
282 % been specified, the default is Adobe's Bookman.
283 %
284 % \begin{macrocode}
285 \ProcessOptions\relax
286 \providecommand*{\@defaultcnfont}{pbk}
287 % \end{macrocode}
288 %
289 % If nobody said \textbf{nogrey}, we fetch the |color| package and
290 % define our colour. If the color package is not included until now,
291 % we define |\color| to do nothing but gobble up its argument.
292 % An error is issued when \textbf{grey} is turned on and the color
293 % package is nonexistent. When you read the documentation because of
294 % this: \texttt{color.sty} is included in the graphics bundle to be
295 % found at \textsc{ctan}.
296 %
297 % \begin{macrocode}
298 \if@usecolor
299 \IfFileExists{color.sty}{%
300 \RequirePackage{color}
301 \definecolor{chaptergrey}{rgb}{0.6,0.6,0.6}}{%
302 \PackageError{quotchap}{%
303 The color package is apparently unavailable.\MessageBreak
304 Turn off the `grey' option and come back again}{%
305 Since you did not say `nogrey', quotchap defined chapter
306 numbers to appear\MessageBreak grey. You do not need a color
307 printer, since most printing devices can cope\MessageBreak with
308 grey scales, but you need the color package coming with the
309 graphics\MessageBreak bundle available from CTAN.}}
310 \else
311 \providecommand*{\color}[1]{}
312 \fi
313 % \end{macrocode}
314 %
315 % Now we are ready to give the final font declarations. The
316 % commands |\sectfont| and
317 % |\chapterhead|\{|start|\textbar|end|\}|vskip| are defined in the
318 % \textsf{KOMA-Script} classes the chapter is based on,
319 % they are provided in case |quotchap| is used with other, e.g.
320 % the default classes. If we are building a report, there is no
321 % |\frontmatter|, |\mainmatter| and |\backmatter| resp. everything is
322 % |\mainmatter|, thus we have to provide the corresponding switch
323 % used in the |\chapter| command.
324 %
325 % \begin{macrocode}
326 \AtEndOfPackage{%
327 \newcommand*{\chapnumfont}{%
328 \usefont{\f@encoding}{\@defaultcnfont}{b}{n}\fontsize{100}{130}\selectfont%
329 \color{chaptergrey}}
330 \let\size@chapter\huge
331 \providecommand*{\chapterheadstartvskip}{\vspace*{2.3\baselineskip}}
332 \providecommand*{\chapterheadendvskip}{\vspace{1.7\baselineskip}}
333 \providecommand*{\sectfont}{\relax}
334 \providecommand*{\quotefont}{\slshape}
335 \providecommand*{\qauthorfont}{\upshape}
336 \@ifundefined{@mainmattertrue}{\newif\if@mainmatter\@mainmattertrue}{}}
337 % \end{macrocode}
338 %
339 % \subsection{User Level Commands}
340 %
341 % \begin{macro}{savequote}
342 % Here go the top level command declarations (and definitions, too).
343 % We use the |lrbox| environment to save the contents of the whole
344 % environment in a horizontal box. The quotes are effectively a
345 % paragraph box typeset in footnote size and oblique style, to the
346 % width given as a parameter, while any spacing at the beginning
347 % and the end of the environment is ignored. Since
348 % |\newenvironment| implies a group, we have to make the box
349 % |\@quotebox| global explicitly.
350 %
351 % Finally, we enable the box insertion command that is disabled
352 % initially and after each chapter heading. (Possibly it is faster
353 % to delete the save box contents and insert a nearly-empty vertical
354 % box at each chapter---profilers to the front.)
355 %
356 % \begin{macrocode}
357 \newenvironment{savequote}[1][10cm]{%
358 \begin{lrbox}{\@quotebox}
359 \begin{minipage}[t]{#1}\footnotesize\quotefont
360 \ignorespaces}{%
361 \unskip\end{minipage}\end{lrbox}
362 \global\setbox\@quotebox\copy\@quotebox
363 \global\let\@printcites\@iprintcites
364 \ignorespacesafterend}
365 % \end{macrocode}
366 % \end{macro}
367 %
368 % \begin{macro}{\qauthor}
369 % The |\qauthor| command simply selects some font and
370 % skip---lets the name be set in roman letters and flush right at
371 % two ems distance from the margin.
372 %
373 % \begin{macrocode}
374 \newcommand{\qauthor}[1]{%
375 \par\smallskip
376 {\raggedleft\qauthorfont #1\qquad\hbox{}\par}\bigskip}
377 % \end{macrocode}
378 % \end{macro}
379 %
380 % \begin{macro}{\qsetcnfont}
381 % The user can set any font for the chapter number by providing its family
382 % name to this command.
383 % \begin{macrocode}
384 \newcommand{\qsetcnfont}[1]{%
385 \renewcommand*{\@defaultcnfont}{#1}}
386 % \end{macrocode}
387 % \end{macro}
388 %
389 % \subsection{Making up the chapter heading}
390 %
391 % Here are the modification to the chapter command definitions of
392 % the \textsf{KOMA-Script} document classes. This package was
393 % originally designed to
394 % co-operate only with them; therefore we have to provide some
395 % measurement defined only there. We insert the citations (if available)
396 % by calling the insert box or do nothing wrapper.
397 %
398 % The second modification is the formatting of the heading. If there
399 % is a chapter number to be printed, our really huge font is selected
400 % and the number is typeset to the right margin, followed by the
401 % title, as usual.
402 %
403 % \begin{macrocode}
404 \newsavebox{\@quotebox}
405 \let\@printcites\relax
406 \renewcommand\chapter{%
407 \if@openright\cleardoublepage\else\clearpage\fi
408 \thispagestyle{plain}%
409 \global\@topnum\z@
410 \@printcites
411 \@afterindentfalse
412 \secdef\@chapter\@schapter}
413 \renewcommand{\@makechapterhead}[1]{\chapterheadstartvskip%
414 {\size@chapter{\sectfont\raggedleft
415 {\chapnumfont
416 \ifnum \c@secnumdepth >\m@ne%
417 \if@mainmatter\thechapter%
418 \fi\fi
419 \par\nobreak}%
420 {\raggedleft\advance\leftmargin10em\interlinepenalty\@M #1\par}}
421 \nobreak\chapterheadendvskip}}
422 \renewcommand{\@makeschapterhead}[1]{%
423 {\let\c@secnumdepth\m@ne\@makechapterhead{#1}}}
424 \newcommand*{\@iprintcites}{%
425 \vbox to\z@{\copy\@quotebox\vss}
426 \global\let\@printcites\relax}
427 % \end{macrocode}
428 %
429 % And this is it. Happy \TeX ing!
430 %
431 %\Finale
432 %
433 %% \CharacterTable
434 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
435 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
436 %% Digits \0\1\2\3\4\5\6\7\8\9
437 %% Exclamation \! Double quote \" Hash (number) \#
438 %% Dollar \$ Percent \% Ampersand \&
439 %% Acute accent \' Left paren \( Right paren \)
440 %% Asterisk \* Plus \+ Comma \,
441 %% Minus \- Point \. Solidus \/
442 %% Colon \: Semicolon \; Less than \<
443 %% Equals \= Greater than \> Question mark \?
444 %% Commercial at \@ Left bracket \[ Backslash \\
445 %% Right bracket \] Circumflex \^ Underscore \_
446 %% Grave accent \` Left brace \{ Vertical bar \|
447 %% Right brace \} Tilde \~}
448 %
449 %\endinput
450 %
451 % LocalWords: QUOTCHAP quotchap sty docstrip cfg texmf EXMF tex misc dtx drv
452 % LocalWords: multicol iNA tinnefeld irb cs uni dortmund de pt psnfss qauthor
453 % LocalWords: savequote nogrey color chaptergrey xdvi BT palatino avantgarde
454 % LocalWords: helvetica newcentury usecolor defaultcnfont bch ppl pag pbk pcr
455 % LocalWords: phv pnc ptm ctan rgb vskip lrbox co em ing