Рубрики

purple

What color mixture makes purple

then the command color sets the blue colour for the current block of text. In this case for the itemize environment.


background-color

The background-color CSS property sets the background color of an element.

/* Keyword values */ background-color: red; background-color: indigo; /* Hexadecimal value */ background-color: #bbff00; /* Fully opaque */ background-color: #bf0; /* Fully opaque shorthand */ background-color: #11ffee00; /* Fully transparent */ background-color: #1fe0; /* Fully transparent shorthand */ background-color: #11ffeeff; /* Fully opaque */ background-color: #1fef; /* Fully opaque shorthand */ /* RGB value */ background-color: rgb(255 255 128); /* Fully opaque */ background-color: rgb(117 190 218 / 0.5); /* 50% transparent */ /* HSL value */ background-color: hsl(50 33% 25%); /* Fully opaque */ background-color: hsl(50 33% 25% / 0.75); /* 75% opaque, i.e. 25% transparent */ /* Special keyword values */ background-color: currentcolor; background-color: transparent; /* Global values */ background-color: inherit; background-color: initial; background-color: revert; background-color: revert-layer; background-color: unset; 

The background-color property is specified as a single value.

Values

The uniform color of the background. It is rendered behind any background-image that is specified, although the color will still be visible through any transparency in the image.

Accessibility concerns

It is important to ensure that the contrast ratio between the background color and the color of the text placed over it is high enough that people experiencing low vision conditions will be able to read the content of the page.

Color contrast ratio is determined by comparing the luminance of the text and background color values. In order to meet current Web Content Accessibility Guidelines (WCAG), a ratio of 4.5:1 is required for text content and 3:1 for larger text such as headings. Large text is defined as 18.66px and bold or larger, or 24px or larger.

  • WebAIM: Color Contrast Checker
  • MDN Understanding WCAG, Guideline 1.4 explanations
  • Understanding Success Criterion 1.4.3 | W3C Understanding WCAG 2.0


Formal definition

Initial value transparent
Applies to all elements. It also applies to ::first-letter and ::first-line .
Inherited no
Computed value computed color
Animation type a color

background-color =


Named colours provided by the xcolor package

As noted in the xcolor package documentation, the following named colours are always available without needing to load any package options:

list of colours in the xcolor package

Accessing additional named colours

Additional named colours can be accessed via the following xcolor package options:

  • dvipsnames : loads 68 named colours (CMYK)
  • svgnames : loads 151 named colours (RGB)
  • x11names : loads 317 named colours (RGB)

For example, if you write

usepackage[dvipsnames]xcolor> 

you can access the following named colours:

colours loaded by dvipsnames option of xcolor package

Refer to the xcolor package documentation for tabulated lists of colours provided by the svgnames and x11names options.

Example usage

The following example uses named colours loaded via the dvipsnames option.

documentclassarticle> usepackage[dvipsnames]xcolor> begindocument> This example shows how to use the textttxcolor> package to change the colour of LaTeX<> page elements. beginitemize> colorForestGreen> item First item item Second item enditemize> noindent colorRubineRed> rulelinewidth>0.5mm>> The background colour of text can also be textcolorred>easily> set. For instance, you can change use an colorboxBurntOrange>orange background> and then continue typing. enddocument> 

This example produces the following output:

Demonstration of the xcolor package

Two new commands are also used in the example:

  • textcolor: Changes the colour of inline text. This command takes two parameters, the colour to use and the text whose colour is changed. In the example the word easily is printed in red
  • colorbox: Changes the background colour of the text passed in as the second argument. In the example above, the words orange background are typeset on a background colour of BurntOrange .

Loading and using named colours in the color package

You can also use the color package and load named colours via its usenames and dvipsnames package options:

usepackage[usenames,dvipsnames]color> 

The following code uses the color package to apply the same named colours used in the previous xcolor package example.

documentclassarticle> usepackage[usenames,dvipsnames]color> %using the color package, not xcolor begindocument> This example shows how to use the textttbfseries color> package to change the colour of LaTeX<> page elements. beginitemize> colorForestGreen> item First item item Second item enditemize> noindent colorRubineRed> rulelinewidth>0.5mm>> The background colour of text can also be textcolorred>easily> set. For instance, you can change use an colorboxBurntOrange>orange background> and then continue typing. enddocument> 

This example produces the same output as the previous xcolor version:

Demonstration of the color package

Drivers and colour

Use of colour when typesetting text or math was not part of the original design of TeX; instead, use/application of colour was delegated to external “drivers” which converted TeX’s original output file format (DVI) into PostScript or PDF. In order for colour to work, driver-specific instructions had to be “injected” into TeX’s output by using a built-in TeX command called special whose job is simply to allow code/data to pass through the typesetting process and become embedded into the output file. When the chosen driver (software) processed the typeset output it would detect the embedded code/data and act upon it to achieve whatever the user intended—such as the use of colour.

Times have changed, and PDF is now by far the most common output format used by TeX engines, long supplanting the use of legacy DVI drivers and creation of PostScript. Users also have a greater choice of TeX engine to use for typesetting their LaTeX documents, most notably pdfTeX, XeTeX or LuaTeX/LuaHBTeX, so it is still important to take account of differences in those TeX engines—ensuring the correct mechanisms are used to insert colour data (PDF instructions) into their PDF files. To support and accommodate the legacy DVI output format and the wider environment of TeX engines and workflows in use, you can, if required, configure the color or xcolor packages to use a particular “driver” so that LaTeX will generate colour data using using the appropriate method.

Drivers for color and xcolor

The color package provides out-of-the-box support for the following driver options:

  • dvipdfmx , dvips , dvisvgm , luatex , pdftex and xetex

There are other options as described in the color package documentation.

The xcolor package provides the following driver options:

  • dvips , xdvi , dvipdf , dvipdfm , dvipdfmx , luatex , pdftex , dvipsone , dviwindo , emtex , dviwin , oztex , textures , pctexps , pctexwin , pctexhp , pctex32 , truetex , tcidvi , vtex and xetex .

Automatic colour driver detection

When typesetting your document LaTeX reads a configuration file called color.cfg which contains code that can determine if you are running pdfTeX, XeTeX or LuaTeX and automatically loads the appropriate driver ( .def file) for you, so you don’t need to specify the driver package option for those engines.

More advanced example using the dvisvgm driver to create an SVG file

The following example uses the color package with options that load named colours and the dvisvgm driver to output colour definitions/data using SVG code:

usepackage[dvisvgm, usenames, dvipsnames]color> 

Specifically, the output file typeset by Overleaf is converted to SVG using a program called dvisvgm , which is part of TeX Live and available on our servers. To run dvisvgm , after the page is typeset, we use a latexmkrc file which is created when you open the following code in Overleaf:

documentclassarticle> usepackage[dvisvgm, usenames, dvipsnames]color> titleCreating SVG graphics> authorOverleaf> begindocument> maketitle Hello, colorApricot>in Apricot> and now in colorDarkOrchid> DarkOrchid> but perhaps it might look nicer if we use colorJungleGreen>JungleGreen>---or may not? enddocument> 

Once Overleaf has finished compiling you can access the SVG graphic, called mygraphic.svg , by selecting Logs and outputs and choosing the Other logs and files dropdown list:

Accessing a generated file on Overleaf

Colin Wynn
the authorColin Wynn

Leave a Reply