Color and underline text in LaTeX

For a particular project, I had a requirement that the text be coloured as well as underlined. Now making text underlined in LaTeX has a default support in the form of \underline{text}, which simply produces an underlined text.

But what if you want to customise the underlining, for example, change the thickness of the underline, or its distance from the text baseline. Or simply you might want to have a different colour for the underline. There are several packages which allow you to customise this exact requirement.

For the present post I will choose the soul package which has some other goodies for typesetting as well. You can load the package with \usepackage{soul} Along with underlining, you have have strikeout and highlight. To setup the underline, soul package gives three options, underline depth, underline thickness and underline colour (page 12-13 of the package documentation).

You can set this in the preamble

\setul{⟨underline depth⟩}{⟨underline thickness⟩}

It is recommended that the units of these lengths are in ex, so that they are relative to the font size. For example,


To use it in the document \ul{underlined text} will produce

Another option is to set the colour of the underline. This can be done with


With this option, the above code will look like

The color option can be changed anywhere in the document, so you can have change of colours as required. Defining in the preamble has a universal effect.

So far so good. Now in this case I wanted the underlined text to be of different colour. For this one can define a newcommand with text colour option.


I am also using the svgnames option from the xcolor package for calling colours by names.


In the main text, you can use it as \ublue{coloured and underlined text} to produce the required result. Will produce 



Lists with LaTeX

While writing documents one needs lists. Usually the lists are either numbered or with bullet. The standard enumerate option in LaTeX by default provides Arabic-Hindu numbers for the list.

The standard syntax is as under:

\item First item
\item Second item

This will produce a list with Arabic-Hindu numbers with the items at each head.

In case one wanted a list with bullets, we can use the itemize environment.

\item First item
\item Second item

This will produce a list with with bullets
There is yet another environment description which can take user supplied options for list headings.
For example:

\item[First] First item
\item[Second] Second item

In this case the descriptors in square brackets after the \item will be used as the item titles. So when I required any alphabetical list, I used to make list in the description environment and put the alphabets/ descriptors manually.

So far so good.

Recently I had to make a list with Roman numerals instead of Arabic ones. The list was fairly long so manual option seemed to be a very un-LaTeX kind of thing to do. Just a little googling and I found a treasury of options that can be used with the standard enumerate environment. This was the enumitem package.

The package provides various options for the enumerate environment like label and its formatting, style, alignment,  indent, vertical and horizontal spacing etc.

The label options that are available are \alph, \Alph, \arabic, \roman and \Roman,
These can be intialised by using


After this the regular \item will produce list with alphabets, numbers or roman numerals.

Please see the documentation for more details.

Suppose you have a list which is split in many parts. You can use resume function to continue with numbering left off in the last part of the list. The resume function can be named and you can have different lists to resume.