Skip to content Skip to sidebar Skip to footer

How to Make the Refs Blue Again in Latex

Contents

  • 1 Introduction
  • 2 Named colours provided past the xcolor bundle
    • 2.1 Accessing boosted named colours
    • two.2 Instance usage
  • 3 Loading and using named colours in the color bundle
  • four Drivers and colour
    • iv.one Drivers for color and xcolor
    • 4.two Automatic colour commuter detection
    • iv.three More advanced case using the dvisvgm commuter to create an SVG file
  • 5 Creating your own colours
    • v.i xcolor-only color models
  • 6 Setting the page groundwork colour
  • 7 Further reading

Introduction

This article explains how to utilise colour in your LaTeX document via the color or xcolor packages. Notation that user-level documentation of the color bundle is contained in The LaTeX standard graphics bundle.

Both packages provide a common gear up of commands for colour manipulation, but xcolor is more flexible and supports a larger number of colour models, and then is the recommended approach.

We'll showtime with the following example:

                        \documentclass            {commodity}            \usepackage            {xcolor}            \begin            {document}            This instance shows some instances of using the            \texttt            {xcolor}            package  to alter the colour of elements in            \LaTeX.            \begin            {itemize}            \color            {blue}            \detail            Starting time item            \item            Second item            \stop            {itemize}            \noindent            {            \color            {ruddy}            \rule            {            \linewidth            }{0.5mm}}            \stop            {document}          

 Open this xcolor example in Overleaf

This instance produces the post-obit output:

Example use of xcolor package in LaTeX

In this example, the package xcolor is imported with

then the command \colour{blueish} sets the bluish color for the electric current cake of text. In this instance for the itemize environment.

The code to typeset the horizontal line created by \rule{\linewidth}{0.5mm} is contained in a group, delimited by { and }, in order to keep the effects of the \colour{ruddy} local to that grouping.

Named colours provided past the xcolor package

Every bit noted in the xcolor package documentation, the following named colours are ever available without needing to load whatever package options:

list of colours in the xcolor package

Accessing additional named colours

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

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

For case, if you write

                        \usepackage            [dvipsnames]            {xcolor}          

you lot can admission 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 instance uses named colours loaded via the dvipsnames option.

                        \documentclass            {article}            \usepackage            [dvipsnames]            {xcolor}            \begin            {document}            This instance shows how to apply the            \texttt            {xcolor}            package  to modify the colour of            \LaTeX            {}            page elements.            \begin            {catalog}            \color            {ForestGreen}            \item            Commencement item            \particular            Second item            \end            {catalog}            \noindent            {            \color            {RubineRed}            \dominion            {            \linewidth            }{0.5mm}}            The background color of text can also be            \textcolor            {red}{easily}            fix. For  instance, you tin can change utilise an            \colorbox            {BurntOrange}{orange background}            and and then continue typing.            \stop            {document}          

 Open this xcolor example in Overleaf

This instance produces the following output:

Demonstration of the xcolor package

2 new commands are too used in the instance:

  • \textcolor{ruby}{easily}: Changes the color of inline text. This control takes 2 parameters, the colour to use and the text whose colour is changed. In the example the discussion easily is printed in red
  • \colorbox{BurntOrange}{orange background}: Changes the background colour of the text passed in as the 2d argument. In the example to a higher place, the words orange background are typeset on a groundwork colour of BurntOrange.

Loading and using named colours in the color package

You can also utilize 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 bundle example.

                        \documentclass            {article}            \usepackage            [usenames,dvipsnames]            {color}            %using the color bundle, not xcolor            \brainstorm            {document}            This example shows how to use the            \texttt            {            \bfseries            colour}            package  to change the colour of            \LaTeX            {}            page elements.            \begin            {itemize}            \color            {ForestGreen}            \item            First item            \detail            Second particular            \end            {itemize}            \noindent            {            \color            {RubineRed}            \rule            {            \linewidth            }{0.5mm}}            The background colour of text tin can also be            \textcolor            {reddish}{easily}            set. For  case, yous tin change utilize an            \colorbox            {BurntOrange}{orange background}            and so go along typing.            \end            {document}          

 Open up this colour example in Overleaf

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

