Today I want to present you another article on the graphic features of the publishing system LaTeX. This time it will be about color. Most often, these features of LaTeX are ignored, since the proportion of color publications is quite small. In addition, the excessive use of color can only harm - a variegated multi-color document is difficult to read and it looks unattractive. But skillful use of color can greatly contribute to the perception of content: highlighting headlines, subtitles, quotations, important parts of the text, and even table cells helps to quickly grasp the essence, without getting into details.
So who was interested, click on the link:
Color in LaTeX
Two packages from the
graphics collection:
color and
colortbl allow working with color in the LaTeX system. The first allows you to set the color of the text and background, as a separate block, and the entire document, and the second - to paint the table. Let's connect both packages in the preamble of the document:
\ usepackage [usenames]{color}
\ usepackage {colortbl}
All color switching commands have an option in which the color model is specified and the required arguments in which the color is specified.
The named model is the default color model. The color is given by one of eight constants:
- black
- red
- blue
- magenta
- white
- green
- cyan
- yellow
It resembles an eight-bit DOS palette. Here is a small example:
\ textcolor {blue}{ \ hbox {$x^2$}}
Blue x
2Colors named in the dvips driver. The
dvips driver contains the definition of 68 color names:
- Greenyellow
- Yellow
- Goldenrod
- Dandelion
- Apricot
- Peach
- Melon
- Yellowrange
- Orange
- Burntorange
- Bittersweet
- Redrange
- Mahogany
- Maroon
- Brickred
- Red
- Orangered
- Rubinered
- Wildstrawberry
- Salmon
- CarnationPink
- Magenta
- Violetred
- Rhodamine
- Mulberry
- Redviolet
- Fuchsia
- Lavender
- Thistle
- Orchid
- DarkOrchid
- Purple
- Plum
- Violet
- RoyalPurple
- Blueviolet
- Periwinkle
- Cadetblue
- Cornflowerblue
- Midnightblue
- Navyblue
- RoyalBlue
- Blue
- Cerulean
- Cyan
- ProcessBlue
- Skyblue
- Turquoise
- Tealblue
- Aquamarine
- Bluegreen
- Emerald
- Junglegreen
- Seagreen
- Green
- Forestgreen
- Pinegreen
- Limegreen
- Yellowgreen
- Springgreen
- Olivegreen
- Rawsienna
- Sepia
- Brown
- Tan
- Gray
- Black
- White
Here, as we see, the possibilities are somewhat broader. The example is a little different from the previous one:
\ textcolor {Orange}{ $\ bigcup $.}
Orange ∪
')
Model rgb. In the
rgb model, any color is obtained by mixing the light rays of the three basic colors: red (red), green (green) and blue (blue). In general, this model is not used in printing, as it is based on the colored rays of light (as in a kinescope, our LCD monitors or on photographic film). For printing traditionally used model
cmyk , which will be discussed below.
The color specification in the
rgb model is given by the three comma-separated numbers in the range from 0 to 1, which correspond to the intensity of the basic color components. For example, yellow color is specified as 1, 1, 0, white color - as 1, 1, 1, and 0, 0, 0 - gives black color.
Model gray. Gray color is obtained by mixing in equal proportions of the base colors from the
rgb model with an intensity of less than unity. The specification of a color in the
gray model is set with one number from 0 to 1, for example 0.5 instead of 0.5, 0.5, 0.5 in the model
rgb . Black color corresponds to 0, white color - 1.
Cmyk model If red paper is applied to a sheet of paper and then illuminated with white light, then only the red component of the light will be reflected from the paper. Now we apply red ink on the paper with densely planted dots, and then fill all the spaces between the red dots with green ink. Now both red and green light will be reflected from the sheet of paper. Individual points cannot be distinguished from a distance, so the eye will receive a mixture of red and green and the paper will look yellow. [
If the paint is applied not with dots, but with a solid fill, then the paint will mix and you will get a dirty reddish color. ]
The
cmyk color model is based on this. In this model, the color specification is given by the four comma-separated numbers from 0 to 1, which correspond to the “amount” of cyan, magenta, yellow and black paint on a white sheet of paper. White color corresponds to the specification 0, 0, 0, 0 (there is no paint on the white sheet of paper), and black - 0, 0, 0, 1.
Color text
You can change the text color in the document either with the command
\ textcolor [model]{spec}{text}
either by declaration
{\ color [model]{spec}text}
Here
model is a color model,
spec is a color specification.
Example:
\ textcolor {red}{,} \ textcolor [cmyk]{0,1,1,0}{ ,}
\ textcolor [rgb]{1,0,0}{ !}
Red, red again, and red again!
Colored boxes
Team
\ colorbox [model]{spec}{lr-text}
puts, like the
\ mbox
command, the text
lr-text into a box whose background color is given by the
model and
spec arguments. Here
model is a color model,
spec is a color specification. Team
\ fcolorbox [model]{fr-spec}{spec}{lr-text}
additionally surrounds this box with a
fr-spec color frame. Example:
\ fcolorbox {red}{yellow}{\ dots }
Text...
Colored background page
You can change the page color by a declaration.
\ pagecolor [model]{spec}
Here
model is a color model,
spec is a color specification. The scope of the declaration is not limited to any brackets. To return the white color of the pages, you must call the command
\ pagecolor {white}
.
Color tables
The
colortbl package, using the
color and
array packages, allows you to color the tables. Colors are set the same as in the
color package.
Team
\ columncolor [model]{spec}[left-overhang][right-overhang]
sets the color of the table column with the color given by the first two arguments. The
left-overhang and
right-overhang options set the left and right distances between the edges of the colored area and the text. If only one argument is given, then it sets both distances.
Team
\ rowcolor [model]{spec}[left-overhang][right-overhang]
colors the table row. Her place at the beginning of the line.
The following examples will help you figure it out.
\ begin {tabular}{%
|>{\ color {white}\ columncolor {black}}l|
>{\ columncolor {yellow}[.6\ tabcolsep ]}c|
>{\ columncolor [gray]{.8}}r|}
& & \\ & &
\ end {tabular}

