Use Fontawesome with pdfLatex

Using Fontawesome in Documents

Fontawesome offers more than 600 scalable vector icons which can be used via CSS. The same icon kit is also available for being used in Latex. Since recently, the package was only available for Xelatex and LuaTex, but it is now also available for pdfLatex. The installation is a bit tricky, which I would like to share with you how I managed to install the font for Latex.

Get Hold of the Package

You can download the package from CTAN and store it locally on your drive. Alternatively you can also use wget:

wget http://mirrors.ctan.org/fonts/fontawesome.zip

Obey the Structure!

The TexLive system utilises a special directory structure for finding the packages and their content. The package we obtained from CTAN does currently not comply with the given structure, which is why the installation procedure differs a little bit from the norm. You should know that TexLive utilises several repositories for storing packages. A global one in the directory /usr/local/share/texmf  and a local one in the home directory, usually ~/texmf . You can print the directory that TexLive is using withthe following command:

psewhich -var-value=TEXMFHOME

We will install fontawesome in the user’s directory as this does not require root privileges. Upon googling for a little while, I found this helpful post, which describes how to copy the needed tiles to their  appropriate location. First, we create the directory structure in the local TexLive repository of the user.

mkdir -p ~/texmf/
mkdir -p ~/texmf/doc/fonts/fontawesome/
mkdir -p ~/texmf/fonts/enc/dvips/fontawesome/
mkdir -p ~/texmf/fonts/map/dvips/fontawesome/
mkdir -p ~/texmf/fonts/opentype/public/fontawesome/
mkdir -p ~/texmf/fonts/tfm/public/fontawesome/
mkdir -p ~/texmf/fonts/type1/public/fontawesome/
mkdir -p ~/texmf/tex/latex/fontawesome/

In the second step, unzip the package file and copy the content into the directory structure:

unzip fontawesome.zip
cd fontawesome
mv README.md ~/texmf/doc/fonts/fontawesome/
mv doc/* ~/texmf/doc/fonts/fontawesome/
mv enc/* ~/texmf/fonts/enc/dvips/fontawesome/
mv map/* ~/texmf/fonts/map/dvips/fontawesome/
mv opentype/* ~/texmf/fonts/opentype/public/fontawesome/
mv tfm/* ~/texmf/fonts/tfm/public/fontawesome/
mv type1/* ~/texmf/fonts/type1/public/fontawesome/
mv tex/* ~/texmf/tex/latex/fontawesome/

Now everything is in the right place. Following the blog post I linked above unfortunately leads to an error, that the map file cannot be found. What was missing in the original post is that you need to provide the name of the map file, such that the update tool can actually find it. Reading the linked documentation actually helped and I found the trick. We need to create a directory called web2c in the ~/texmf directory and create a file called updmap.cfg. This file needs to point to the map file of Fontawesome and we are all set:

user:~/texmf$ cat web2c/updmap.cfg 
Map fontawesome.map

Install the new Font

Then we can proceed as described and update the package manager of TexLive and install the font like this:

texhash ~/texmf 
updmap
kpsewhich fontawesome.map

Try it!

This minimal example shows how to test and use the Fontawesome package.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fontawesome}

\title{Using Fontawesome in Latex  \faThumbsUp}
\author{Stefan}

\begin{document}

\maketitle
\section{Why Fontawesome?}
Using fontawesome allows creating iconic texts. Also there are a lot of social media icons available,
 such as \faFacebook, \faTwitter or \faLinkedin. And there is no need 
for Windings\footnote{https://en.wikipedia.org/wiki/Wingdings} anymore for creating awesome picture stories.
\section{Wordpress}
\begin{tiny} \faWordpress \end{tiny}
\begin{small} \faWordpress \end{small}
\begin{normalsize} \faWordpress \end{normalsize}
\begin{LARGE} \faWordpress \end{LARGE} 
\begin{Huge} \faWordpress \end{Huge}
\end{document}

The final result looks like this. Isn’t it beautiful?

Fontawesome Example

Continue reading


Tracking Changes in Latex – The Easy Way

Latex has many advantages in comparison to WYSIWYG word processors such as Microsoft Word or Libre Office. Being a text based markup language, Latex allows distraction free writing in a large selection of editors, it scales easily also for large projects with hundreds or thousands of references and images within the text and it produces very clean layouts, which can be exchanged simply by using different document classes. If you use a version control system such as git or svn, also versioning becomes very convenient, every change can be seen in the text file as a simple diff.

Although I am a big fan of latex, there are some things where other processors such as Word do have their advantages as well. Tracking changes is such an advantage, which is solved very nicely and intuitively. Source code management tools such as git and svn can produce a diff of the file and highlight changes, but the changes are not rendered in the document. Tracing changes in a Latex source file is not comfortable, especially if people should be able to see where changes have been made in  a document, who are not familiar with the Latex source.

Installing latexdiff

The Perl tool latexdiff provides this missing feature and creates a Latex file as output, which contains the changes made between two revisions of a file. In addition the changes are highlighted in a similar fashion as in graphical text processors. Install the tool with the following apt command:

sudo apt-get install latexdiff

This provides the following tools for various source code management systems, as indicated by the suffix.

latexdiff latexdiff-cvs latexdiff-fast latexdiff-git latexdiff-rcs latexdiff-svn latexdiff-vc

Tracing Changes

After installing the software package, you can start comparing different revisions of the same file. Simply use the following command to highlight changes between two files. Note that this command creates a new Latex document as output, which you then need to compile in order to have a readable PDF with the changes.

# Generate diff with tracked changes
latexdiff Document_Version1.tex Document_Version2.tex > Document_Changes_V1_v2.tex
# Compile the Latex document
pdflatex Document_Changes_V1_v2.tex

This gives the following output, where the blue content has been added from one version to another and the red content has been deleted.

changesUsing Revision Control

If you manage your Latex source with git or any other SCM tool anyways, you can use the same tool for comparing different revisions. Lets have a look at previous revisions in the git log:

stefan@stefan-Linux:~/Gitlab-Workspace/LatexTest$ git log
commit fc894678144569ace27776f82f230cfce0f1f017
Author: Stefan Pröll <sproell@sba-research.org>
Date:   Wed Feb 17 18:40:37 2016 +0100

    revision 2

commit 76bacf74d21f486daa4404a9bf16d2bfd634c38e
Author: Stefan Pröll <sproell@sba-research.org>
Date:   Wed Feb 17 18:36:41 2016 +0100

    revision 1

commit 641053bee12b9e9ecd8312c82925f5a962e5d65a
Author: Stefan Pröll <sproell@sba-research.org>
Date:   Wed Feb 17 17:45:17 2016 +0100

    mandrill init

Suppose we want to track the changes between revision 1 and revision 2, you can use the appropriate lateydiff variant to compare the revisions with eachother.

latexdiff-git -r fc894678144569ace27776f82f230cfce0f1f017 -r 76bacf74d21f486daa4404a9bf16d2bfd634c38e Document.tex

Note that in this case we provide the commit hash for git. This tool automatically writes the output in a new file denoted with the names of the two commit hashes that we provided. In the case of Subversion, you can also provide the revision id.

Limitations

It is important to understand that the Latex tool only considers changes in the printable text. This entails that if you change a picture or even replace an image with a new file (having a new file name), this will not be highlighted.

Continue reading