Demonstration of the color package

Drivers and colour

Use of color when typesetting text or math was not office of the original design of TeX; instead, apply/awarding of colour was delegated to external "drivers" which converted TeX's original output file format (DVI) into PostScript or PDF. In guild for colour to piece of work, driver-specific instructions had to exist "injected" into TeX's output by using a built-in TeX command called \special whose task 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 discover the embedded code/data and act upon it to achieve whatever the user intended—such equally the use of color.

Times take changed, and PDF is now past far the near common output format used past TeX engines, long supplanting the use of legacy DVI drivers and creation of PostScript. Users besides have a greater choice of TeX engine to use for typesetting their LaTeX documents, most notably pdfTeX, XeTeX or LuaTeX/LuaHBTeX, so it is nevertheless important to take account of differences in those TeX engines—ensuring the right mechanisms are used to insert colour data (PDF instructions) into their PDF files. To back up and accommodate the legacy DVI output format and the wider surround of TeX engines and workflows in use, you tin, if required, configure the color or xcolor packages to use a detail "driver" then that LaTeX will generate color data using using the appropriate method.

Drivers for color and xcolor

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

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

There are other options every bit described in the color parcel documentation.

The xcolor bundle 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 yous, so you don't need to specify the driver package option for those engines.

More avant-garde instance using the dvisvgm commuter 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 lawmaking:

                        \usepackage            [dvisvgm, usenames, dvipsnames]            {color}          

Specifically, the output file typeset past Overleaf is converted to SVG using a program chosen dvisvgm, which is office of TeX Live and available on our servers. To run dvisvgm, afterwards the folio is typeset, we employ a latexmkrc file which is created when you open the following code in Overleaf:

                        \documentclass            {article}            \usepackage            [dvisvgm, usenames, dvipsnames]            {color}            \title            {Creating SVG graphics}            \writer            {Overleaf}            \brainstorm            {document}            \maketitle            Hi,            {            \color            {Apricot}in Apricot}            and now in            {            \color            {DarkOrchid}            DarkOrchid}            but perhaps it might await nicer if we employ            {            \color            {JungleGreen}JungleGreen}---or may non?            \stop            {document}          

 Open this example to create an SVG file

In one case Overleaf has finished compiling y'all 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

Creating your own colours

It is possible to define your own colours, the manner in which the colour is divers depends on the preferred colour model. The following example uses 4 colour models.

                        \documentclass            {article}            \usepackage            [dvipsnames]            {xcolor}            \definecolor            {mypink1}{rgb}{0.858, 0.188, 0.478}            \definecolor            {mypink2}{RGB}{219, 48, 122}            \definecolor            {mypink3}{cmyk}{0, 0.7808, 0.4429, 0.1412}            \definecolor            {mygray}{gray}{0.6}            \brainstorm            {document}            User-divers colours with dissimilar colour models:            \brainstorm            {enumerate}            \item            \textcolor            {mypink1}{Pink with rgb}            \detail            \textcolor            {mypink2}{Pink with RGB}            \item            \textcolor            {mypink3}{Pinkish with cmyk}            \item            \textcolor            {mygray}{Gray with greyness}            \end            {enumerate}            \end            {document}          

 Open this example in Overleaf

This case produces the following output:

LaeX example creating user-defined colours

The control \definecolor takes 3 parameters: the name of the new colour, the model, and the colour definition. Roughly speaking, each number represent how much of each colour y'all add to the mix that makes up the concluding colour.

  • rgb : Red, Greenish, Blue. 3 comma-separated values between 0 and 1 define the components of the color.
  • RGB : The same as rgb, only the numbers are integers between 0 and 255.
  • cmyk : Cyan, Magenta, Yellow and black. Comma-separated listing of four numbers between 0 and 1 that determine the color co-ordinate to the subtractive CMYK model used by commercial printers.
  • gray : Greyness calibration. A unmarried number betwixt 0 and 1.

In the example, mypink1, mypink2 and mypink3 define the same colour but for dissimilar models. Yous can actually see that the one defined by cmyk is slightly unlike.

Colours divers by either model tin later be used inside your document not only to set the colour of the text, only for any other chemical element that takes a colour every bit parameter, for instance tables (you lot must add together the table option to xcolor), graphic elements created with TikZ, plots, vertical rulers in multicolumn documents and code listings.

