LaTeX fonts: 73 PDF and JPG samples

I had a friend ask me to find an alternative font for him to use in LaTeX. I first tried to trawl Google, but only found dated and incomplete pages, so I decided to sample a ton of fonts so he could choose for himself. My friend was running Ubuntu Linux which uses TeX Live and Ubuntu comes with two texlive-fonts packages in the repositories: texlive-fonts-extra and texlive-fonts-recommended. So the first thing I did was to create lists of the fonts in these packages:

aptitude show texlive-fonts-extra | grep " -- " | awk '{print $1}' > texlive-fonts-extra
aptitude show texlive-fonts-recommended | grep " -- " | awk '{print $1}' > texlive-fonts-recommended.txt

This provided 121 fonts for texlive-fonts-extra and 24 for texlive-fonts-recommended.

Automating the font sampling
To automate the font sampling I made a template LaTeX document, where I used the standard dummy text of typesetting: Lorem Ipsum and small equation to see math font in use. The LaTeX template is slightly shortened compared to the version in the downloads.

\section*{Lorem ipsum dolor sit amet}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna orci,
commodo eget sollicitudin id, commodo vitae erat. Pellentesque eu dapibus arcu.
Cras tristique, lectus at porta porttitor, enim tellus pulvinar turpis,
pulvinar fringilla elit erat sed sem. Suspendisse elit velit, iaculis id
adipiscing in, convallis et lectus. 
{\left( \frac{\partial}{\partial x}{\left(\frac{\partial g\left(x,y\right)}{\partial y}\right)}_x \right)}_y = 
{\left(\frac{\partial}{\partial y}{\left(\frac{\partial g\left(x,y\right)}{\partial x}\right)}_y \right)}_x
\section*{Nullam ac gravida ante}
Nullam ac gravida ante. Ut consequat, arcu vel sodales pharetra, ante nibh
rhoncus justo, pulvinar gravida lorem nunc ut augue. Nullam nec diam libero,
eget aliquam augue. 

Now to the script to automate it all. First the script replaces %placeholder with \usepackage{fontname}, then document is compiled using pdflatex, the pdf is convert to a image using ImageMagick and finally a bit of cleaning. The script reads the list of fonts to use from the file texlive-working-fonts.txt which contains the 73 fonts compiled flawlessly in the two lists compiled earlier. texlive-working-fonts.txt is included in the downloads below.

# Times like fonts 
#fonts="times mathptmx pslatex newcent palatino lmodern"
if [ ! -d PDFS ]; then
    mkdir PDFS
if [ ! -d JPGS ]; then
    mkdir JPGS
for font in $(cat texlive-working-fonts.txt); do
    if [ ! -e PDFS/font-$font.pdf ]; then
        echo "### Creating $font"
        if [ $font = "standardlatex" ]; then
            sed "s/%placeholder//g" document.tex > font-$font.tex
            sed "s/%placeholder/\\\usepackage\{$font\}/g" document.tex > font-$font.tex
    	pdflatex font-$font.tex
        convert font-$font.pdf font-$font.jpg
        mv font-$font.pdf PDFS/
        mv font-$font.jpg JPGS/
        rm -f font-$font.tex font-$font.log font-$font.aux
        echo "### PDF for font: $font already exist"

Running the script return two folders: a folder containing PDF’s of all the 73 fonts and a folder called JPGS containing all the JPG’s. Below is a sample of 6 of the fonts – the full monty can be found in the downloads.

A minimal download containg only the bash-script, the template LaTex document and the lists of fonts: (3 kB)
latex-font-test.tar.gz (2.2 kB)

A full download all files along with PDF and JPEG versions of document using 73 different fonts. (8.1 MB)
latex-font-test-with-pdfs-and-jpgs.tar.gz (8.2 MB)

This entry was posted in Articles, Computer. Bookmark the permalink.

3 Responses to LaTeX fonts: 73 PDF and JPG samples

  1. grateful passer-by says:

    cheers, very helpful!

  2. vorebro says:

    This was a great idea! Thanks for sharing the script and the output.

    However, I notice that a lot of the fonts actually look the same. Several fonts need more than just \usepackage{fontname}. For example, to see the result of Inconsolata, you would need to add \renewcommand*\familydefault{\ttdefault} or add some \textt text, and to see Trajan, you need to add \trjnfamily and have a sequence of upper-case letters.

    I’ll see if I can add to your script to see the output of more fonts.

  3. vorebro says:

    Or actually, I just realized that the LaTeX font catalogue at has most of the info we need.

Leave a Reply