SlideShare a Scribd company logo
Indian TEX Users Group
URL :

http://www.river-valley.com/tug

The colortbl . . .
More colors and . . .

8

Color tables . . .
More Examples . . .

Title Page

A
On-line Tutorial on LTEX
The Tutorial Team
Indian TEX Users Group, SJP Buildings, Cotton Hills
Trivandrum 695014, INDIA
2000
Prof. (Dr.) K. S. S. Nambooripad, Director, Center for Mathematical Sciences, Trivandrum, (Editor); Dr. E. Krishnan,
Reader in Mathematics, University College, Trivandrum; Mohit Agarwal, Department of Aerospace Engineering,
Indian Institute of Science, Bangalore; T. Rishi, Focal Image (India) Pvt. Ltd., Trivandrum; L. A. Ajith, Focal Image
(India) Pvt. Ltd., Trivandrum; A. M. Shan, Focal Image (India) Pvt. Ltd., Trivandrum; C. V. Radhakrishnan, River
Valley Technologies, Software Technology Park, Trivandrum constitute the Tutorial team
A
A
This document is generated from LTEX sources compiled with pdfLTEX v. 14e in an
INTEL Pentium III 700 MHz system running Linux kernel version 2.2.14-12. The
packages used are hyperref.sty and pdfscreen.sty

c 2000, Indian TEX Users Group. This document may be distributed under the terms of the
A
A
LTEX Project Public License, as described in lppl.txt in the base LTEX distribution, either
version 1.0 or, at your option, any later version

Page 1 of 14

Go Back

Full Screen

Close

Quit
A
8 Color tables in LTEX
The colortbl . . .
More colors and . . .
Color tables . . .

8.1.

The colortbl package
A
In the previous chapters we learnt how to construct tables in LTEX that could span even to a number of pages. Here we shall see how to obtain color cells in tables, using David Carlisle’s colortbl
package. This package requires the color and array packages.

More Examples . . .

Title Page

The colortbl package provides a number of commands using which one can obtain really
colorful tables. We shall demonstrate each of these with the help of simple examples in the
following sections.

8.1.1.

The columncolor command
Page 2 of 14

The format for the columncolor command is
columncolor[ color model ]{ color }[ left overhang ][ right overhang ]

Go Back

Full Screen

Color model

It changes the current color to the argument specified until the end of the
current group or the environment. The colors black, white, red, green,
blue, cyan, magenta, and yellow should be predefined by any driver. Colors
can also be defined by a package, as well as by the use of definecolor

Close

Quit
command1 .
Color
It is an optional argument, and is like a specification to the color model given.
This is particularly convenient if one wants to use a color without defining it
initially.
Left overhang It controls the width of the panel past the widest entry in the column. It is
also an optional argument, and takes the value tabcolsep (in tabular) and
arraycolsep (in array).
Right overhang If ommited it defaults to the left overhang.
We have a few different tables below that will demonstrate a few possibilities using the columncolor
command.

The colortbl . . .
More colors and . . .
Color tables . . .
More Examples . . .

Title Page

one
three

two
four

begin{tabular}{|l|r|}
hline
{one} & {two} 
{three} & {four} hline
end{tabular}
Page 3 of 14

In the following table both the overhangs are set to 0pt.
Go Back

one
three

two
four

|>{columncolor{khaki}[0pt]}l|
>{color{blue}columncolor[gray]{.8}[0pt]}r|

The default overhang of tabcolsep produces:
1

For instance, by using the command definecolor{myblue}{rgb}{.8,.85,1}, you can have the color

myblue.

Full Screen

Close

Quit
one
three

two
four

|>{columncolor{khaki}}l|
>{color{blue}columncolor[gray]{.8}}r|

It is also possible to have colors like the one below! Using multicolumn it is possible to
change the color of specified rows of a table.

The colortbl . . .
More colors and . . .
Color tables . . .

one
three

8.1.2.

multicolumn{1}{|>{color{blue}columncolor[gray]%
{0.8}}l|}{three} &
multicolumn{1}{|>{columncolor{khaki}}r|}{four}

two
four

More Examples . . .

Title Page

The rowcolor command
The rowcolor command is helpful in case a table is maked principally by rows. The arguments in rowcolor are of the form as in columncolor. Here’s an example:
Page 4 of 14

one
three
five

two
four
six

A multicolumn command
overrides the default colors
for both the current row and
column.

begin{tabular}{|l||r|}
hline
rowcolor{lightturquoise} {one} & {two} 
rowcolor{honeydew} {three} & {four} 
multicolumn{1}{|>{color{blue}columncolor[gray]%
{0.8}}l||}{five} &
multicolumn{1}{|>{columncolor{khaki}}r|}{six}
hline
end{tabular}

Go Back

Full Screen

Close

Quit
8.2.

More colors and tricks
In this section we’ll see how to obtain even more colors: colored rules, colored space between
two rules, and more.
Colored rules can be easily obtained wherever desired by replacing the | with something
like !{color{green}vline}.
The above trick still leaves the spaces between || white. In order to obtain colored space
one can remove the inter glue, and replace it by a colored rule. For instance,
!{color{green}vline}
@{color{yellow}vrule width doublerulesep}
!{color{green}vline}

