Custom LaTeX package

Published on 29 Mar 2021

Just recently I thought about making my LaTeX package, aizancommons.sty, globally available so that I do not have to keep copying it around. The directive \usepackage{aizancommons} works even though the file is not in the same directory, much like how an actual LaTeX package would work.

On a Fedora system (Fedora Server 33, running on a VM), I was able to get it to work. First is to place to .sty file at the appropriate location, followed by running texhash to register the file, and confirm it has been registered by running kpsewhich.

# Create the folder
mkdir -p ~/texmf/tex/latex

# Copy the .sty LaTeX package file
cp aizancommons.sty ~/texmf/tex/latex

# Run texhash
texhash

# Check if it got registered
kpsewhich aizancommons.sty

A successful kpsewhich command would return the full path of that .sty file. In my case with aizancommons.sty, it returned /home/aixnr/texmf/tex/latex/aizancommons.sty.

Then I got curious. Since I track my aizancommons.sty using git, can I just place a symbolic link to the file? This makes it more easier for tracking the changes that I do to this package file.

# Create symbolic link
ln -s /full/path/to/aizancommons.sty /home/aixnr/texmf/tex/latex/aizancommons.sty

# Register
texhash

# Check
kpsewhich aizancommons.sty

kpsewhich returned the full path to the .sty file. Now, does it work? Yep it did, I confirmed it by writing a new LaTex document, and it was rendered as expected.

In my previous post, I embedded a GitHub gist to my common.sty. Here is the updated version, aizancommons.sty.

On a distantly related note, I noticed that with Source Sans Pro font, I did not have to enter to math mode to use Greek letters such as µ, α, β, so on and so forth. With CMU fonts before, I had to enter into math mode, otherwise the document won’t render. This was useful to know since I could just use Vim digraph to quickly type the Greek letter.