ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

The Color Table Package


Enviado por   •  16 de Mayo de 2013  •  1.358 Palabras (6 Páginas)  •  441 Visitas

Página 1 de 6

The colortbl package

David Carlisle

2001/02/13

Abstract

This package implements a flexibable mechanism for giving colured ‘panels’

behind specified columns in a table. This package requires the array and

color packages.

1 Introduction

This package is for colouring tables (i.e., giving coloured panels behind column

entries). In that it has many similarities with Timothy Van Zandt’s colortab

package. The internal implementation is quite different though, also colortab works

with the table constructs of other formats besides LATEX. This package requires

LATEX (and its color and array packages).

First, a standard tabular, for comparison.

\begin{tabular}{|l|c|}

one&two\\

three&four

\end{tabular}

one two

three four

2 The \columncolor command

The examples below demonstrate various possibilities of the \columncolor command

introduced by this package. The vertical rules specified by | are kept in

all the examples, to make the column positioning clearer, although possibly you

would not want coloured panels and vertical rules in practice.

The package supplies a \columncolor command, that should (only) be used in

the argument of a > column specifier, to add a coloured panel behind the specified

column. It can be used in the main ‘preamble’ argument of array or tabular, and

also in \multicolumn specifiers.

The basic format is:

\columncolor[hcolor modeli]{hcolour i} [hleft overhangi][hright overhangi]

The first argument (or first two if the optional argument is used) are standard

color package arguments, as used by \color.

The last two arguments control how far the panel overlaps past the widest

entry in the column. If the right overhang argument is omitted then it defaults to

left overhang. If they are both omitted they default to \tabcolsep (in tabular) or

\arraycolsep (in array).

If the overhangs are both set to 0pt then the effect is:

This file has version number v0.1j, last revised 2001/02/13.

1

|>{\columncolor[gray]{.8}[0pt]}l|

>{\color{white}%

\columncolor[gray]{.2}[0pt]}l|

one two

three four

The default overhang of \tabcolsep produces:

|>{\columncolor[gray]{.8}}l|

>{\color{white}%

\columncolor[gray]{.2}}l|

one two

three four

You might want something between these two extremes. A value of .5\tabcolsep

produces the following effect

|>{\columncolor[gray]{.8}[.5\tabcolsep]}l|

>{\color{white}%

\columncolor[gray]{.2}[.5\tabcolsep]}l|

one two

three four

This package should work with most other packages that are compatible with

the array package syntax. In particular it works with longtable and dcolumn as the

following example shows.

Before starting give a little space: \setlength\minrowclearance{2pt}

A long table example

First two columns Third column

p-type D-type (dcolumn)

P-column and another one 12·34

Total (wrong) 100·6

Some long

text in the

first column

bbb 1·2

aaa and some long text

in the second

column

1·345

Total (wrong) 100·6

aaa bbb 1·345

Note that

the coloured

rules in all

columns

stretch to

accomodate

large entries

in one

column.

bbb 1·345

aaa bbb 100

Continued. . .

2

A long table example (continued)

First two columns Third column

p-type D-type (dcolumn)

aaa Depending on your

driver you may get

unsightly gaps or

lines where the

‘screens’ used to

produce different

shapes interact

badly. You may

want to cause

adjacent panels of

the same colour by

specifying a larger

overhang or by

adding some

negative space (in

a \noalign

between rows.

12·4

aaa bbb 45·3

The End

This example shows rather poor taste but is quite colourful! Inspect the source

file, colortbl.dtx, to see the full code for the example, but it uses the following

column types.

\newcolumntype{A}{%

>{\color{white}\columncolor{red}[.5\tabcolsep]%

\raggedright}%

p{2cm}}

\newcolumntype{B}{%

>{\columncolor{blue}[.5\tabcolsep]%

\color{yellow}\raggedright}

p{3cm}}

\newcolumntype{C}{%

>{\columncolor{yellow}[.5\tabcolsep]}%

D{.}{\cdot}{3.3}}

\newcolumntype{E}{%

>{\large\bfseries

\columncolor{cyan}[.5\tabcolsep]}c}

\newcolumntype{F}{%

>{\color{white}

\columncolor{magenta}[.5\tabcolsep]}c}

\newcolumntype{G}{%

>{\columncolor[gray]{0.8}[.5\tabcolsep][\tabcolsep]}l}

\newcolumntype{H}{>{\columncolor[gray]{0.8}}l}

\newcolumntype{I}{%

>{\columncolor[gray]{0.8}[\tabcolsep][.5\tabcolsep]}%

D{.}{\cdot}{3.3}}

3

3 Using the ‘overhang’ arguments for tabular*

The above is all very well for tabular, but what about tabular*?

Here the problem is rather harder. Although TEX’s \leader mechanism which

is used by this package to insert the ‘stretchy’ coloured panels is rather like glue,

the \tabskip glue that is inserted between columns of tabular* (and longtable for

that matter) has to be ‘real glue’ and not ‘leaders’.

Within limits the overhang options may be used here. Consider the first table

example above. If we use tabular* set to 3 cm with a preamble setting of

\begin{tabular*}{3cm}{%

@{\extracolsep{\fill}}

>{\columncolor[gray]{.8}[0pt][20mm]}l

>{\columncolor[gray]{.8}[5mm][0pt]}l

@{}}

one two

three four

Changing the specified width to 4 cm works, but don’t push your luck to

5 cm. . .

one two

three four

one two

three four

4 The \rowcolor command

As demonstrated above, one may change the colour of specified rows of a table

by the use of \multicolumn commands in each entry of the row. However if your

table is to be marked principally by rows, you may find this rather inconvenient.

For this reason a new mechanism, \rowcolor, has been introduced1.

\rowcolor takes the same

...

Descargar como (para miembros actualizados) txt (12 Kb)
Leer 5 páginas más »
Disponible sólo en Clubensayos.com