would change the color of the rules to green, and there would be another yellow rule of
thickness equal to doublerulesep between the two.
arrayrulewidth specifies the ‘thickness’ of the rules. The default is set to 0.4pt and
can be changed by using, for instance, setwidtharrayrulewidth{1pt} to a value of
1pt.

The colortbl . . .
More colors and . . .
Color tables . . .
More Examples . . .

Title Page

Page 5 of 14

arrayrulecolor takes the same arguments as color. It can be specified at any point

in the table. However, if given in the mid table it affects only the rules that are specified
after that point, and any vertical rules in the table ‘preamble’ keep their original colors.
For example, the command

Go Back

Full Screen

setlengtharrayrulewidth{1pt}arrayrulecolor{blue}

would set the arrayrulewidth to 1pt and the rule color to blue.

Close

doublerulesep specifies the space between the double rules.
Quit
doublerulesepcolor works in the same way as arrayrulecolor, and refers to the

color between double rules.
minrowclearance is used for inserting space at any desired row.

8.3.

Color tables with hhline

The colortbl . . .
More colors and . . .

There are many advantages of using hhline (hhline package) to draw horizontal rules instead of cline. Firstly, hhline provides more flexibility in producing the rules particularly
because of the way it interacts with the vertical lines. Moreover, sometimes the color of the lines
produced by cline doesn’t appear (rather it’s covered up by the color panels in the following
row). So it becomes more appropriate if one uses the − rule type in a hhline argument.

Color tables . . .
More Examples . . .

Title Page

The hhline command can be used to produce a single rule, or a double rule. hhline has
arguments very similar to those in the ‘preamble’ of an array or tabular.
=
−
∼
|
:
#