\ begin {tabular}{|l|c|}
\ rowcolor [gray]{.9} & \\
\ rowcolor [gray]{.6} &
\ end {tabular}

\ newcolumntype {H}{>{\ columncolor {magenta}}c}
\ begin {tabular}{%
|>{\ columncolor {yellow}}l|
>{\ color {white}\ columncolor {black}}l|}
\ multicolumn {2}{|H|}{} \\
& \\ &
\ end {tabular}

\ def \ tabrowsep {\ noalign {\ vskip 2pt}}
\ newcolumntype {H}{%
>{\ columncolor [gray]{.9}}p{1.7cm}}
\ begin {tabular}[t]{*2H}
\ rowcolor [gray]{.6} & \\\ tabrowsep & \\\ tabrowsep
&
\ end {tabular}

\ setlength \ arrayrulewidth {2pt}\ arrayrulecolor {blue}
\ setlength \ doublerulesep {2pt}\ doublerulesepcolor {yellow}
\ begin {tabular}{||l||c||}
\ hline \ hline
& \\ & \\
\ hline \ hline
\ end {tabular}

\ begin {tabular}{||l|c||}
\ hhline {|t:=:t:=:t|}
& \\ & \\
\ hhline {|b:=:b:=:b|}
\ end {tabular}

\ newcommand \ rgbline [1]{\ hhline {>{\ arrayrulecolor {red}}|#1:=%
>{\ arrayrulecolor {green}}=>{\ arrayrulecolor {blue}}=:#1|}}
\ arrayrulecolor {red}
\ begin {tabular}{||*3c||}\ rgbline {t}
red & green & \ multicolumn {1}{c||}{blue}\\
\ rgbline {b}\ end {tabular}

Well, that's all. For writing the article, the book by Vladimir Syutkin “Color in LaTeX2e” was used. I hope someone will be useful this article.
Here lies the original article. Thank.