Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % File: cd.dtx Copyright (C) 1998-2007 Sebastiano Vigna
4 % Copyright (C) 2014 Werner Lemberg
5 %
6 % This file is free software; you can redistribute it and/or modify
7 % it under the terms of the GNU General Public License as published by
8 % the Free Software Foundation; either version 2 of the License, or
9 % (at your option) any later version.
10 %
11 % This program is distributed in the hope that it will be useful,
12 % but WITHOUT ANY WARRANTY; without even the implied warranty of
13 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 % GNU General Public License for more details.
15 %
16 % You should have received a copy of the GNU General Public License
17 % along with this program; if not, write to the Free Software
18 % Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 %
20 %
21 % \fi
22 %
23 % \CheckSum{1121}
24 %% \CharacterTable
25 %% {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
26 %% 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
27 %% Digits \0\1\2\3\4\5\6\7\8\9
28 %% Exclamation \! Double quote \" Hash (number) \#
29 %% Dollar \$ Percent \% Ampersand \&
30 %% Acute accent \' Left paren \( Right paren \)
31 %% Asterisk \* Plus \+ Comma \,
32 %% Minus \- Point \. Solidus \/
33 %% Colon \: Semicolon \; Less than \<
34 %% Equals \= Greater than \> Question mark \?
35 %% Commercial at \@ Left bracket \[ Backslash \\
36 %% Right bracket \] Circumflex \^ Underscore \_
37 %% Grave accent \` Left brace \{ Vertical bar \|
38 %% Right brace \} Tilde \~}
39 %%
40 % \iffalse
41 %
42 %<class>\NeedsTeXFormat{LaTeX2e}
43 %<class>\ProvidesClass{cd}[2014/06/13 v1.4 CD Cover Class]
44 %
45 %<*driver>
46 \documentclass{ltxdoc}
47 \RecordChanges
48 \GetFileInfo{cd.cls}
49
50 \title{A CD Cover Class}
51 \date{Printed \today}
52 \author{Sebastiano Vigna}
53
54 \begin{document}
55 \maketitle
56 \tableofcontents
57 \DocInput{cd.dtx}
58 \end{document}
59 %</driver>
60 %
61 % \fi
62 %
63 %
64 % \changes{v0.0}{1998/06/04}
65 % {Created file.}
66 %
67 % \changes{v0.1}{1998/06/15}
68 % {New macros for data file handling.}
69 %
70 % \changes{v1.0}{2002/01/10}
71 % {Bump revision number.}
72 %
73 % \changes{v1.1}{2005/09/08}
74 % {Add support for slim cases.}
75 % \changes{v1.1}{2005/09/08}
76 % {Better positioning, too.}
77 %
78 % \changes{v1.3}{2007/10/12}
79 % {Implement covergraphics, etc.}
80 % \changes{v1.3}{2007/10/12}
81 % {Implement .dat/.lst filename from job name.}
82 %
83 % \changes{v1.4}{2014/06/13}
84 % {Make track list height configurable.}
85 % \changes{v1.4}{2014/06/13}
86 % {Add \cs{trackrange} command.}
87 % \changes{v1.4}{2014/06/13}
88 % {Fix typo in \cs{track} command.}
89 % \changes{v1.4}{2014/06/13}
90 % {Make slim and normal back covers use the same height.}
91 %
92 %
93 % \section{Introduction}
94 %
95 % The purpose of this class is to print CD covers. The main design line is
96 % allowing the creation of labels with minimum effort, without restraining
97 % the freedom to customise. There is also some support for multiple cover
98 % printing. Since version 1.1, slim CD boxes are supported.
99 %
100 % Each CD cover is created by a number of commands that set the content of
101 % the front cover, back cover, track lists etc. After everything is ready,
102 % additional commands actually generate the covers. This is a very simple
103 % example:
104 %
105 % \begin{verbatim}
106 % \documentclass{cd}
107 % \begin{document}
108 %
109 % \covertext{
110 % The Artist\\
111 % \bfseries The Title
112 % }
113 %
114 % \leftspine{THE ARTIST}
115 % \centerspine{THE TITLE}
116 %
117 % \lefttracklist{
118 % \track Song 1
119 % \track Song 2
120 % \track Song 3
121 % }
122 %
123 % \leftinfo{Words and Music by The Artist}
124 %
125 % \makecover\par
126 % \makeback\par
127 % \end{document}
128 % \end{verbatim}
129 %
130 % By compiling the file above, you will obtain your first CD cover. Using
131 % |\makeslimcover| instead of |\makecover| and |\makeback|, you will obtain
132 % a single cover for a slim CD box.
133 %
134 % Equivalently, you can create a file |CD.dat| containing the lines between
135 % |\begin{document}| and |\makecover| and compile with \LaTeX{} the file
136 % |CD.tex| (or |slimCD.tex|). This is a better mechanism---each CD should
137 % have its own data (|.dat|) file that is run through the driver file
138 % |CD.tex| or the more powerful list mechanism described below. This also
139 % allows to set some parameters one for all (for instance, the font family)
140 % in the driver file. My driver file, for instance, is as follows (see
141 % below for the non-standard commands):
142 %
143 % \begin{verbatim}
144 % \documentclass[a4paper]{cd}
145 % \usepackage[latin1]{inputenc}
146 % \usepackage{avant}
147 % \renewcommand\rmdefault{\sfdefault}
148 % \onecorrection{.2}
149 % \begin{document}
150 % \makeCD
151 % \end{document}
152 % \end{verbatim}
153 %
154 % The |CD| class loads the |article| class, so commands like |\Large| or
155 % |\smallskip| are available. However, the |CD| class provides its own
156 % precise size-switching commands, and for greater accuracy it is advisable
157 % to use \LaTeX's |\\|\oarg{vspace} mechanism in order to generate vertical
158 % spacing.
159 %
160 % Note that the class uses heavily the |rotating| package, so you must
161 % convert the resulting dvi file into PostScript\textregistered, or use
162 % directly |pdflatex|.
163 %
164 %
165 % \section{The Text Commands}
166 %
167 % The content of a CD cover are set using the following self-explaining
168 % commands.
169 %
170 % \begin{quote}
171 % |\covertext|, |\backtext|, |\insidetext|,\\
172 % |\leftspine|, |\centerspine|, |\rightspine|,\\
173 % |\lefttracklist|, |\righttracklist|,\\
174 % |\leftinfo|, |\rightinfo|
175 % \end{quote}
176 %
177 % \noindent The commands |\insidetext|, |\leftspine|, |\centerspine| and
178 % |\rightspine| are ignored for slim covers. Note that by default the
179 % material contained in |\covertext|, |\backtext| and |\insidetext| is
180 % bottom-aligned, and the arguments of the spine commands must not contain
181 % line breaks. The left and right track lists should use the |\track|
182 % command, which inserts a |\par| and an automatically numbered box with the
183 % track number. There is also a |\trackrange| command that takes a
184 % parameter and adds a range indication (two numbered boxes separated by a
185 % dash). Should you need to set manually the track number, use
186 % |\setindex|\marg{n}. The text contained in |\leftinfo| and |\rightinfo|
187 % is bottom-aligned just under the respective track lists. Note that if the
188 % right information or track list box is empty, the left one will span
189 % across the whole cover. By default everything is typeset with no
190 % justification, and no paragraph indentation. One tenth of the current
191 % baseline skip is inserted between paragraphs.
192 %
193 % In extreme cases you may want to create different spines (e.g., for
194 % R.E.M.'s \emph{Fables Of The Reconstruction}); the |\leftspinebis|,
195 % |\centerspinebis| and |\rightspinebis| commands allows you to insert
196 % different content into the ``back'' spine.
197 %
198 % The height of the track list (in millimeters) can be set with
199 % |\tracklistheight|, which expects a dimensionless, positive integer value.
200 % If not specified, the height is set to 70. The sum of the track list
201 % height and the height of the area used to typeset |\covertext| on the back
202 % cover equals 100.
203 %
204 %
205 % \section{The Graphic Commands}
206 %
207 % In the case you want to fill the cover or the inside of your CD with a
208 % picture, the commands |\covergraphics| and |\insidegraphics| work like
209 % |\covertext| and |\insidetext|, but they create no border (as opposed to
210 % the standard 1\,cm border for text).
211 %
212 %
213 % \section{The Font Commands}
214 %
215 % The |CD| class provides some simple commands for switching the font
216 % dimension and line spacing. The command |\fh|\marg{height} sets the font
217 % height to the given number of points (line spacing is not affected), while
218 % |\fhb|\marg{height}\marg{baselineskip} sets both the font height and the
219 % baseline skip (usually 6/5th of the font height will work). Note that you
220 % can just write |\fh7| in order to switch to a 7~point font, and that the
221 % |\fhb| command always sets |\parskip| to 1/10th of the current baseline
222 % skip, so |\par| will always space a little more than |\\|.
223 %
224 % When you issue a |\newcd| command, all fonts are reset to their default
225 % values. But there are a number of self-explaining commands, i.e.,
226 % |\coverfont|, |\backfont|, |\insidefont|, |\spinefont|, |\tracklistfont|,
227 % |\infofont| and |\indexfont|, that allow to change the font assigned to a
228 % part of the cover. In fact, they are just one-argument macros whose
229 % arguments are expanded just before the corresponding text commands, and
230 % can contain other formatting parameters.
231 %
232 %
233 % \section{The Cover Creation Commands}
234 %
235 % Before setting the content of the cover, the |\newcd| command takes care
236 % of resetting everything to default values. In particular, |\backtext| is
237 % the same as |\covertext| (unless you change it explicitly), so usually you
238 % do not need to set the former (note that, of course, this does \emph{not}
239 % happen with |\covergraphics|). Analogously, |\backfont| is the same as
240 % |\coverfont|.
241 %
242 % Once everything is set up, the |\makecover| and |\makeback| commands will
243 % create a cover and a back cover using the data set so far, whereas the
244 % |\makeslimcover| will create a slim cover. Both commands have an optional
245 % argument that can contain any of the letters |lrtb| (left, right, top,
246 % bottom), which create the respective crop marks (note that the argument
247 % must be enclosed in brackets). The default value is |lrtb|. The
248 % possibility of partially eliminating crop marks is particularly useful
249 % when stacking several covers in the same sheet.
250 %
251 % It is possible to create a single \LaTeX{} document containing a CD cover,
252 % but it is usually more useful to create a data file containing all
253 % |CD|-specific command, and include it from a ``driver'' file, containing
254 % the |\makeCD| or the |\makeslimCD| command. With no argument, it checks
255 % for the existence of a \textit{jobname}|.dat| file (where \textit{jobname}
256 % is the root of the \LaTeX{} file under compilation---e.g., |CD.dat| when
257 % compiling |CD.tex|). If such a file exists, it is input and then the
258 % (slim) CD cover is generated. Otherwise, the user is asked for a data
259 % file name (the |CD| class will try automatically to append the |.dat|
260 % extension to the name), which is read and processed. Of course, the
261 % optional argument (which, note again, must be enclosed in brackets) can be
262 % used to specify a data file name.
263 %
264 % Having a database of data files is particularly useful when using the
265 % |\makelist| or the |\makeslimlist| commands, which process an entire list
266 % of CDs, printing one cover (or two back covers) per page; the crop marks
267 % are suitably aligned so to minimise the cutting effort. The CD list must
268 % be contained in a list file, one data file name per line. With no
269 % argument, |\makelist| and |\makeslimlist| check for the existence of a
270 % |CD.lst| file. If it exists, it is input; otherwise, the user is asked
271 % for a list file name (the |CD| class will try automatically to append the
272 % |.lst| extension to the name), which is read and processed. Again, the
273 % optional argument can be used to specify a list file name.
274 %
275 %
276 % \section{The Options}
277 %
278 % You can pass to the |CD| class all the options of the |article| class
279 % (e.g., paper size). Moreover, there are options |aligncovertop|,
280 % |aligninsidetop|, |alignbacktop| and |aligntop| (the last one resumes the
281 % first three ones), and analogously |aligncovercenter|, etc., that allow to
282 % change the default alignment behaviour. The |covergraphics| option lets
283 % you use the entire cover area (instead of a centered 10\,cm$\times$10\,cm
284 % square). Finally, the |alignspine| option forces vertical centring of the
285 % spine text on the ``real'' height of the box involved, rather than on the
286 % height of a generic upper case character. This is not usually what you
287 % want, since, e.g., accents can lead to ugly results. Experiment.
288 %
289 %
290 % \section{Getting Obsessed}
291 %
292 % PostScript fonts usually are set up in such a way that the metric of all
293 % digits is the same, regardless of the actual appearance. This (in
294 % particular with sans-serif fonts) can lead to a very ugly alignment of
295 % two-digit track numbers in which either the first or the last digit is
296 % a~1. The solution is to put in the preamble a
297 % |\onecorrection|\marg{fraction} command: the positioning of two-digit
298 % numbers either starting or ending with 1 will be corrected by the given
299 % fraction of the width of a~1. For instance, |\onecorrection{.2}| works
300 % great for AvantGarde. The values for other fonts must be set by
301 % trial-and-error.
302 %
303 %
304 % \StopEventually{}
305 %
306 %
307 % \section{The Code}
308 %
309 % First of all we manage all options. This is done with a |\newif| for
310 % |alignspine|, and by defining suitably some macros representing the
311 % alignment option for the cover, inside and back text. Default is~|b|.
312 % All options we do not process are passed to the |article| class.
313 %
314 % \begin{macrocode}
315 %<*class>
316 \newif\if@lignspine
317 \@lignspinefalse
318
319 \DeclareOption{alignspine}{\@lignspinetrue}
320
321 \def\@ligncover{b}
322 \def\@ligninside{b}
323 \def\@lignback{b}
324
325 \DeclareOption{aligncovertop}{\def\@ligncover{t}}
326 \DeclareOption{aligninsidetop}{\def\@ligninside{t}}
327 \DeclareOption{alignbacktop}{\def\@lignback{t}}
328
329 \DeclareOption{covergraphics}{\def\@lignback{t}}
330
331 \DeclareOption{aligntop}%
332 {\ExecuteOptions{aligncovertop,
333 aligninsidetop,
334 alignbacktop}}
335
336 \DeclareOption{aligncovercenter}{\def\@ligncover{c}}
337 \DeclareOption{aligninsidecenter}{\def\@ligninside{c}}
338 \DeclareOption{alignbackcenter}{\def\@lignback{c}}
339
340 \DeclareOption{aligncenter}%
341 {\ExecuteOptions{aligncovercenter,
342 aligninsidecenter,
343 alignbackcenter}}
344
345 \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
346
347 \ProcessOptions\relax
348 % \end{macrocode}
349 %
350 % Now we load the |article| class and the |rotating| package, which is
351 % fundamental in typesetting the spine text.
352 %
353 % \begin{macrocode}
354 \LoadClass{article}
355 \RequirePackage{rotating}
356 % \end{macrocode}
357 %
358 % The |\onecorrection| command defines a the fraction used for
359 % correcting the alignment of 1's. The default is~0.
360 %
361 % \begin{macrocode}
362 \DeclareRobustCommand*\onecorrection[1]{\def\onec@rrfrac{#1}}
363 \onecorrection{0}
364 % \end{macrocode}
365 %
366 % Now we have all the font and text declaration commands. They just define
367 % a certain macro to be their argument.
368 %
369 % \begin{macrocode}
370 \DeclareRobustCommand*{\coverfont}[1]{\def\coverf@nt{#1}}
371 \DeclareRobustCommand*{\backfont}[1]{\def\backf@nt{#1}}
372 \DeclareRobustCommand*{\insidefont}[1]{\def\insidef@nt{#1}}
373 \DeclareRobustCommand*{\spinefont}[1]{\def\spinef@nt{#1}}
374 \DeclareRobustCommand*{\tracklistfont}[1]{\def\tracklistf@nt{#1}}
375 \DeclareRobustCommand*{\infofont}[1]{\def\infof@nt{#1}}
376 \DeclareRobustCommand*{\indexfont}[1]{\def\indexf@nt{#1}}
377
378 \DeclareRobustCommand{\lefttracklist}[1]{\def\lefttr@cklist{#1}}
379 \DeclareRobustCommand{\righttracklist}[1]{\def\righttr@cklist{#1}}
380 \DeclareRobustCommand{\leftinfo}[1]{\def\leftinf@{#1}}
381 \DeclareRobustCommand{\rightinfo}[1]{\def\rightinf@{#1}}
382 \DeclareRobustCommand{\covertext}[1]{\def\c@vertext{#1}}
383 \DeclareRobustCommand{\backtext}[1]{\def\b@cktext{#1}}
384 \DeclareRobustCommand{\insidetext}[1]{\def\insid@text{#1}}
385
386 \DeclareRobustCommand{\covergraphics}[1]{%
387 \def\c@vertext{#1}\def\c@vergraphics{}}
388 \DeclareRobustCommand{\insidegraphics}[1]{%
389 \def\insid@text{#1}\def\insid@graphics{}}
390
391 \DeclareRobustCommand*{\leftspine}[1]{\def\leftspin@{#1}}
392 \DeclareRobustCommand*{\centerspine}[1]{\def\centerspin@{#1}}
393 \DeclareRobustCommand*{\rightspine}[1]{\def\rightspin@{#1}}
394 \DeclareRobustCommand*{\leftspinebis}[1]{\def\leftspin@bis{#1}}
395 \DeclareRobustCommand*{\centerspinebis}[1]{\def\centerspin@bis{#1}}
396 \DeclareRobustCommand*{\rightspinebis}[1]{\def\rightspin@bis{#1}}
397
398 \DeclareRobustCommand*{\tracklistheight}[1]{%
399 \begingroup
400 \xdef\tr@cklistheight{#1}%
401 \@tempcnta=100
402 \advance\@tempcnta by -\tr@cklistheight
403 \xdef\c@vertextheight{\the\@tempcnta}%
404 \@tempcnta=12
405 \advance\@tempcnta by \tr@cklistheight
406 \xdef\c@verpos{\the\@tempcnta}%
407 \endgroup
408 }
409 % \end{macrocode}
410 %
411 % We do not want any |lineskip|, as stacked covers should not be separated
412 % by any space. Analogously, we want no margins, no indentation and no
413 % hyphenation. Offsets will be set command by each command.
414 %
415 % \begin{macrocode}
416 \evensidemargin=0cm
417 \oddsidemargin=0cm
418 \topmargin=0cm
419 \headheight=0cm
420 \headsep=0cm
421 \footskip=0cm
422 \textwidth=\paperwidth
423 %\advance\textwidth by -3cm
424 \textheight=\paperheight
425 %\advance\textheight by -3cm
426
427 \lineskip=0pt
428 \lineskiplimit=0pt
429 \parskip=0pt
430 \parindent=0pt
431 \hyphenpenalty=10000
432 % \end{macrocode}
433 %
434 % We set the unit for the |picture| environment to 1\,mm and prepare a
435 % number of lengths that will be useful in aligning track numbers and spine
436 % text. |\squ@re| holds the side length of the square framing the track
437 % numbers. |\h@nging| is its hanging amount. |\h@ngingg| is the hanging
438 % amount of a track range. |\@hstrip| and |\@wstrip| are used when aligning
439 % the spine. |\winf@| and |\wtr@cklist| are the width of the information
440 % and tracklist minipages.
441 %
442 % \begin{macrocode}
443 \setlength{\unitlength}{1mm}
444 \newlength{\squ@re}
445 \newlength{\@temp}
446 \newlength{\@tempp}
447 \newlength{\d@shwidth}
448 \newlength{\h@nging}
449 \newlength{\h@ngingg}
450 \newlength{\@hstrip}
451 \newlength{\@wstrip}
452 \newlength{\winf@}
453 \newlength{\wtr@cklist}
454 \newlength{\onec@rrection}
455 % \end{macrocode}
456 %
457 % The |\tr@ck| command typesets a hanging framed box with a small number
458 % inside. The number is given by a counter that is reset to~1 at each
459 % |\makeback|, and can be changed manually with the |\setindex| command.
460 % Two parameters makes it possible to set the hanging amount and the amount
461 % of space that follows the box. The alignment inside the small box will be
462 % corrected for numbers either starting or ending with a~1 by the fraction
463 % of the width of~1 specified with the |\onecorrection| command. The
464 % associated user commands are |\track| and |\trackrange|; the latter makes
465 % it possible to typeset a range given its length.
466 %
467 % \begin{macrocode}
468 \newcounter{tr@ckindex}
469 \DeclareRobustCommand*{\setindex}[1]{\setcounter{tr@ckindex}{#1}}
470
471 \DeclareRobustCommand*{\tr@ck}[2]{%
472 \let\@firstdigit=\@empty
473 \setlength{\onec@rrection}{0pt}%
474 \settowidth{\@temp}{\indexf@nt1}%
475 \expandafter\@tfor \expandafter\@digit
476 \expandafter:\expandafter=\number\value{tr@ckindex}\do {%
477 \ifx\@firstdigit\@empty
478 \let\@firstdigit=\@digit
479 \else
480 \if 1\@firstdigit
481 \if 1\@digit\else
482 \setlength{\onec@rrection}{-\onec@rrfrac\@temp}%
483 \fi
484 \else
485 \if 1\@digit
486 \setlength{\onec@rrection}{\onec@rrfrac\@temp}%
487 \fi
488 \fi
489 \fi
490 }%
491 \setlength{\@temp}{\squ@re}%
492 \settoheight{\@tempp}{\tracklistf@nt M}%
493 \addtolength{\@temp}{-\@tempp}%
494 \raisebox{-.5\@temp}{%
495 \setlength{\unitlength}{\squ@re}%
496 \hspace*{-#1}%
497 \begin{picture}(1,1)
498 \put(0,0){%
499 \framebox(1,1){%
500 \hspace*{\onec@rrection}\indexf@nt\thetr@ckindex}%
501 }
502 \end{picture}%
503 }%
504 \hspace*{#2}%
505 \addtocounter{tr@ckindex}{1}%
506 }
507
508 \DeclareRobustCommand*{\track}{%
509 \par\tr@ck{\h@nging}{6pt}%
510 }
511
512 \DeclareRobustCommand*{\trackrange}[1]{%
513 \par
514 \tr@ck{\h@ngingg}{1pt}%
515 \addtocounter{tr@ckindex}{#1}%
516 \addtocounter{tr@ckindex}{-2}%
517 \settoheight{\@temp}{\indexf@nt M}%
518 \settoheight{\@tempp}{\tracklistf@nt M}%
519 \addtolength{\@temp}{-\@tempp}%
520 \raisebox{-.5\@temp}{\indexf@nt-}%
521 \hspace*{1pt}%
522 \tr@ck{0pt}{6pt}%
523 }
524 % \end{macrocode}
525 %
526 % We declare some utility commands that allow for easy font dimension
527 % switch. The |\newcd| command resets font and text values to its default
528 % values.
529 %
530 % \begin{macrocode}
531 \AtBeginDocument{%
532 \pagestyle{empty}%
533 \thispagestyle{empty}%
534 \newcd
535 }
536
537 \DeclareRobustCommand*{\fhb}[2]{%
538 \fontsize{#1pt}{#2pt}\selectfont
539 \parskip=.1\baselineskip
540 }
541
542 \DeclareRobustCommand*{\fh}[1]{%
543 \fontsize{#1pt}{\baselineskip}\selectfont
544 }
545
546 \DeclareRobustCommand*{\newcd}{%
547 \lefttracklist{}%
548 \righttracklist{}%
549 \covertext{}%
550 \insidetext{}%
551 \leftspine{}%
552 \centerspine{}%
553 \rightspine{}%
554 \leftspinebis{\leftspin@}%
555 \centerspinebis{\centerspin@}%
556 \rightspinebis{\rightspin@}%
557 \leftinfo{}%
558 \rightinfo{}%
559 \coverfont{\fhb{16}{19}}%
560 \backfont{\coverf@nt}%
561 \insidefont{\fhb{10}{12}}%
562 \spinefont{\fhb{9}{11}\bfseries}%
563 \tracklistfont{\fhb{9}{10.5}}%
564 \infofont{\fhb{7}{8.3}}%
565 \indexfont{\fhb{5}{0}}%
566 \tracklistheight{70}%
567 }
568 % \end{macrocode}
569 %
570 % The following two commands are useful in alignment. The first command
571 % decides the height and width of a given strip of text, to be inserted in
572 % the spine. The point is that unless the |alignspine| option has been
573 % requested, we do not set |\@hstrip|, which has been set previously to the
574 % maximum height of a capital letter. The |\alignt@baseline| command is
575 % used at the end of boxes that could be bottom aligned: it eliminates the
576 % additional height inserted when a box's last line has a descender.
577 %
578 % \begin{macrocode}
579 \DeclareRobustCommand*{\@sethwstrips}[1]{%
580 \settowidth{\@wstrip}{\spinef@nt #1}%
581 \if@lignspine
582 \settoheight{\@hstrip}{\spinef@nt #1}%
583 \fi
584 }
585
586 \DeclareRobustCommand*{\alignt@baseline}{%
587 \settodepth{\@temp}{gjpqy}%
588 \vphantom{gjpqy}\par
589 \vspace*{-\@temp}\par
590 }
591 % \end{macrocode}
592 %
593 % It is now easy to write down the |\makecover| command. It is just a
594 % matter of laying out the material and printing the requested crop marks.
595 %
596 % \begin{macrocode}
597 \DeclareRobustCommand*{\makecover}[1][lrtb]{%
598 \voffset=0in
599 \begin{picture}(120,240)
600 \end{picture}%
601 \begin{rotate}{90}%
602 \begin{picture}(240,120)
603 \@tfor\cr@pmark := #1 \do {
604 \if l\cr@pmark
605 \put(-1,0){\line(-1,0){5}}
606 \put(-1,120){\line(-1,0){5}}
607 \else\if r\cr@pmark
608 \put(241,0){\line(1,0){5}}
609 \put(241,120){\line(1,0){5}}
610 \else\if b\cr@pmark
611 \put(0,-1){\line(0,-1){5}}
612 \put(240,-1){\line(0,-1){5}}
613 \put(120,-1){\line(0,-1){1}}
614 \put(120,-3){\line(0,-1){1}}
615 \put(120,-5){\line(0,-1){1}}
616 \else\if t\cr@pmark
617 \put(0,121){\line(0,1){5}}
618 \put(240,121){\line(0,1){5}}
619 \put(120,121){\line(0,1){1}}
620 \put(120,123){\line(0,1){1}}
621 \put(120,125){\line(0,1){1}}
622 \else\if c\cr@pmark
623 \put(0,0){\line(1,0){240}}
624 \put(0,0){\line(0,1){120}}
625 \put(120,0){\line(0,1){120}}
626 \put(0,120){\line(1,0){240}}
627 \put(240,0){\line(0,1){120}}
628 \fi\fi\fi\fi\fi
629 }
630
631 \ifx\insid@graphics\@empty
632 \put(0,0){%
633 \makebox(120,120)[\@ligninside]{%
634 \parbox{12cm}{%
635 \raggedright
636 \insidef@nt
637 \insid@text
638 \alignt@baseline}}}
639 \else
640 \put(10,10){%
641 \makebox(100,100)[\@ligninside]{%
642 \parbox{10cm}{%
643 \raggedright
644 \insidef@nt
645 \insid@text
646 \alignt@baseline}}}
647 \fi
648 \ifx\c@vergraphics\@empty
649 \put(120,0){%
650 \makebox(120,120)[\@ligncover]{%
651 \parbox{12cm}{%
652 \raggedright
653 \coverf@nt
654 \c@vertext
655 \alignt@baseline}}}
656 \else
657 \put(130,10){%
658 \makebox(100,100)[\@ligncover]{%
659 \parbox{10cm}{%
660 \raggedright
661 \coverf@nt
662 \c@vertext
663 \alignt@baseline}}}
664 \fi
665 \end{picture}%
666 \end{rotate}%
667 }
668 % \end{macrocode}
669 %
670 % The |\makeback| command is slightly more complicated, as it must set up
671 % come values for the |\track| command to work. Moreover, it has to check
672 % for empty right information or tracklist minipages, as in this case the
673 % left ones must be enlarged, and it must try to use the text from the cover
674 % page if no back text has been specified.
675 %
676 % \begin{macrocode}
677 \DeclareRobustCommand*{\makeback}[1][lrtb]{%
678 \voffset=-.5in
679 \setindex{1}%
680 \settowidth{\d@shwidth}{\indexf@nt-}%
681 \settowidth{\squ@re}{\indexf@nt00}%
682 \settoheight{\@temp}{\indexf@nt0}%
683 \addtolength{\squ@re}{.4\@temp}%
684 \setlength{\h@nging}{\squ@re}%
685 \setlength{\h@ngingg}{\squ@re}%
686 \addtolength{\h@ngingg}{\squ@re}%
687 \addtolength{\h@ngingg}{\d@shwidth}%
688 \addtolength{\h@nging}{6pt}%
689 \addtolength{\h@ngingg}{8pt}%
690 \settoheight{\@hstrip}{\spinef@nt ABCDEFGHIJKLMNOPQRSTUVWXYZ}%
691 %
692 \ifx\righttr@cklist\@empty
693 \setlength{\wtr@cklist}{12cm}%
694 \else
695 \setlength{\wtr@cklist}{5.5cm}%
696 \fi
697 %
698 \ifx\rightinf@\@empty
699 \setlength{\winf@}{12cm}%
700 \else
701 \setlength{\winf@}{5.5cm}%
702 \fi
703 %
704 \begin{picture}(151,118)
705 \@tfor\cr@pmark := #1 \do {
706 \if l\cr@pmark
707 \put(-1,0){\line(-1,0){5}}
708 \put(-1,118){\line(-1,0){5}}
709 \else\if r\cr@pmark
710 \put(152,0){\line(1,0){5}}
711 \put(152,118){\line(1,0){5}}
712 \else\if b\cr@pmark
713 \put(0,-1){\line(0,-1){5}}
714 \put(151,-1){\line(0,-1){5}}
715 \put(6.5,-1){\line(0,-1){1}}
716 \put(6.5,-3){\line(0,-1){1}}
717 \put(6.5,-5){\line(0,-1){1}}
718 \put(144.5,-1){\line(0,-1){1}}
719 \put(144.5,-3){\line(0,-1){1}}
720 \put(144.5,-5){\line(0,-1){1}}
721 \else\if t\cr@pmark
722 \put(0,119){\line(0,1){5}}
723 \put(151,119){\line(0,1){5}}
724 \put(6.5,119){\line(0,1){1}}
725 \put(6.5,121){\line(0,1){1}}
726 \put(6.5,123){\line(0,1){1}}
727 \put(144.5,119){\line(0,1){1}}
728 \put(144.5,121){\line(0,1){1}}
729 \put(144.5,123){\line(0,1){1}}
730 \else\if c\cr@pmark
731 \put(0,0){\line(1,0){151}}
732 \put(0,0){\line(0,1){118}}
733 \put(151,0){\line(0,1){118}}
734 \put(0,118){\line(1,0){151}}
735 \put(6.5,0){\line(0,1){118}}
736 \put(144.5,0){\line(0,1){118}}
737 \fi\fi\fi\fi\fi
738 }
739
740 \@sethwstrips{\leftspin@}
741
742 \put(0,4){%
743 \makebox(6.5,110)[b]{%
744 \makebox[\@hstrip][r]{%
745 \begin{rotate}{90}%
746 \spinef@nt
747 \leftspin@
748 \end{rotate}}}}
749
750 \@sethwstrips{\centerspin@}
751
752 \put(0,4){%
753 \makebox(6.5,110){%
754 \raisebox{0pt}[\@wstrip]{%
755 \makebox[\@hstrip][r]{%
756 \begin{rotate}{90}%
757 \spinef@nt
758 \centerspin@
759 \end{rotate}}}}}
760
761 \@sethwstrips{\rightspin@}
762
763 \put(0,4){%
764 \makebox(6.5,110)[t]{%
765 \raisebox{0pt}[\@wstrip]{%
766 \makebox[\@hstrip][r]{%
767 \begin{rotate}{90}%
768 \spinef@nt
769 \rightspin@
770 \end{rotate}}}}}
771
772 \@sethwstrips{\leftspin@bis}
773
774 \put(144.5,4){%
775 \makebox(6.5,110)[t]{%
776 \makebox[\@hstrip][l]{%
777 \begin{rotate}{-90}%
778 \spinef@nt
779 \leftspin@bis
780 \end{rotate}}}}
781
782 \@sethwstrips{\centerspin@bis}
783
784 \put(144.5,4){%
785 \makebox(6.5,110){%
786 \raisebox{\@wstrip}[\@wstrip]{%
787 \makebox[\@hstrip][l]{%
788 \begin{rotate}{-90}%
789 \spinef@nt
790 \centerspin@bis
791 \end{rotate}}}}}
792
793 \@sethwstrips{\rightspin@bis}
794
795 \put(144.5,4){%
796 \makebox(6.5,110)[b]{%
797 \raisebox{\@wstrip}[\@wstrip]{%
798 \makebox[\@hstrip][l]{%
799 \begin{rotate}{-90}%
800 \spinef@nt
801 \rightspin@bis
802 \end{rotate}}}}}
803
804 \put(17,0){%
805 \begin{picture}(121,118)
806 \put(0,\c@verpos){%
807 \makebox(120,\c@vertextheight)[\@lignback]{%
808 \parbox{12.1cm}{%
809 \raggedright
810 \backf@nt
811 \ifx\b@cktext\undefined
812 \ifx\c@vergraphics\@empty\else\c@vertext\fi
813 \else
814 \b@cktext
815 \fi
816 \alignt@baseline}}}
817
818 \put(0,5){%
819 \makebox(55,\tr@cklistheight)[tl]{%
820 \begin{minipage}{\wtr@cklist}%
821 \lineskip=.5pt
822 \lineskiplimit=1pt
823 \raggedright
824 \tracklistf@nt
825 \lefttr@cklist
826 \end{minipage}}}
827
828 \put(65,5){%
829 \makebox(55,\tr@cklistheight)[tl]{%
830 \begin{minipage}{\wtr@cklist}%
831 \lineskip=.5pt
832 \lineskiplimit=1pt
833 \raggedright
834 \tracklistf@nt
835 \righttr@cklist
836 \end{minipage}}}
837
838 \put(0,5){%
839 \makebox(0,0)[bl]{%
840 \parbox{\winf@}{%
841 \raggedright
842 \infof@nt
843 \leftinf@
844 \alignt@baseline}}}
845
846 \put(65,5){%
847 \makebox(0,0)[bl]{%
848 \parbox{\winf@}{%
849 \raggedright
850 \infof@nt
851 \rightinf@
852 \alignt@baseline}}}
853 \end{picture}%
854 }
855 \end{picture}%
856 }
857 % \end{macrocode}
858 %
859 % The |\makeslimcover| command is essentially a mix of the previous two, as
860 % a single slim cover must contain the front matter and the track lists.
861 % Note that we have much less space.
862 %
863 % \begin{macrocode}
864 \DeclareRobustCommand*{\makeslimcover}[1][lrtb]{%
865 \voffset=0in
866 \setindex{1}%
867 \settowidth{\d@shwidth}{\indexf@nt-}%
868 \settowidth{\squ@re}{\indexf@nt00}%
869 \settoheight{\@temp}{\indexf@nt0}%
870 \addtolength{\squ@re}{.4\@temp}%
871 \setlength{\h@nging}{\squ@re}%
872 \setlength{\h@ngingg}{\squ@re}%
873 \addtolength{\h@ngingg}{\squ@re}%
874 \addtolength{\h@ngingg}{\d@shwidth}%
875 \addtolength{\h@nging}{6pt}%
876 \addtolength{\h@ngingg}{8pt}%
877 \settoheight{\@hstrip}{\spinef@nt ABCDEFGHIJKLMNOPQRSTUVWXYZ}%
878 %
879 \ifx\righttr@cklist\@empty
880 \setlength{\wtr@cklist}{10cm}%
881 \else
882 \setlength{\wtr@cklist}{4.7cm}%
883 \fi
884 %
885 \ifx\rightinf@\@empty
886 \setlength{\winf@}{10cm}%
887 \else
888 \setlength{\winf@}{4.7cm}%
889 \fi
890 %
891 \begin{picture}(120,240)
892 \end{picture}%
893 \begin{rotate}{90}%
894 \begin{picture}(240,120)
895 \@tfor\cr@pmark := #1 \do {
896 \if l\cr@pmark
897 \put(-1,0){\line(-1,0){5}}
898 \put(-1,120){\line(-1,0){5}}
899 \else\if r\cr@pmark
900 \put(241,0){\line(1,0){5}}
901 \put(241,120){\line(1,0){5}}
902 \else\if b\cr@pmark
903 \put(0,-1){\line(0,-1){5}}
904 \put(240,-1){\line(0,-1){5}}
905 \put(120,-1){\line(0,-1){1}}
906 \put(120,-3){\line(0,-1){1}}
907 \put(120,-5){\line(0,-1){1}}
908 \else\if t\cr@pmark
909 \put(0,121){\line(0,1){5}}
910 \put(240,121){\line(0,1){5}}
911 \put(120,121){\line(0,1){1}}
912 \put(120,123){\line(0,1){1}}
913 \put(120,125){\line(0,1){1}}
914 \else\if c\cr@pmark
915 \put(0,0){\line(1,0){240}}
916 \put(0,0){\line(0,1){120}}
917 \put(120,0){\line(0,1){120}}
918 \put(0,120){\line(1,0){240}}
919 \put(240,0){\line(0,1){120}}
920 \fi\fi\fi\fi\fi
921 }
922
923 \put(11,0){%
924 \begin{picture}(100,120)
925 \put(0,\c@verpos){%
926 \makebox(100,\c@vertextheight)[\@lignback]{%
927 \parbox{10.1cm}{%
928 \raggedright
929 \backf@nt
930 \ifx\b@cktext\undefined
931 \ifx\c@vergraphics\@empty\else\c@vertext\fi
932 \else
933 \b@cktext
934 \fi
935 \alignt@baseline}}}
936
937 \put(0,5){%
938 \makebox(47,\tr@cklistheight)[tl]{%
939 \begin{minipage}{\wtr@cklist}%
940 \lineskip=.5pt
941 \lineskiplimit=1pt
942 \raggedright
943 \tracklistf@nt
944 \lefttr@cklist
945 \end{minipage}}}
946
947 \put(55,5){%
948 \makebox(47,\tr@cklistheight)[tl]{%
949 \begin{minipage}{\wtr@cklist}%
950 \lineskip=.5pt
951 \lineskiplimit=1pt
952 \raggedright
953 \tracklistf@nt
954 \righttr@cklist
955 \end{minipage}}}
956
957 \put(0,5){%
958 \makebox(0,0)[bl]{%
959 \parbox{\winf@}{%
960 \raggedright
961 \infof@nt
962 \leftinf@
963 \alignt@baseline}}}
964
965 \put(55,5){%
966 \makebox(0,0)[bl]{%
967 \parbox{\winf@}{%
968 \raggedright
969 \infof@nt
970 \rightinf@
971 \alignt@baseline}}}
972 \end{picture}%
973 }
974 \ifx\c@vergraphics\@empty
975 \put(120,0){%
976 \makebox(120,120)[\@ligncover]{%
977 \parbox{12cm}{%
978 \raggedright
979 \coverf@nt
980 \c@vertext
981 \alignt@baseline}}}
982 \else
983 \put(130,10){%
984 \makebox(100,100)[\@ligncover]{%
985 \parbox{10cm}{%
986 \raggedright
987 \coverf@nt
988 \c@vertext
989 \alignt@baseline}}}
990 \fi
991 \end{picture}%
992 \end{rotate}%
993 }
994 % \end{macrocode}
995 %
996 % Finally, we have the high-level commands that allow to produce one or
997 % several CD from data files, |\makeCD|, |\makelist|, |\makeslimCD| and
998 % |\makeslimlist|. All have an additional argument for the file name,
999 % defaulting to |\jobname.dat| or |\jobname.lst|.
1000 %
1001 % Two separate commands factor out the checks and the user interaction in
1002 % case the file is not specified or does not exist.
1003 %
1004 % A data file must contain only text declaration commands from the |CD|
1005 % class. All \LaTeX{} stuff (preamble, etc.) and cover generation commands
1006 % are handled automatically. A list file must contain a number of lines,
1007 % each containing a data file name.
1008 %
1009 % \begin{macrocode}
1010 \DeclareRobustCommand*{\@skCDfile}[1]{%
1011 \def\CDname{#1}%
1012 \ifx\CDname\@empty
1013 \IfFileExists{\jobname.dat}{%
1014 \def\CDname{\jobname.dat}%
1015 }{%
1016 \typein[\CDname]{Please insert CD data file name:}%
1017 }%
1018 \fi
1019 \InputIfFileExists{\CDname.dat}{%
1020 }{%
1021 \InputIfFileExists{\CDname}{%
1022 }{%
1023 \ClassError{cd}
1024 {CD data file (\CDname.dat or \CDname) not found}
1025 {}%
1026 }%
1027 }%
1028 }
1029
1030 \DeclareRobustCommand*{\makeCD}[1][]{%
1031 \@skCDfile{#1}%
1032 \makecover\par
1033 \makeback\par
1034 }
1035
1036 \DeclareRobustCommand*{\makeslimCD}[1][]{%
1037 \@skCDfile{#1}%
1038 \makeslimcover\par
1039 }
1040
1041 \newread\CDlist
1042
1043 \newcounter{@cd}
1044 \setcounter{@cd}{0}
1045
1046 \newif\ifne@f
1047
1048 \DeclareRobustCommand*{\@sklistfile}[1]{%
1049 \def\CDlistname{#1}%
1050 \ifx\CDlistname\@empty
1051 \IfFileExists{\jobname.lst}{%
1052 \def\CDlistname{\jobname.lst}%
1053 }{%
1054 \typein[\CDlistname]{Please insert CD list file name:}
1055 }%
1056 \fi
1057 \IfFileExists{\CDlistname.lst}{%
1058 \immediate\openin\CDlist=\CDlistname.lst
1059 }{%
1060 \IfFileExists{\CDlistname}{%
1061 \immediate\openin\CDlist=\CDlistname
1062 }{%
1063 \ClassError{cd}
1064 {CD list (\CDlistname.lst or \CDlistname) not found}
1065 {}%
1066 }%
1067 }%
1068 \ne@ftrue
1069 }
1070
1071 \DeclareRobustCommand*{\makelist}[1][]{%
1072 \@sklistfile{#1}%
1073 \advance\endlinechar\@M
1074 \immediate\read\CDlist to \CDname
1075 \advance\endlinechar-\@M
1076 \ifeof\CDlist\ne@ffalse\fi
1077 %
1078 \@whilesw \ifne@f \fi {%
1079 \newcd
1080 \InputIfFileExists{\CDname.dat}{%
1081 }{%
1082 \InputIfFileExists{\CDname}{%
1083 }{%
1084 \ClassError{cd}
1085 {CD data file (\CDname.dat or \CDname) not found}
1086 {}%
1087 }%
1088 }%
1089 \advance\endlinechar\@M
1090 \immediate\read\CDlist to \CDname
1091 \advance\endlinechar-\@M
1092 \ifeof\CDlist\ne@ffalse\fi
1093 \ifodd\value{@cd}%
1094 \makeback[lrb]\par
1095 \makecover\par
1096 \else
1097 \makecover\par
1098 \ifne@f\makeback[lrt]\else\makeback\fi\par
1099 \fi
1100 \addtocounter{@cd}{1}%
1101 }%
1102 }
1103
1104 \DeclareRobustCommand*{\makeslimlist}[1][]{%
1105 \@sklistfile{#1}%
1106 \advance\endlinechar\@M
1107 \immediate\read\CDlist to \CDname
1108 \advance\endlinechar-\@M
1109 \ifeof\CDlist\ne@ffalse\fi
1110 %
1111 \@whilesw \ifne@f \fi {%
1112 \newcd
1113 \InputIfFileExists{\CDname.dat}{%
1114 }{%
1115 \InputIfFileExists{\CDname}{%
1116 }{%
1117 \ClassError{cd}
1118 {CD data file (\CDname.dat or \CDname) not found}
1119 {}%
1120 }%
1121 }%
1122 \advance\endlinechar\@M
1123 \immediate\read\CDlist to \CDname
1124 \advance\endlinechar-\@M
1125 \ifeof\CDlist\ne@ffalse\fi
1126 \makeslimcover\par
1127 }%
1128 }
1129 %</class>
1130 % \end{macrocode}
1131 % \Finale
1132 %
1133 % \PrintChanges
1134 % \addcontentsline{toc}{section}{Change History}
1135
1136 \endinput