
Using color in LaTeX
Today I want to present you another article on the graphics capabilities of the LaTeX publishing system. This time it will be about color. Most often, these features of LaTeX are ignored, since the proportion of color publications is rather small. In addition, excessive use of color can only do much harm - a motley multi-color document is difficult to read and looks unattractive. But the skillful use of color can greatly contribute to the perception of content: highlighting headings, subheadings, quotes, important parts of the text and even table cells helps to quickly catch the point, without reading the details.
So to whom it became interesting, click on the link:
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 text and background, as a separate block, and the entire document, and the second - to fill in the table. We include both packages in the preamble of the document:
All color switching commands have an option in which the color model and the required arguments in which the color is specified are indicated.
The named model is the default color model. Color is given by one of eight constants:
It resembles an eight-bit DOS palette. Here is a small example: Blue x 2 Colors named in the dvips driver. The dvips driver contains a definition of 68 color names:
Here, as we see, the possibilities are somewhat wider. The example differs little from the previous one: Orange ∪ Model rgb. In the rgb model, any color is obtained by mixing light rays of three basic colors: red (red), green (green) and blue (blue). In general, this model is not used in printing, as it is based on colored light rays (as in a picture tube, our LCD monitors, or film). For printing, the cmyk model is traditionally used , which will be discussed below. Color specification in the model rgb
is set by three numbers, separated by commas, in the range from 0 to 1, which correspond to the intensity of the basic color components. For example, yellow is specified as 1, 1, 0, white as 1, 1, 1, and 0, 0, 0 gives black.
Model gray. The gray color is obtained by mixing in equal proportions the base colors from the rgb model with an intensity of less than unity. The color specification in the gray model is specified by a single number from 0 to 1, for example 0.5 instead of 0.5, 0.5, 0.5 in the rgb model . Black corresponds to 0, white - 1.
Model cmyk.If you put red paint on a sheet of paper and then light it with white light, then only the red component of the light will be reflected from the paper. Now apply red ink to the paper with densely planted dots, and then fill all the spaces between the red dots with green paint. Now both red and green light will be reflected from a sheet of paper. It is impossible to distinguish individual points from a distance, so the eye will receive a mixture of red and green and the paper looks yellow. [ If the paint is applied not with dots, but with a solid fill, then the paint will mix and get a dirty reddish color. ]
This is where the cmyk color model is based.. In this model, the color specification is specified by four numbers, separated by commas, from 0 to 1, which correspond to the “amount” of cyan, magenta, yellow and black ink on a white sheet of paper. Specification 0, 0, 0, 0 corresponds to white color (there is no paint on a white sheet of paper), and 0, 0, 0, 1 to black.
You can change the text color in a document either by a command or by a declaration. Here model is a color model, spec is a color specification. Example: Red, red again, and red again!
The command puts, like the command , the text lr-text in a box whose background color is specified by the arguments model and spec . Here model is the color model, spec is the color specification. The team further surrounds this box with a fr-spec color frame . Example: Text ...
You can change the color of the page with a declaration. Here model is the color model, spec is the color specification. The scope of the declaration is not limited to any parentheses. To return the white color of the pages, you need to call the command .
The colortbl package , using the color and array packages , allows you to colorize tables. Colors are set as in the color package .
The command sets the color of the table column with the color specified by the first two arguments. The left-overhang and right-overhang options specify the distances left and right between the edges of the colored area and the text. If only one argument is specified, then it specifies both distances. The command colors the table row. Its place at the beginning of the line. The following examples will help you figure it out.







