~ubuntu-branches/debian/wheezy/texlive-extra/wheezy

« back to all changes in this revision

Viewing changes to texmf-dist/doc/generic/colortab/colortab.doc

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2008-12-06 10:27:26 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20081206102726-x8bamyc8dpgy0w5s
Tags: 2007.dfsg.11-1
This releases fixes 3 RC bugs, thus urgency medium
* blacklist yi4latex, no-sell license (Closes: #507009)
* blacklist colortab, no-sell/no-modify license (Closes: #507768)
* add license statement for the wsuipa fonts (Closes: #491354)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%% BEGIN colortab.doc
2
 
\def\FileVersion{0.9}
3
 
\def\FileDate{1997/03/28}
4
 
%%
5
 
%% Documentation for colortab.tex/colortab.sty.
6
 
%% Run through LaTeX, with or without the NFSS.
7
 
%%
8
 
%% You need the file fancybox.sty, available from Princeton.EDU:/pub/tvz
9
 
%%
10
 
%% The color commands \gray and \lightgray must be defined if you
11
 
%% want to see the examples. pstricks.tex will be loaded for this
12
 
%% purpose if it is found. Otherwise, you must load your own
13
 
%% color commands.
14
 
%%
15
 
%% Change these if using different size paper. You can also include the
16
 
%% twosided style option, if desired:
17
 
 
18
 
\def\paperwidth{8.5in}
19
 
\def\paperheight{11in}
20
 
 
21
 
\documentstyle[12pt,fancybox]{article}
22
 
 
23
 
\makeatletter
24
 
 
25
 
% Load pstricks.tex if it is found:
26
 
\@input{pstricks.tex}
27
 
 
28
 
% Input colortab.tex here to check file version:
29
 
\input colortab.tex
30
 
\ifx\FileVersion\fileversion\else
31
 
  \@latexerr{colortab input file and documentation do not have the same
32
 
    version}\@ehd
33
 
\fi
34
 
 
35
 
% DATES, VERSIONS AND TITLES:
36
 
 
37
 
\def\expanddate#1/#2/#3/{\year=19#1 \month=#2 \day=#3}
38
 
\begingroup
39
 
  \expandafter\expanddate\filedate/
40
 
  \xdef\thefiledate{\today}
41
 
\endgroup
42
 
 
43
 
\title{Documentation for colortab.tex/colortab.sty:\\[5pt]
44
 
  Shading and coloring \TeX\ tables}
45
 
\author{Timothy Van Zandt\\ tvz@Princeton.EDU}
46
 
\date{Version \fileversion\\ \thefiledate}
47
 
 
48
 
\def\@maketitle{%
49
 
 \begin{center}
50
 
   {\Large\bf \@title \par}
51
 
   \vskip 1.2em {\lineskip .5em
52
 
   \begin{tabular}[t]{c}\@author\end{tabular}\par}
53
 
   \vskip .8em {\@date}%
54
 
  \end{center}
55
 
  \par
56
 
  \vskip .5em}
57
 
 
58
 
% PAGE STYLE:
59
 
 
60
 
\pagestyle{myheadings}
61
 
\if@twoside
62
 
  \markboth{Documentation for colortab.tex/.sty}%
63
 
    {Version \fileversion, \thefiledate}%
64
 
\else
65
 
  \markright{colortab.tex, Version \fileversion}
66
 
\fi
67
 
 
68
 
% TABLE OF CONTENTS
69
 
 
70
 
\newskip\myskip
71
 
 
72
 
\def\tableofcontents{%
73
 
  \par\vfill
74
 
  \begin{quote}
75
 
    \begin{center} \Large\bf Contents \end{center}
76
 
    \def\numberline##1{\hbox to 0pt{\hss##1\hskip 1em}}%
77
 
    \let\oldaddvspace\addvspace
78
 
    \def\addvspace##1{%
79
 
      \myskip##1\relax
80
 
      \oldaddvspace{.5\myskip}}
81
 
    \@starttoc{toc}%
82
 
  \end{quote}
83
 
  \thispagestyle{empty}
84
 
  \vfill
85
 
  \clearpage}
86
 
 
87
 
 
88
 
% PAGE PARAMETERS:
89
 
 
90
 
% Paragraphs are marked by large space rather than indentation:
91
 
\parindent 0pt
92
 
\parskip 7pt plus 1pt minus 1pt
93
 
 
94
 
\setlength{\topmargin}{0pt}
95
 
\setlength{\headheight}{12pt}        % height of running head
96
 
\setlength{\headsep}{30pt}           % distance between header and text
97
 
\setlength{\textheight}{8.2in}        % height of text on page
98
 
 
99
 
% Adjust margins for different paper size:
100
 
\@tempdima=\paperwidth
101
 
\advance\@tempdima-8.5in
102
 
\advance\oddsidemargin .5\@tempdima
103
 
\advance\evensidemargin .5\@tempdima
104
 
\@tempdima=\paperheight
105
 
\advance\@tempdima-11in
106
 
\advance\topmargin .5\@tempdima
107
 
 
108
 
% VERBATIM HACKS:
109
 
 
110
 
\VerbatimFootnotes
111
 
 
112
 
% Short meta (works in verbatim. Can't use < for other purposes.
113
 
\catcode`\<=13 \def<#1>{{\rm\it #1\/}}    % <meta> (works in verbatim)
114
 
 
115
 
% Short verbatim. " can appear in verbatim environments.
116
 
\def\temp{\Verb"}
117
 
\expandafter\def\expandafter\dospecials\expandafter{\dospecials\do\"}
118
 
\catcode`\"=13
119
 
\let"\temp
120
 
 
121
 
\def\n#1{{\tt\string#1}}
122
 
 
123
 
% Verbatim item:
124
 
\newcommand{\vitem}{\SaveVerb[{\def\bf{}\item[\UseVerb{\MyTemp}]}]{\MyTemp}}
125
 
 
126
 
% Verbatim section"
127
 
 
128
 
% EXAMPLES:
129
 
% 1. Save example verbatim to \jobname.tmp,
130
 
% 2. Input verbatim with \catcode`\"=14 (" is a comment).
131
 
% 3. Input again with \catcode\`"=9 (" is ignored).
132
 
 
133
 
\renewcommand{\EveryVerbatimLine}[2]{}
134
 
 
135
 
\renewcommand{\EveryVerbOutLine}[2]{}
136
 
 
137
 
\newcommand{\BeginExample}{%
138
 
  \VerbatimEnvironment\begin{VerbatimOut}{\jobname.tmp}}
139
 
 
140
 
\newcommand{\EndExample}{%
141
 
  \end{VerbatimOut}%.
142
 
  \renewcommand{\EveryVerbatimLine}{}%
143
 
  \renewcommand{\EveryVerbatimCodes}{\catcode`\"=14}%
144
 
  \LVerbatimInput{\jobname.tmp}%
145
 
  \catcode`\"=9}
146
 
 
147
 
\@ifundefined{lightgray}{\@testfalse}%
148
 
  {\@ifundefined{gray}{\@testfalse}{\@testtrue}}
149
 
 
150
 
\if@test
151
 
 
152
 
\newenvironment{example}{\BeginExample}{\EndExample
153
 
  \begin{center}\leavevmode\input{\jobname.tmp}\end{center}}
154
 
 
155
 
\else
156
 
 
157
 
\newenvironment{example}{\VerbatimEnvironment\LVerbatim}{\endLVerbatim}
158
 
 
159
 
\fi
160
 
 
161
 
% END PREAMBLE:
162
 
\makeatother
163
 
 
164
 
\begin{document}
165
 
 
166
 
\maketitle
167
 
 
168
 
\begin{quote}
169
 
"colortab.tex/colortab.sty" contains macros that let you use your color
170
 
commands for shading and coloring cells in tables and other alignment
171
 
environments. It is compatible with most \TeX\ macro packages.
172
 
\end{quote}
173
 
 
174
 
\tableofcontents
175
 
 
176
 
\section{Introduction}
177
 
 
178
 
Adding color to tables is fraught with difficulties, but as the examples in
179
 
this file indicate, it can be done. In any case, consider this an advanced
180
 
topic, and be aware that the commands in "colortab.tex" are not robust.
181
 
 
182
 
This is meant to supplement your own color commands. There are many macro
183
 
files that implement color for the various "dvi" drivers that can support
184
 
color. E.g., the PSTricks package works with a variety of DVI-to-PS drivers.
185
 
 
186
 
For example, suppose you have a macro that defines the color command "\gray".
187
 
"colortab.tex" requires that one of the following produce a gray line:
188
 
\begin{LVerbatim}
189
 
  {\gray \hrule}
190
 
  \gray{\hrule}
191
 
\end{LVerbatim}
192
 
if you want to use this command to color the cells in tables.
193
 
This is probably the case if the one of the following produces gray text:
194
 
\begin{LVerbatim}
195
 
  {\gray I am gray!}
196
 
  \gray{I am gray!}
197
 
\end{LVerbatim}
198
 
 
199
 
"colortab.tex" contains macros for \TeX's "\halign" primitive. Incorporating
200
 
color into high-level macros based on the "\halign" primitive requires a
201
 
case-by-case treatment. "colortab.tex" also contains macros for coloring cells
202
 
\LaTeX's various array environments, and for the \LaTeX\ "longtable"
203
 
environment that is defined in the "longtable" (or "longtabl") style option.
204
 
These can serve as examples that can be accommodated to other table macros.
205
 
See the code itself for happy hacking.
206
 
 
207
 
\section{\TeX's halign primitive}
208
 
 
209
 
To shade cells in an alignment, use
210
 
\begin{LVerbatim}
211
 
  \coloralign
212
 
\end{LVerbatim}
213
 
instead of "\halign". Then,  to color the columns in one or more rows, type
214
 
\begin{LVerbatim}
215
 
  \CC
216
 
    <row of colors>\cr
217
 
    <rows to be colored>\cr
218
 
  \ECC
219
 
\end{LVerbatim}
220
 
For example:
221
 
\begin{example}
222
 
  \setbox\strutbox=\hbox{\vrule height11.5pt
223
 
    depth6.5pt width0pt}%
224
 
  \vbox{\offinterlineskip
225
 
    \coloralign{%
226
 
        \vrule\strut\quad\hfil#\hfil\quad
227
 
        &\vrule\quad\hfil#\quad\vrule\cr
228
 
      \noalign{\hrule}%
229
 
      \CC
230
 
        \gray &\cr
231
 
        Tamarind&Chiplote\cr
232
 
      \ECC\noalign{\hrule}%
233
 
      \CC
234
 
        \lightgray &\gray\cr
235
 
        Lulu&Serrano\cr\noalign{\hrule}%
236
 
        Guanabana&Larga\cr
237
 
      \ECC\noalign{\hrule}%
238
 
  }}
239
 
\end{example}
240
 
 
241
 
"\CC" and "\ECC" stand for ``ColorCells'' and ``EndColorCells'', respectively.
242
 
You cannot change the name of "\ECC" with "\let" or "\def" (without redefining
243
 
"\CC"), because it is really just a delimiter. This is also true of the first
244
 
"\cr", which marks the end of the row of color commands.
245
 
Remember that only complete rows can go between "\CC" and "\ECC". Where you
246
 
include horizontal lines is generally inconsequential. You can have nested
247
 
"\coloralign" environments, but the nested environment must be enclosed in
248
 
brackets "{}".  There is no "\coloralign to" or "\coloralign spread" because
249
 
the space inserted by "\tabskip" won't be shaded.
250
 
 
251
 
These macros are not very robust. You can make best use of them by knowing how
252
 
they work. "\coloralign" just saves the preamble, and otherwise is identical
253
 
to "\halign". "\CC" finds the height of the rows that have to be colored, and
254
 
then "\CC" draws a rectangle using \TeX's line-drawing primitives in each
255
 
cell, colored by the color commands included in the first line that follows
256
 
"\CC". E.g.,
257
 
\begin{LVerbatim}
258
 
  \yellow &&\red \cr
259
 
\end{LVerbatim}
260
 
draws a yellow rectangle in column 1, nothing in column 2, and a red rectangle
261
 
in column 3. Then "\CC" goes back up the height of the rectangle, so that
262
 
\TeX's current point is back where it was when "\CC" started. At this point,
263
 
"\CC" has finished its work. When the next rows of the alignment environment
264
 
are processed by "\halign", they are put down on top of the rectangles, and
265
 
hence have colored backgrounds.
266
 
 
267
 
"\CC" finds the height of the rows to be colored by putting the rows into an
268
 
"\halign" environment, using the preamble that was saved by "\coloralign", and
269
 
then measuring the height of the resulting box.
270
 
 
271
 
\section{\LaTeX\ array environments}
272
 
 
273
 
Cells can be colored in a \LaTeX\ array without using a special array
274
 
environment (i.e., there is no \LaTeX\ analog to "\coloralign"). Use "\LCC"
275
 
instead of "\CC", and use "\\" to end the row of color commands instead of
276
 
"\cr". For example:
277
 
\begin{example}
278
 
  \def\arraystretch{1.5}%
279
 
  \begin{tabular}{|l|c|}\hline
280
 
    \LCC
281
 
      \gray & \\
282
 
      Tamarind & Chiplote \\ \hline
283
 
    \ECC
284
 
    \LCC
285
 
      \lightgray & \gray\\
286
 
      Lulu & Serrano\\ \hline
287
 
      Guanabana & Larga\\ \hline
288
 
    \ECC
289
 
  \end{tabular}
290
 
\end{example}
291
 
The same caveats apply as with the "\coloralign" environment.
292
 
 
293
 
When \n\LCC\ and \n\ECC\ are used with Frank Mittelbach's "array.sty", nested
294
 
array-type environments and "\multicolumn" commands wipe out information
295
 
needed by \n\ECC\. Here is a workaround: Put "\SP" (``SavePreamble'') at the
296
 
beginning of the array-type environment (right after the column declarations),
297
 
and put "\RP" (``RestorePreamble'') at the end of each line containing a
298
 
"\multicolumn" command or nested array-type environment (after the "\\", and
299
 
before the \n\ECC). For example:
300
 
\begin{LVerbatim}
301
 
  \begin{tabular}{|l|c|}\SP\hline
302
 
    \LCC
303
 
      \gray & \\
304
 
      \multicolumn{2}{c}{Tamarind}\\ \RP \hline
305
 
    \ECC
306
 
  \end{tabular}
307
 
\end{LVerbatim}
308
 
Further nesting (e.g., an array within a "\multicolumn", or a "\multicolumn"
309
 
or array within a nested array) sometimes works and sometimes doesn't. You
310
 
will have to figure that one out for yourself.
311
 
 
312
 
 
313
 
\section{longtable.sty}
314
 
 
315
 
"longtable.sty", by David Carlisle, defines the "longtable" environment, for
316
 
making multipage tables. "\LCC" will not work with "longtable". However,
317
 
"colortab" contains other macros that will work, if you use "longtable.sty" in
318
 
conjunction with Frank Mittelbach's "array.sty". These macros have been tested
319
 
only briefly, with version 3.04 of "longtable.sty" and version 2.1b of
320
 
"array.sty".
321
 
 
322
 
Before every column identifier in the environment's argument (e.g., "c", "l",
323
 
"r", "p", "m" or "b"), put
324
 
\begin{description}
325
 
  \vitem"!{\LC}" If none of the below applies;
326
 
  \vitem"!{\LCi}" If the column is preceded by one or more vertical lines;
327
 
  \vitem"!{\LCii}" If the column is followed by two vertical lines;
328
 
  \vitem"!{\LCiii}" If the column is preceded by one or more vertical lines
329
 
and followed by two vertical lines.
330
 
  \vitem"!{\LCz{<len1>}{<len2>}}" If "colortab" should back up by <len1>
331
 
before drawing the background, and should draw the background <len2> shorter
332
 
than the width of the column.
333
 
\end{description}
334
 
Remember that you have to do this for every column, not just the columns that
335
 
you want to color.
336
 
 
337
 
Then include
338
 
\begin{LVerbatim}
339
 
  \LColors <color> & <color> & ... & <color>\\
340
 
\end{LVerbatim}
341
 
in the first row of the environment, and later on as well if you wish to
342
 
change the colors. Here also you have to include every column, but you can
343
 
leave an entry blank if you don't want any background color in that column.
344
 
 
345
 
The color comes out right, or at all, only after you have run the file enough
346
 
times for "longtable.sty" to set the alignment correctly.
347
 
 
348
 
Here is an example. The output will appear in this documentation only if
349
 
"longtable.sty" or "longtabl.sty" is installed on your system.
350
 
\begingroup
351
 
  \makeatletter
352
 
  \catcode`\<=12
353
 
% Modification Denis GIROU (CNRS/IDRIS - France) - &lt;Denis.Girou@idris.fr&gt; - 10 Sep. 1996
354
 
% Can't work with LaTeX 2e
355
 
%  \@input{longtable.sty}%
356
 
%  \@input{longtabl.sty}%
357
 
%  \@input{array.sty}%
358
 
  \@input{longtable.styX}% Avoid loading of longtable.sty...
359
 
  \@input{longtabl.sty}%
360
 
  \@input{array.styX}% Avoid loading of array.sty...
361
 
  \@testtrue
362
 
  \@ifundefined{c@LT@tables}{\@testfalse}{}%
363
 
  \@ifundefined{d@llarbegin}{\@testfalse}{}%
364
 
  \if@test\else
365
 
    \renewenvironment{example}{\VerbatimEnvironment\LVerbatim}{\endLVerbatim}%
366
 
  \fi
367
 
  \makeatother
368
 
\begin{example}
369
 
  \LARGE
370
 
  \begin{longtable}{|!{\LCiii}l||!{\LCi}c|!{\LCi}c|}\hline
371
 
    \LColors \gray & & \\
372
 
      Tamarind & Chiplote & Galanga\\ \hline
373
 
    \LColors \lightgray & & \gray\\
374
 
      Lulu & & Serrano\\ \hline
375
 
      Guanabana & Larga &\\ \hline
376
 
  \end{longtable}
377
 
\end{example}
378
 
\endgroup
379
 
 
380
 
\section{Coloring lines}
381
 
 
382
 
Let's begin with the "\halign" environment. Changing the color of lines is
383
 
easy, because if you write, say, "{\gray\hrule}", then the line comes out
384
 
gray. For example:
385
 
\begin{example}
386
 
  % Thicker lines and wider spacing give better view:
387
 
  \setbox\strutbox=\hbox{%
388
 
    \vrule height15.5pt depth8.5pt width0pt}%
389
 
  \def\Hrule{\hrule height 2.5pt}%
390
 
  \def\Vrule{\vrule width 2.5pt}%
391
 
  % Now the table:
392
 
  \vbox{\offinterlineskip
393
 
    \halign{%
394
 
        {\lightgray\Vrule}\strut\quad\hfil#\hfil\quad
395
 
        &{\gray\Vrule}\quad\hfil#\quad\Vrule\cr
396
 
      \noalign{\Hrule}%
397
 
      Tamarind& Chiplote\cr\noalign{{\darkgray\Hrule}}%
398
 
      Lulu& Serrano\cr\noalign{\Hrule}%
399
 
      Guanabana& Larga\cr\noalign{{\lightgray\Hrule}}%
400
 
  }}
401
 
\end{example}
402
 
 
403
 
With \LaTeX, you can add an entry like
404
 
\begin{LVerbatim}
405
 
  @{\hspace{\tabcolsep}{\gray\vrule}\hspace{\tabcolsep}}
406
 
\end{LVerbatim}
407
 
to the argument of the alignment environment, instead of "|", if you want to
408
 
color the vertical line that is drawn. If using "array.sty", you can try:
409
 
\begin{LVerbatim}
410
 
  !{{\gray\vrule}}
411
 
\end{LVerbatim}
412
 
 
413
 
To color horizontal lines with \LaTeX, don't bother trying
414
 
\begin{LVerbatim}
415
 
  {\gray\hline}
416
 
\end{LVerbatim}
417
 
because it won't work. You write your own version of "\hline" and "\cline", or
418
 
use the non-aligned color commands described in the next section.
419
 
 
420
 
\section{Non-aligned color with PSTricks}
421
 
 
422
 
Here are a few other commands that can be useful for adding color to tables.
423
 
{\bf They only work with PSTricks, v0.93 or later.} <color> in this case is
424
 
the name of the color, without the backslash. These fudge the color commands
425
 
so that they do not have to be balanced with respect to \TeX\ grouping. You
426
 
can achieve the same thing using "\special{<raw postscript>}" and "\noalign",
427
 
if you know what you are doing. These should work with just about any
428
 
alignment macro, include "\halign" and \LaTeX's "tabular" environment.
429
 
 
430
 
\begin{description}
431
 
 
432
 
\vitem"\AC{<color>} ... \EAC" \
433
 
 
434
 
  These stand for "AlignColor" and "EndAlignColor", respectively. <color> is
435
 
the name of the color, without a backslash, rather than a color command. This
436
 
can be used within a cell, but they do not have to be within the same cell,
437
 
nor do they have to be properly nested with respect to \TeX\ grouping.
438
 
Generally, "\AC{<color>}" switches to <color>, and \n\EAC\ restores the color
439
 
that would be in effect if the first \n\AC\ command were missing.
440
 
 
441
 
\vitem"\NAC{<color>} ... \ENAC" \
442
 
 
443
 
  These stand for "NoAlignColor" and "EndNoAlignColor", respectively. These
444
 
are like \n\AC\ and \n\EAC, but the color commands are put inside a
445
 
"\noalign". They can only appear at the end of a line, after "\\" or "\cr".
446
 
 
447
 
\end{description}
448
 
Actually, these do not even have to be used in pairs.
449
 
 
450
 
Here is an example of how "\AC", etc., can be used. to color lines in \LaTeX\
451
 
arrays. The output will appear in this documentation only if PSTricks is
452
 
installed on your system:
453
 
\begingroup
454
 
\ifx\PSTricksLoaded\endinput\else
455
 
  \renewenvironment{example}{\VerbatimEnvironment\LVerbatim}{\endLVerbatim}
456
 
\fi
457
 
\begin{example}
458
 
  \arrayrulewidth 1.5pt
459
 
  \begin{tabular}{|l|c|}\hline
460
 
    Tamarind& Chiplote\\ \NAC{gray}\hline\ENAC
461
 
    Lulu& Serrano\\ \cline{1-1}
462
 
      \NAC{lightgray}\cline{2-2}\ENAC
463
 
    Guanabana\AC{lightgray} & \EAC Larga\\ \hline
464
 
  \end{tabular}
465
 
\end{example}
466
 
\endgroup
467
 
 
468
 
\end{document}
469
 
%% END colortab.doc