A double hline equal to the column width.
A single hline equal to the column width.
A column with no hline.
A vline which cuts through a double (or single) hline.
A vline which is broken by a double line.
A double hline segment between two vlines.
t The top half of a double hline segment.
b The bottom half of a double hline segment.
∗ *{3}{==#} expands to ==#==#==#, as in the *-form for the preamble.
We now demonstrate an example of the hhline command in the following table:

Page 6 of 14

Go Back

Full Screen

Close

Quit
A table using hhline
S.No. Col. 1 Col. 2
1
abc
def
2
pqr
lmn
3
uvw
xyz
n
pqr
lmn

The colortbl . . .
More colors and . . .

arrayrulecolor{white}
begin{tabular}{>{columncolor{honeydew}}c
>{columncolor{honeydew}}c|
>{columncolor{honeydew}}c}
multicolumn{3}{>{columncolor{wheat}}l}
textbf{A table using {sf hline}}
rowcolor{white} textbf{S.No.} & textbf{Col. 1} &
textbf{Col. 2}
arrayrulecolor{black}
rowcolor{khaki}
{1} & {abc} & {def} hhline{˜--}
rowcolor{lightsteelblue}
{2} & {pqr} & {lmn} hhline{˜--}
{3} & {uvw} & {xyz} hhline{˜--}
rowcolor{white}
{n} & {pqr} & {lmn}
end{tabular}

Color tables . . .
More Examples . . .

Title Page

Page 7 of 14

Go Back

Full Screen

Close

Quit
8.4.

More Examples of Color Table
All these examples are taken from the TEXLive CDROM. The first example is not a table, but a
horizontally packed colorboxes.
The colortbl . . .

cyan (C):

.0

.1

.2

.3

.4

.5

.6

.7

.8

.9

magenta (M):

.0

.1

.2

.3

.4

.5

.6

.7

.8

.9

Color tables . . .

yellow (Y):

.0

.1

.2

.3

.4

.5

.6

.7

.8

.9

More Examples . . .

black (K):

.0

.1

.2

.3

.4

.5

.6

.7

.8

.9

More colors and . . .

Title Page

newcounter{Colr}
setlength{fboxsep}{2mm}
begin{flushleft}
newcommand{CBox}[1]{colorbox[cmyk]{.#1,0.,0.,0.}{.#1}}
makebox[30mm][l]{cyan (C):}
whiledo{value{Colr}<10}{CBox{theColr}stepcounter{Colr}}
renewcommand{CBox}[1]{colorbox[cmyk]{0.,.#1,0.,0.}{.#1}}
setcounter{Colr}{0}makebox[30mm][l]{magenta (M):}
whiledo{value{Colr}<10}{CBox{theColr}stepcounter{Colr}}
renewcommand{CBox}[1]{colorbox[cmyk]{0.,0.,.#1,0.}{.#1}}
setcounter{Colr}{0}makebox[30mm][l]{yellow (Y):}
whiledo{value{Colr}<10}{CBox{theColr}stepcounter{Colr}}
renewcommand{CBox}[1]{colorbox[cmyk]{0.,0.,0.,.#1}{.#1}}
setcounter{Colr}{0}makebox[30mm][l]{black (K):}
whiledo{value{Colr}<10}{CBox{theColr}stepcounter{Colr}}
end{flushleft}

Page 8 of 14

Go Back

Full Screen

Close

Quit
LONDON
Sydney

Price
OG4G

Mon Oct 21 or 28

11 or 18 days

999GBP

Thu Oct 17

Mon Oct 21 or 28

4 or 11 days

999GBP

Sun Oct 13

Mon Oct 21 or 28

8 or 15 days

999GBP

The colortbl . . .

Sun Oct 20

OG7A

Thu Oct 10

Mon Oct 28

8 days

999GBP

More colors and . . .

This is a column colored table. The same table is made row coloured in the next one.

Color tables . . .
More Examples . . .

setlength{extrarowheight}{2mm}
setlength{tabcolsep}{2mm}
begin{tabular}{|l|%
>{columncolor{yellow}}c|c|>{columncolor{yellow}}c|c|%
>{columncolor{red}bfseries}c<{textsc{GBP}}|}
hline
multicolumn{3}{>{columncolor{red}}l}{color{white}textsf{LONDON}}
&multicolumn{3}{>{columncolor{red}}r}{color{white}textsf{Price}}
[1pt]
hline
Sydney & OG4G &Thu Oct 10 &Mon Oct 21 or 28 &11 or 18 days &999
&
&Thu Oct 17 &Mon Oct 21 or 28 & 4 or 11 days &999
& OG7A &Sun Oct 13 &Mon Oct 21 or 28 & 8 or 15 days &999
&
&Sun Oct 20 &Mon Oct 28
& 8 days
&999
hline
end{tabular}

Title Page

Page 9 of 14

Go Back

Full Screen

Close

Quit
Sydney

OG4G

Mon Oct 21 or 28

11 or 18 days

999

Thu Oct 17

Mon Oct 21 or 28

4 or 11 days

999

Sun Oct 13

Mon Oct 21 or 28

8 or 15 days

999

Sun Oct 20

OG7A

Thu Oct 10

Mon Oct 28

8 days

999

The colortbl . . .
More colors and . . .

setlength{extrarowheight}{2mm}
begin{tabular}{|l|c|c|c|c|c|c|c|}
hline
Sydney
& OG4G &Thu Oct 10 &Mon Oct
rowcolor[gray]{0.5}
&
&Thu Oct 17 &Mon Oct
&OG7A &Sun Oct 13 &Mon Oct
rowcolor[gray]{0.5}
&
&Sun Oct 20 &Mon Oct
hline
end{tabular}

Color tables . . .
More Examples . . .

21 or 28 &11 or 18 days &999
Title Page

21 or 28 & 4 or 11 days &999
21 or 28 & 8 or 15 days &999
28

& 8 days

&999

Page 10 of 14

Go Back

Full Screen

Close

Quit
See the rule colours have different ones in the following example.
United Kingdom
France
Russia

London
Paris
Moscow

Thames
Seine
Moskva
The colortbl . . .

setlength{arrayrulewidth}{2pt}
arrayrulecolor{green}
begin{tabular}{|l|c|r|}
arrayrulecolor{black}hline
United Kingdom & London & Thames
arrayrulecolor{blue}hline
France
& Paris & Seine 
arrayrulecolor{black}cline{1-1}
arrayrulecolor{red}cline{2-3}
Russia & Moscow & Moskva  hline
end{tabular}

More colors and . . .
Color tables . . .
More Examples . . .

Title Page

Page 11 of 14

Go Back

Full Screen

Close

Quit
It is possible to keep some cells of a table in white while keeping the whole table in a different
colour.

Table title
Description
Row one
Row two
Row three
Row four
Totals

Column 1

Column 2

mmmmm
mmmm
mmmmm
mmmmm
mmmmm

mmmm
mmm
mmmmm
mmmm
mmmmm

The colortbl . . .
More colors and . . .
Color tables . . .
More Examples . . .

Title Page

newcommand{CTPanel}[1]{%
multicolumn{1}{>{columncolor{white}}r|}{#1}}
setlengthfboxsep{3mm}
colorbox[cmyk]{.40,0,0,0}{%
begin{tabular}{l|r|r}
multicolumn{1}{l|}
{largetextbf{Table title}}[2mm]
textbf{Description} & textbf{Column 1}
& textbf{Column 2} [1mm]hline
Row one & CTPanel{mmmmm} & CTPanel{mmmm} hline
Row two & CTPanel{mmmm} & CTPanel{mmm} hline
Row three& CTPanel{mmmmm} & CTPanel{mmmmm}hline
Row four & CTPanel{mmmmm} & CTPanel{mmmm} hline
Totals
& mmmmm & mmmmm
end{tabular}}

Page 12 of 14

Go Back

Full Screen

Close

Quit
Table title
Description
Row one
Row two
Row three
Row four
Totals

Column 1
mmmmm
mmmm
mmmmm
mmmmm
mmmmm

Column 2
mmmm
mmm
mmmmm
mmmm
mmmmm

The colortbl . . .
More colors and . . .
Color tables . . .
More Examples . . .

definecolor{Blueb}{cmyk}{.40,0,0,0}
definecolor{Blued}{cmyk}{.80,0,0,0}
arrayrulecolor{white}
begin{tabular}{>{columncolor{Blued}}l
>{columncolor{Blued}}r|%
>{columncolor{Blued}}r}
multicolumn{3}{>{columncolor{Blueb}}l}%
{largetextbf{Table title}}[2mm]
rowcolor{white}
textbf{Description} & textbf{Column 1}
& textbf{Column 2} [1mm]
arrayrulecolor{black}
rowcolor{Blueb}
Row one
& mmmmm & mmmm hhline{˜--}
Row two
& mmmm & mmm hhline{˜--}
Row three & mmmmm & mmmmmhhline{˜--}
Row four & mmmmm & mmmmhhline{˜--}
rowcolor{white} Totals
& mmmmm & mmmmm
end{tabular}

Title Page

Page 13 of 14

Go Back

Full Screen

Close

Quit
Table title
Description
Row one
Row two
Row three
Row four
Totals

Column 1

Column 2

mmmmm
mmmm
mmmmm
mmmmm
mmmmm

mmmm
mmm
mmmmm
mmmm
mmmmm

The colortbl . . .
More colors and . . .
Color tables . . .
More Examples . . .

definecolor{Blueb}{cmyk}{.40,0,0,0}
definecolor{Blued}{cmyk}{.80,0,0,0}
definecolor{Bluee}{cmyk}{1.0,0,0,0}
arrayrulecolor{black}
setlengtharrayrulewidth{1mm}
begin{tabular}{llrrl}
rowcolor{Blueb}
qquad&multicolumn{3}{>{columncolor{Blueb}}l}
{largetextbf{Table title}}&qquad[2mm]
rowcolor{Blued}& textbf{Description}
& textbf{Column 1}
& textbf{Column 2}& [2mm]
hline
rowcolor{Blued}& Row one & mmmmm & mmmm &
rowcolor{Blued}& Row two & mmmm & mmm &
rowcolor{Blued}& Row three& mmmmm & mmmmm&
rowcolor{Blued}& Row four & mmmmm & mmmm &
cline{2-3}
rowcolor{Bluee}& Totals & mmmmm & mmmmm&[2mm]
end{tabular}

Title Page

Page 14 of 14

Go Back

Full Screen

Close

Quit

More Related Content

PDF
Chap11 scr
PPTX
Presentation on use of r statistics
PDF
Typesetting Theses / Reports with LaTeX : Workshop Day 3
PPTX
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION By Sintiak Haque
PDF
Chap17 scr
PDF
Computer concrete
PDF
GDP.s ASA
PPTX
Workshop social media trends 2014
Chap11 scr
Presentation on use of r statistics
Typesetting Theses / Reports with LaTeX : Workshop Day 3
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION By Sintiak Haque
Chap17 scr
Computer concrete
GDP.s ASA
Workshop social media trends 2014

Viewers also liked (20)

PDF
Whats ahead for the economy ASA
PDF
Gfs artemisia
TXT
成熟稳重
PPTX
Holy Trinity_A-Z
PDF
AN EFFICIENT PROXY SIGNCRYPTION SCHEME BASED ON THE DISCRETE LOGARITHM PROBLEM
PDF
Ping! LaTeX
PPT
Ramadan fasting and muslim patients
PDF
Fulfilling real time analytics on obi apps platform
PDF
LATEX OR INDESIGN
PPTX
Strategic Business Planning Development
PDF
บังต่อ
PDF
Freewilly with beamerusetheme Torino.sty
PPTX
21st Education PowerPoint
PDF
Sustainable business-sgd-2012-iitr
PDF
Fancyslides Beamer
PPS
Temeto
PDF
Air Beamer
PPT
Tom jones
PDF
Execushares beamer
PPTX
Providing the ultimate publishing experience
Whats ahead for the economy ASA
Gfs artemisia
成熟稳重
Holy Trinity_A-Z
AN EFFICIENT PROXY SIGNCRYPTION SCHEME BASED ON THE DISCRETE LOGARITHM PROBLEM
Ping! LaTeX
Ramadan fasting and muslim patients
Fulfilling real time analytics on obi apps platform
LATEX OR INDESIGN
Strategic Business Planning Development
บังต่อ
Freewilly with beamerusetheme Torino.sty
21st Education PowerPoint
Sustainable business-sgd-2012-iitr
Fancyslides Beamer
Temeto
Air Beamer
Tom jones
Execushares beamer
Providing the ultimate publishing experience
Ad

Similar to Chap08 scr (20)

PDF
Latex tables and figures
PDF
Chap07 scr
PPTX
Rajeev ranjan
PDF
Chap06 scr
PDF
MATLAB
PDF
Chap04 scr
PDF
La tex basics
PDF
Chap13 scr
PPTX
Lecture_3.pptx
PDF
Ltxcrib
PDF
An Introduction to MATLAB with Worked Examples
PDF
Chap05 scr
PDF
Matlab Tutorial for Beginners - I
PPTX
3_MATLAB Basics Introduction for Engineers .pptx
PDF
Chap14 scr
PDF
SATISFIABILITY METHODS FOR COLOURING GRAPHS
PDF
MATLAB PLOT.pdf
PDF
How to build beautiful slides pdf format idea .
PPTX
Using package amsmath typing equation labeling and referring.pptx
Latex tables and figures
Chap07 scr
Rajeev ranjan
Chap06 scr
MATLAB
Chap04 scr
La tex basics
Chap13 scr
Lecture_3.pptx
Ltxcrib
An Introduction to MATLAB with Worked Examples
Chap05 scr
Matlab Tutorial for Beginners - I
3_MATLAB Basics Introduction for Engineers .pptx
Chap14 scr
SATISFIABILITY METHODS FOR COLOURING GRAPHS
MATLAB PLOT.pdf
How to build beautiful slides pdf format idea .
Using package amsmath typing equation labeling and referring.pptx
Ad

More from Hirwanto Iwan (20)

PDF
Analisis Butir Soal PAS Matematika Wajib Kelas 12 IPA/IPS 2024-2025
PDF
01. integral fungsi aljabar
PDF
Analisis Butir Soal PG Matematika Wajib Kelas XII IPA-IPS NFBS Serang
PDF
Analisis Butir Soal Pilihan Ganda Matematika Wajib Kelas XII IPA
PDF
Materi Limit Aljabar dan Turunan Aljabar
PDF
Pembahasan Soal Matematika Wajib PTS Kelas XI IPS
PDF
Pembahasan Soal Matematika Wajib PTS Kelas XI IPA
PDF
Fitur Baru WinEdt 9.1
PDF
Pemasangan WinEdt 9.1
PDF
Kumpulan Soal UM UGM
PDF
Membuat Dokumen LaTeX Edisi ke - 33
PDF
AGH Beamer
PDF
AFIT Beamer
PDF
Hackd Beamer
PDF
LUH Beamer
PDF
Cambridge Beamer
PDF
ESOP Beamer
PDF
AP Beamer
PDF
Naked Beamer
PDF
TUDelft Beamer
Analisis Butir Soal PAS Matematika Wajib Kelas 12 IPA/IPS 2024-2025
01. integral fungsi aljabar
Analisis Butir Soal PG Matematika Wajib Kelas XII IPA-IPS NFBS Serang
Analisis Butir Soal Pilihan Ganda Matematika Wajib Kelas XII IPA
Materi Limit Aljabar dan Turunan Aljabar
Pembahasan Soal Matematika Wajib PTS Kelas XI IPS
Pembahasan Soal Matematika Wajib PTS Kelas XI IPA
Fitur Baru WinEdt 9.1
Pemasangan WinEdt 9.1
Kumpulan Soal UM UGM
Membuat Dokumen LaTeX Edisi ke - 33
AGH Beamer
AFIT Beamer
Hackd Beamer
LUH Beamer
Cambridge Beamer
ESOP Beamer
AP Beamer
Naked Beamer
TUDelft Beamer

Recently uploaded (20)

PPTX
Chapter 5: Probability Theory and Statistics
PDF
Encapsulation theory and applications.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
August Patch Tuesday
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
project resource management chapter-09.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Tartificialntelligence_presentation.pptx
Chapter 5: Probability Theory and Statistics
Encapsulation theory and applications.pdf
1 - Historical Antecedents, Social Consideration.pdf
August Patch Tuesday
Heart disease approach using modified random forest and particle swarm optimi...
A comparative analysis of optical character recognition models for extracting...
Building Integrated photovoltaic BIPV_UPV.pdf
Enhancing emotion recognition model for a student engagement use case through...
A comparative study of natural language inference in Swahili using monolingua...
Hindi spoken digit analysis for native and non-native speakers
Unlocking AI with Model Context Protocol (MCP)
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Web App vs Mobile App What Should You Build First.pdf
Group 1 Presentation -Planning and Decision Making .pptx
Encapsulation_ Review paper, used for researhc scholars
project resource management chapter-09.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Programs and apps: productivity, graphics, security and other tools
Tartificialntelligence_presentation.pptx

Chap08 scr

  • 1. Indian TEX Users Group URL : http://www.river-valley.com/tug The colortbl . . . More colors and . . . 8 Color tables . . . More Examples . . . Title Page A On-line Tutorial on LTEX The Tutorial Team Indian TEX Users Group, SJP Buildings, Cotton Hills Trivandrum 695014, INDIA 2000 Prof. (Dr.) K. S. S. Nambooripad, Director, Center for Mathematical Sciences, Trivandrum, (Editor); Dr. E. Krishnan, Reader in Mathematics, University College, Trivandrum; Mohit Agarwal, Department of Aerospace Engineering, Indian Institute of Science, Bangalore; T. Rishi, Focal Image (India) Pvt. Ltd., Trivandrum; L. A. Ajith, Focal Image (India) Pvt. Ltd., Trivandrum; A. M. Shan, Focal Image (India) Pvt. Ltd., Trivandrum; C. V. Radhakrishnan, River Valley Technologies, Software Technology Park, Trivandrum constitute the Tutorial team A A This document is generated from LTEX sources compiled with pdfLTEX v. 14e in an INTEL Pentium III 700 MHz system running Linux kernel version 2.2.14-12. The packages used are hyperref.sty and pdfscreen.sty c 2000, Indian TEX Users Group. This document may be distributed under the terms of the A A LTEX Project Public License, as described in lppl.txt in the base LTEX distribution, either version 1.0 or, at your option, any later version Page 1 of 14 Go Back Full Screen Close Quit
  • 2. A 8 Color tables in LTEX The colortbl . . . More colors and . . . Color tables . . . 8.1. The colortbl package A In the previous chapters we learnt how to construct tables in LTEX that could span even to a number of pages. Here we shall see how to obtain color cells in tables, using David Carlisle’s colortbl package. This package requires the color and array packages. More Examples . . . Title Page The colortbl package provides a number of commands using which one can obtain really colorful tables. We shall demonstrate each of these with the help of simple examples in the following sections. 8.1.1. The columncolor command Page 2 of 14 The format for the columncolor command is columncolor[ color model ]{ color }[ left overhang ][ right overhang ] Go Back Full Screen Color model It changes the current color to the argument specified until the end of the current group or the environment. The colors black, white, red, green, blue, cyan, magenta, and yellow should be predefined by any driver. Colors can also be defined by a package, as well as by the use of definecolor Close Quit
  • 3. command1 . Color It is an optional argument, and is like a specification to the color model given. This is particularly convenient if one wants to use a color without defining it initially. Left overhang It controls the width of the panel past the widest entry in the column. It is also an optional argument, and takes the value tabcolsep (in tabular) and arraycolsep (in array). Right overhang If ommited it defaults to the left overhang. We have a few different tables below that will demonstrate a few possibilities using the columncolor command. The colortbl . . . More colors and . . . Color tables . . . More Examples . . . Title Page one three two four begin{tabular}{|l|r|} hline {one} & {two} {three} & {four} hline end{tabular} Page 3 of 14 In the following table both the overhangs are set to 0pt. Go Back one three two four |>{columncolor{khaki}[0pt]}l| >{color{blue}columncolor[gray]{.8}[0pt]}r| The default overhang of tabcolsep produces: 1 For instance, by using the command definecolor{myblue}{rgb}{.8,.85,1}, you can have the color myblue. Full Screen Close Quit
  • 4. one three two four |>{columncolor{khaki}}l| >{color{blue}columncolor[gray]{.8}}r| It is also possible to have colors like the one below! Using multicolumn it is possible to change the color of specified rows of a table. The colortbl . . . More colors and . . . Color tables . . . one three 8.1.2. multicolumn{1}{|>{color{blue}columncolor[gray]% {0.8}}l|}{three} & multicolumn{1}{|>{columncolor{khaki}}r|}{four} two four More Examples . . . Title Page The rowcolor command The rowcolor command is helpful in case a table is maked principally by rows. The arguments in rowcolor are of the form as in columncolor. Here’s an example: Page 4 of 14 one three five two four six A multicolumn command overrides the default colors for both the current row and column. begin{tabular}{|l||r|} hline rowcolor{lightturquoise} {one} & {two} rowcolor{honeydew} {three} & {four} multicolumn{1}{|>{color{blue}columncolor[gray]% {0.8}}l||}{five} & multicolumn{1}{|>{columncolor{khaki}}r|}{six} hline end{tabular} Go Back Full Screen Close Quit
  • 5. 8.2. More colors and tricks In this section we’ll see how to obtain even more colors: colored rules, colored space between two rules, and more. Colored rules can be easily obtained wherever desired by replacing the | with something like !{color{green}vline}. The above trick still leaves the spaces between || white. In order to obtain colored space one can remove the inter glue, and replace it by a colored rule. For instance, !{color{green}vline} @{color{yellow}vrule width doublerulesep} !{color{green}vline} would change the color of the rules to green, and there would be another yellow rule of thickness equal to doublerulesep between the two. arrayrulewidth specifies the ‘thickness’ of the rules. The default is set to 0.4pt and can be changed by using, for instance, setwidtharrayrulewidth{1pt} to a value of 1pt. The colortbl . . . More colors and . . . Color tables . . . More Examples . . . Title Page Page 5 of 14 arrayrulecolor takes the same arguments as color. It can be specified at any point in the table. However, if given in the mid table it affects only the rules that are specified after that point, and any vertical rules in the table ‘preamble’ keep their original colors. For example, the command Go Back Full Screen setlengtharrayrulewidth{1pt}arrayrulecolor{blue} would set the arrayrulewidth to 1pt and the rule color to blue. Close doublerulesep specifies the space between the double rules. Quit
  • 6. doublerulesepcolor works in the same way as arrayrulecolor, and refers to the color between double rules. minrowclearance is used for inserting space at any desired row. 8.3. Color tables with hhline The colortbl . . . More colors and . . . There are many advantages of using hhline (hhline package) to draw horizontal rules instead of cline. Firstly, hhline provides more flexibility in producing the rules particularly because of the way it interacts with the vertical lines. Moreover, sometimes the color of the lines produced by cline doesn’t appear (rather it’s covered up by the color panels in the following row). So it becomes more appropriate if one uses the − rule type in a hhline argument. Color tables . . . More Examples . . . Title Page The hhline command can be used to produce a single rule, or a double rule. hhline has arguments very similar to those in the ‘preamble’ of an array or tabular. = − ∼ | : # A double hline equal to the column width. A single hline equal to the column width. A column with no hline. A vline which cuts through a double (or single) hline. A vline which is broken by a double line. A double hline segment between two vlines. t The top half of a double hline segment. b The bottom half of a double hline segment. ∗ *{3}{==#} expands to ==#==#==#, as in the *-form for the preamble. We now demonstrate an example of the hhline command in the following table: Page 6 of 14 Go Back Full Screen Close Quit
  • 7. A table using hhline S.No. Col. 1 Col. 2 1 abc def 2 pqr lmn 3 uvw xyz n pqr lmn The colortbl . . . More colors and . . . arrayrulecolor{white} begin{tabular}{>{columncolor{honeydew}}c >{columncolor{honeydew}}c| >{columncolor{honeydew}}c} multicolumn{3}{>{columncolor{wheat}}l} textbf{A table using {sf hline}} rowcolor{white} textbf{S.No.} & textbf{Col. 1} & textbf{Col. 2} arrayrulecolor{black} rowcolor{khaki} {1} & {abc} & {def} hhline{˜--} rowcolor{lightsteelblue} {2} & {pqr} & {lmn} hhline{˜--} {3} & {uvw} & {xyz} hhline{˜--} rowcolor{white} {n} & {pqr} & {lmn} end{tabular} Color tables . . . More Examples . . . Title Page Page 7 of 14 Go Back Full Screen Close Quit
  • 8. 8.4. More Examples of Color Table All these examples are taken from the TEXLive CDROM. The first example is not a table, but a horizontally packed colorboxes. The colortbl . . . cyan (C): .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 magenta (M): .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 Color tables . . . yellow (Y): .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 More Examples . . . black (K): .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 More colors and . . . Title Page newcounter{Colr} setlength{fboxsep}{2mm} begin{flushleft} newcommand{CBox}[1]{colorbox[cmyk]{.#1,0.,0.,0.}{.#1}} makebox[30mm][l]{cyan (C):} whiledo{value{Colr}<10}{CBox{theColr}stepcounter{Colr}} renewcommand{CBox}[1]{colorbox[cmyk]{0.,.#1,0.,0.}{.#1}} setcounter{Colr}{0}makebox[30mm][l]{magenta (M):} whiledo{value{Colr}<10}{CBox{theColr}stepcounter{Colr}} renewcommand{CBox}[1]{colorbox[cmyk]{0.,0.,.#1,0.}{.#1}} setcounter{Colr}{0}makebox[30mm][l]{yellow (Y):} whiledo{value{Colr}<10}{CBox{theColr}stepcounter{Colr}} renewcommand{CBox}[1]{colorbox[cmyk]{0.,0.,0.,.#1}{.#1}} setcounter{Colr}{0}makebox[30mm][l]{black (K):} whiledo{value{Colr}<10}{CBox{theColr}stepcounter{Colr}} end{flushleft} Page 8 of 14 Go Back Full Screen Close Quit
  • 9. LONDON Sydney Price OG4G Mon Oct 21 or 28 11 or 18 days 999GBP Thu Oct 17 Mon Oct 21 or 28 4 or 11 days 999GBP Sun Oct 13 Mon Oct 21 or 28 8 or 15 days 999GBP The colortbl . . . Sun Oct 20 OG7A Thu Oct 10 Mon Oct 28 8 days 999GBP More colors and . . . This is a column colored table. The same table is made row coloured in the next one. Color tables . . . More Examples . . . setlength{extrarowheight}{2mm} setlength{tabcolsep}{2mm} begin{tabular}{|l|% >{columncolor{yellow}}c|c|>{columncolor{yellow}}c|c|% >{columncolor{red}bfseries}c<{textsc{GBP}}|} hline multicolumn{3}{>{columncolor{red}}l}{color{white}textsf{LONDON}} &multicolumn{3}{>{columncolor{red}}r}{color{white}textsf{Price}} [1pt] hline Sydney & OG4G &Thu Oct 10 &Mon Oct 21 or 28 &11 or 18 days &999 & &Thu Oct 17 &Mon Oct 21 or 28 & 4 or 11 days &999 & OG7A &Sun Oct 13 &Mon Oct 21 or 28 & 8 or 15 days &999 & &Sun Oct 20 &Mon Oct 28 & 8 days &999 hline end{tabular} Title Page Page 9 of 14 Go Back Full Screen Close Quit
  • 10. Sydney OG4G Mon Oct 21 or 28 11 or 18 days 999 Thu Oct 17 Mon Oct 21 or 28 4 or 11 days 999 Sun Oct 13 Mon Oct 21 or 28 8 or 15 days 999 Sun Oct 20 OG7A Thu Oct 10 Mon Oct 28 8 days 999 The colortbl . . . More colors and . . . setlength{extrarowheight}{2mm} begin{tabular}{|l|c|c|c|c|c|c|c|} hline Sydney & OG4G &Thu Oct 10 &Mon Oct rowcolor[gray]{0.5} & &Thu Oct 17 &Mon Oct &OG7A &Sun Oct 13 &Mon Oct rowcolor[gray]{0.5} & &Sun Oct 20 &Mon Oct hline end{tabular} Color tables . . . More Examples . . . 21 or 28 &11 or 18 days &999 Title Page 21 or 28 & 4 or 11 days &999 21 or 28 & 8 or 15 days &999 28 & 8 days &999 Page 10 of 14 Go Back Full Screen Close Quit
  • 11. See the rule colours have different ones in the following example. United Kingdom France Russia London Paris Moscow Thames Seine Moskva The colortbl . . . setlength{arrayrulewidth}{2pt} arrayrulecolor{green} begin{tabular}{|l|c|r|} arrayrulecolor{black}hline United Kingdom & London & Thames arrayrulecolor{blue}hline France & Paris & Seine arrayrulecolor{black}cline{1-1} arrayrulecolor{red}cline{2-3} Russia & Moscow & Moskva hline end{tabular} More colors and . . . Color tables . . . More Examples . . . Title Page Page 11 of 14 Go Back Full Screen Close Quit
  • 12. It is possible to keep some cells of a table in white while keeping the whole table in a different colour. Table title Description Row one Row two Row three Row four Totals Column 1 Column 2 mmmmm mmmm mmmmm mmmmm mmmmm mmmm mmm mmmmm mmmm mmmmm The colortbl . . . More colors and . . . Color tables . . . More Examples . . . Title Page newcommand{CTPanel}[1]{% multicolumn{1}{>{columncolor{white}}r|}{#1}} setlengthfboxsep{3mm} colorbox[cmyk]{.40,0,0,0}{% begin{tabular}{l|r|r} multicolumn{1}{l|} {largetextbf{Table title}}[2mm] textbf{Description} & textbf{Column 1} & textbf{Column 2} [1mm]hline Row one & CTPanel{mmmmm} & CTPanel{mmmm} hline Row two & CTPanel{mmmm} & CTPanel{mmm} hline Row three& CTPanel{mmmmm} & CTPanel{mmmmm}hline Row four & CTPanel{mmmmm} & CTPanel{mmmm} hline Totals & mmmmm & mmmmm end{tabular}} Page 12 of 14 Go Back Full Screen Close Quit
  • 13. Table title Description Row one Row two Row three Row four Totals Column 1 mmmmm mmmm mmmmm mmmmm mmmmm Column 2 mmmm mmm mmmmm mmmm mmmmm The colortbl . . . More colors and . . . Color tables . . . More Examples . . . definecolor{Blueb}{cmyk}{.40,0,0,0} definecolor{Blued}{cmyk}{.80,0,0,0} arrayrulecolor{white} begin{tabular}{>{columncolor{Blued}}l >{columncolor{Blued}}r|% >{columncolor{Blued}}r} multicolumn{3}{>{columncolor{Blueb}}l}% {largetextbf{Table title}}[2mm] rowcolor{white} textbf{Description} & textbf{Column 1} & textbf{Column 2} [1mm] arrayrulecolor{black} rowcolor{Blueb} Row one & mmmmm & mmmm hhline{˜--} Row two & mmmm & mmm hhline{˜--} Row three & mmmmm & mmmmmhhline{˜--} Row four & mmmmm & mmmmhhline{˜--} rowcolor{white} Totals & mmmmm & mmmmm end{tabular} Title Page Page 13 of 14 Go Back Full Screen Close Quit
  • 14. Table title Description Row one Row two Row three Row four Totals Column 1 Column 2 mmmmm mmmm mmmmm mmmmm mmmmm mmmm mmm mmmmm mmmm mmmmm The colortbl . . . More colors and . . . Color tables . . . More Examples . . . definecolor{Blueb}{cmyk}{.40,0,0,0} definecolor{Blued}{cmyk}{.80,0,0,0} definecolor{Bluee}{cmyk}{1.0,0,0,0} arrayrulecolor{black} setlengtharrayrulewidth{1mm} begin{tabular}{llrrl} rowcolor{Blueb} qquad&multicolumn{3}{>{columncolor{Blueb}}l} {largetextbf{Table title}}&qquad[2mm] rowcolor{Blued}& textbf{Description} & textbf{Column 1} & textbf{Column 2}& [2mm] hline rowcolor{Blued}& Row one & mmmmm & mmmm & rowcolor{Blued}& Row two & mmmm & mmm & rowcolor{Blued}& Row three& mmmmm & mmmmm& rowcolor{Blued}& Row four & mmmmm & mmmm & cline{2-3} rowcolor{Bluee}& Totals & mmmmm & mmmmm&[2mm] end{tabular} Title Page Page 14 of 14 Go Back Full Screen Close Quit