Well, that's all. To write the article, the book by Vladimir Syutkin “Color in LaTeX2e” was used. I hope this article is helpful to someone. Here lies the original article. Thanks.
So to whom it became interesting, 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 text and background, as a separate block, and the entire document, and the second - to fill in the table. We include 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 and the required arguments in which the color is specified are indicated.
The named model is the default color model. 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: Blue x 2 Colors named in the dvips driver. The dvips driver contains a definition of 68 color names:
\textcolor{blue}{Синий \hbox{$x^2$}}
- Greenyellow
- Yellow
- Goldenrod
- Dandelion
- Apricot
- Peach
- Melon
- Yellowrange
- Orange
- Burntrange
- 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
- Jungle green
- Seagreen
- Green
- Forestgreen
- Pinegreen
- Limegreen
- Yellowgreen
- Springgreen
- Olivegreen
- Rawiena
- Sepia
- Brown
- Tan
- Gray
- Black
- White
Here, as we see, the possibilities are somewhat wider. The example differs little from the previous one: Orange ∪ Model rgb. In the rgb model, any color is obtained by mixing light rays of three basic colors: red (red), green (green) and blue (blue). In general, this model is not used in printing, as it is based on colored light rays (as in a picture tube, our LCD monitors, or film). For printing, the cmyk model is traditionally used , which will be discussed below. Color specification in the model rgb
\textcolor{Orange}{Оранжевый $\bigcup$.}
is set by three numbers, separated by commas, in the range from 0 to 1, which correspond to the intensity of the basic color components. For example, yellow is specified as 1, 1, 0, white as 1, 1, 1, and 0, 0, 0 gives black.
Model gray. The gray color is obtained by mixing in equal proportions the base colors from the rgb model with an intensity of less than unity. The color specification in the gray model is specified by a single number from 0 to 1, for example 0.5 instead of 0.5, 0.5, 0.5 in the rgb model . Black corresponds to 0, white - 1.
Model cmyk.If you put red paint on a sheet of paper and then light it with white light, then only the red component of the light will be reflected from the paper. Now apply red ink to the paper with densely planted dots, and then fill all the spaces between the red dots with green paint. Now both red and green light will be reflected from a sheet of paper. It is impossible to distinguish individual points from a distance, so the eye will receive a mixture of red and green and the paper looks yellow. [ If the paint is applied not with dots, but with a solid fill, then the paint will mix and get a dirty reddish color. ]
This is where the cmyk color model is based.. In this model, the color specification is specified by four numbers, separated by commas, from 0 to 1, which correspond to the “amount” of cyan, magenta, yellow and black ink on a white sheet of paper. Specification 0, 0, 0, 0 corresponds to white color (there is no paint on a white sheet of paper), and 0, 0, 0, 1 to black.
Color text
You can change the text color in a document either by a command or by a declaration. Here model is a color model, spec is a color specification. Example: Red, red again, and red again!
\textcolor[model]{spec}{text}
{\color[model]{spec}text}
\textcolor{red}{Красный,} \textcolor[cmyk]{0,1,1,0}{опять красный,}
\textcolor[rgb]{1,0,0}{и ещё раз красный!}
Color boxes
The command puts, like the command , the text lr-text in a box whose background color is specified by the arguments model and spec . Here model is the color model, spec is the color specification. The team further surrounds this box with a fr-spec color frame . Example: Text ...
\colorbox[model]{spec}{lr-text}
\mbox
\fcolorbox[model]{fr-spec}{spec}{lr-text}
\fcolorbox{red}{yellow}{Текст\dots}
Color Page Background
You can change the color of the page with a declaration. Here model is the color model, spec is the color specification. The scope of the declaration is not limited to any parentheses. To return the white color of the pages, you need to call the command .
\pagecolor[model]{spec}
\pagecolor{white}
Color tables
The colortbl package , using the color and array packages , allows you to colorize tables. Colors are set as in the color package .
The command sets the color of the table column with the color specified by the first two arguments. The left-overhang and right-overhang options specify the distances left and right between the edges of the colored area and the text. If only one argument is specified, then it specifies both distances. The command colors the table row. Its place at the beginning of the line. The following examples will help you figure it out.
\columncolor[model]{spec}[left-overhang][right-overhang]
\rowcolor[model]{spec}[left-overhang][right-overhang]
\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. To write the article, the book by Vladimir Syutkin “Color in LaTeX2e” was used. I hope this article is helpful to someone. Here lies the original article. Thanks.