xcolor-only color models

The xcolor package provides additional commands which provide support for more color models and friendly colour mixing, as demonstrated in the following example:

                        \documentclass            {article}            \usepackage            [dvipsnames]            {xcolor}            \colorlet            {LightRubineRed}{RubineRed!seventy}            \colorlet            {Mycolor1}{dark-green!ten!orange}            \definecolor            {Mycolor2}{HTML}{00F9DE}            \begin            {certificate}            This document presents several examples showing how to employ the            \texttt            {xcolor}            package  to modify the color of            \LaTeX            {}            page elements.            \begin            {itemize}            \detail            \textcolor            {Mycolor1}{First particular}            \item            \textcolor            {Mycolor2}{Second particular}            \end            {itemize}            \noindent            {            \color            {LightRubineRed}            \dominion            {            \linewidth            }{1mm}}            \noindent            {            \colour            {RubineRed}            \rule            {            \linewidth            }{1mm}}            \end            {document}          

 Open this instance in Overleaf

This example produces the following output:

Custom colours produced by the xcolor package

Three new colours are defined in this example, each one in a unlike style.

  • \colorlet{LightRubineRed}{RubineRed!70}: A new colour named LightRubineRed is created, this colour has 70% the intensity of the original RubineRed colour. Yous can think of it every bit a mixture of lxx% RubineRed and 30% white. Defining colours similar this lets you derive dissimilar tints of a main color—common practice in corporate branding. In the case, you can see the original RubineRed and the new LightRubineRed used in two sequent horizontal rules.
  • \colorlet{Mycolor1}{green!10!orange}: A colour named Mycolor1 is created with ten% dark-green and ninety% orange.
  • \definecolor{Mycolor2}{HTML}{00F9DE}: The color Mycolor2 is created using the HTML model. Colours in this model must be created with 6 hexadecimal digits, the characters A, B,C, D, Eastward and F must be in upper-instance.

The colour models that only xcolor supports are:

  • cmy: cyan, magenta, yellow
  • hsb: hue, saturation, brightness
  • HTML: RRGGBB
  • Greyness: Grayscale, a number betwixt 1 and 15.
  • wave: Wavelength, a number between 363 and 814. The number represents the wavelength of lite, in nanometres (nm)

Setting the page background color

The background color of the entire page can exist easily inverse with \pagecolor. The following code demonstrates this, using the text of an earlier case::

                        \documentclass            {article}            \usepackage            [dvipsnames]            {xcolor}            \colorlet            {LightRubineRed}{RubineRed!70}            \colorlet            {Mycolor1}{green!x!orange}            \definecolor            {Mycolor2}{HTML}{00F9DE}            \brainstorm            {document}            \pagecolor            {black}            \color            {white}            % prepare the default colour to white            This certificate presents several examples showing how to use the            \texttt            {xcolor}            bundle  to change the colour of            \LaTeX            {}            page elements.            \begin            {catalog}            \item            \textcolor            {Mycolor1}{First detail}            \item            \textcolor            {Mycolor2}{Second detail}            \finish            {itemize}            \noindent            {            \colour            {LightRubineRed}            \rule            {            \linewidth            }{1mm}}            \noindent            {            \colour            {RubineRed}            \rule            {            \linewidth            }{1mm}}            \finish            {document}          

 Open this example in Overleaf

This example produces the following output:

Setting the page background colour in LaTex

The command \pagecolor{blackness} set up the page colour to black. This is a switch command, significant information technology volition take event in the entire document unless some other switch command is used to revert it. \nopagecolor will change the background back to normal.

Further reading

For more information see:

  • The color package documentation
  • The xcolor bundle documentation
  • Lengths in LaTeX
  • Font sizes, families, and styles
  • Font typefaces
  • Supporting modern fonts with XeLaTeX
  • Tables
  • Inserting Images
  • Beamer
  • Powerdot
  • Posters

kellysath1968.blogspot.com

Source: https://www.overleaf.com/learn/latex/Using_colours_in_LaTeX

Post a Comment for "How to Make the Refs Blue Again in Latex"