How to build and customise ModernCV on Ubuntu 23.04
Published: 2023-08-15 11:25:07

_Originally published [on my blog](https://robinwinslow.uk/moderncv)._

[ModernCV](https://github.com/moderncv) is a customisable LaTeX CV template for creating your résumé.

![ModernCV and Cover Letter Template](https://writelatex.s3.amazonaws.com/published_ver/26392.jpeg?X-Amz-Expires=14400&X-Amz-Date=20230815T110239Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAWJBOALPNFPV7PVH5/20230815/us-east-1/s3/aws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=56535697d39c813a3cea934c56bcfd9f183db74ff170817e8deb4ad71039668b)

You can edit it directly and for free [on Overleaf](https://www.overleaf.com/latex/templates/moderncv-and-cover-letter-template/sttkgjcysttn), but the version on there is not as customisable as the full source code. So here I'm going to write down how to download, build and customise the original source code on Ubuntu, as I do it.

## Prerequisites

First, install LaTeX on Ubuntu:

``` bash
sudo apt update
sudo apt install -y latexmk texlive-latex-extra texlive-fonts-extra git
```

The pages we're installing are:

- [LatexMK](https://mg.readthedocs.io/latexmk.html): A smart compiler for LaTeX documents. It wraps and makes use of [pdflatex](https://www.math.rug.nl/~trentelman/jacob/pdflatex/pdflatex.html). It's better than using pdflatex yourself because it will manage any recompiltions and further steps automatically.
- [texlive-latex-extra](https://packages.debian.org/sid/texlive-latex-extra): This contains the etoolbox package, which is needed for most things including ModernCV.
- [texlive-fonts-extra](https://packages.debian.org/sid/texlive-fonts-extra): This contains [fontawesome5](https://ctan.org/pkg/fontawesome5?lang=en), used by ModernCV.
- [Git](https://github.com/git-guides/install-git): You need this to clone ModernCV, if you don't have it.

## Build the template ModernCV

Now clone the ModernCV project and build the template CV to check it's working:

``` bash
git clone https://github.com/moderncv/moderncv  # Get the code
cv moderncv  # Enter the project
latexmk -pdf ./template.tex  # Build the template
```

If it succeeded, you should see something like this at the bottom of the output:

```
Output written on template.pdf (6 pages, 351459 bytes).
Transcript written on template.log.
Latexmk: Getting log file 'template.log'
Latexmk: Examining 'template.fls'
Latexmk: Examining 'template.log'
Latexmk: Found input bbl file 'template.bbl'
Latexmk: Log file says output to 'template.pdf'
Latexmk: Found bibliography file(s):
  ./publications.bib
Latexmk: All targets () are up-to-date
```

And if you open up `template.pdf` you should now see an example CV for "John Doe".

If you get errors in compiling the PDF, firstly try running it again, or try deleting the directory, cloning it again, and then running if again. If that fails, try copying any error messages into Google to see if you can discover if you can fix the error by installing more `texlive` packages. It's possible installing [textlive-full](https://packages.debian.org/buster/texlive-full) may help.

## Customise the CV

To customise the CV for your own purposes, you should first copy `template.tex` to make your own `.tex` file for your CV, and then open that file and start editing it.

``` bash
cp template.tex yourname.tex  # Make a copy
code yourname.tex  # I like to use VSCode for editing, but you do you
```

The file has liberal comments to explain to you how to make changes to it. You may want to change the settings at the top of the file for the font size, font style, margins, colour etc.

```latex
\documentclass[11pt,a4paper,sans]{moderncv}        % possible options include font size ('10pt', '11pt' and '12pt'), paper size ('a4paper', 'letterpaper', 'a5paper', 'legalpaper', 'executivepaper' and 'landscape') and font family ('sans' and 'roman')

% moderncv themes
\moderncvstyle{classic}                            % style options are 'casual' (default), 'classic', 'banking', 'oldstyle' and 'fancy'
\moderncvcolor{blue}                               % color options 'black', 'blue' (default), 'burgundy', 'green', 'grey', 'orange', 'purple' and 'red'
%\renewcommand{\familydefault}{\sfdefault}         % to set the default font; use '\sfdefault' for the default sans serif font, '\rmdefault' for the default roman one, or any tex font name
%\nopagenumbers{}                                  % uncomment to suppress automatic page numbering for CVs longer than one page

% adjust the page margins
\usepackage[scale=0.75]{geometry}
\setlength{\footskip}{149.60005pt}                 % depending on the amount of information in the footer, you need to change this value. comment this line out and set it to the size given in the warning
%\setlength{\hintscolumnwidth}{3cm}                % if you want to change the width of the column with the dates
%\setlength{\makecvheadnamewidth}{10cm}            % for the 'classic' style, if you want to force the width allocated to your name and avoid line breaks. be careful though, the length is normally calculated to avoid any overlap with your personal info; use this at your own typographical risks...
```

Then the first thing you should probably do after that is go down to where it says "John Doe" and change it to your name:

``` latex
\name{John}{Doe}
```

Once you've made a couple of changes, try building and opening your CV:

``` bash
latexmk -pdf ./robinwinslowmorris.tex
xdg-open robinwinslowmorris.pdf
```

I'm not going to explain all of how to edit the `.tex` file, as it's mostly explained inline. You can also learn more about LaTeX format [on Overleaf](https://www.overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes) or [on freecodecamp.org](https://www.freecodecamp.org/news/learn-latex-full-course/).