Defining and Using Colours

If you have corporate colours, you will need to use these colours in your documentation, perhaps on the title page or in the headers or footers.

It is best to define these colours in the stylesheet. Several commands are provided for this.

color Package

First, you need to add colour packages. The basic colour package is added using the following command.


xcolor Package

With the xcolor package you can define custom colours using one of the colour models such as gray, rgb, cmyk, and so on.


usenames is one of the 16 predefined colours in LaTeX. These are:

     black, blue, brown, cyan, darkgray,
     gray, green, lightgray, lime, magenta,
     olive, orange, pink, purple, red,
     teal, violet, white, yellow.

dvipsnames loads a set of predefined colours.

svgnames loads a set of predefined colours based on SVG definitions.

table loads a predefined set of colours for use in table rows, columns and cells.

I used the xcolour package as I wanted to define colours based on corporate branding.

Defining Custom Colours

To provide for a set of predefined colours that can be used throughout the document, use the /definecolor command with the colour type and settings as arguments. This requires that you use the xcolor package discussed above.

The simplest means of defining a colour is using the following:

\definecolor{name}{colour model}{specification}

Here are some examples using rgb and cmyk colour models:


The xcolor package provides many more options. I found that I only needed to use the rgb model, give the new colour a name and define its rgb values.

Defining Colours for Boilerplate Elements

Here are five colours that I defined within the stylesheet for using on the title page, headers and footers, and other elements. They use the rgb colour model:

% Blue for title page and other elements
% Orange for headers, footers and headings
% Gray for use as required.
\definecolor{gray}{rgb}{0.4, 0.0, 0.4}
% background color for code boxes
\definecolor{codeBackground}{RGB}{251, 251, 244}
% White for use as required.

Defining Colours for Information Boxes

You can define background colour settings and line colour settings for information boxes used in the document. For example:

% Background colour for Warning Box:
% Background colour for Note Box:
% Background colour for Information Box:
% Line Color for Information Box:
% Line Color for Note Box:
% Two Line Colors for Warning Boxes:

Using Colour Definitions

Once you have defined a colour, you can using it within other styles or commands in the stylesheet.

For example, I defined an orange colour as followS for the title page:


It has a rather odd name called namecolor. I then referenced this colour in the style for chapter titles.


If I want to change the colour of chapter titles, I need only change the definition of namecolor.

I will discuss the heading definitions in a later topic.