projects tutorials cv hire me

Using a LaTeX macro package

If your writing a lot of small documents all the time and do math in them it is a good idea to write yourself a macro package that contains personalized macros and functions to speed up your typesetting. Especially useful for University assignments and notes.

System stuff LaTeX

If you never have written a TeX package, here the short-form with only the stuff we need. You start the file with


end it with


and save it with extension .sty instead of .tex.

Things to add

All of this is more useful for documents that you’re working on by yourself. Otherwise you have to distribute the package to your collaborators.

Using it

To make the package visible to your compiler (pdflatex, xelatex, …) you have to put it on the TeX path. You can add to your users local path to make it available to the compiler while using your account. The path is called TEXMFHOME and you can look it up with:

kpsewhich -var-value TEXMFHOME

On most Linux distros this will be /home/YOUR-USER/texmf, which probably doesn’t exist. As I do not want to clutter my home folder with that folder, I changed the path by setting an environment variable with the same name inside my xinit.rc:

export TEXMFHOME=~/.local/share/texmf

After a reboot/re-login the new TEXMFHOME should be set. Inside the folder your supposed to follow the TeX folder structure which means you should create the folders ~/.local/share/texmf/tex/latex/YOUR-PACKAGE-NAME/ and put your YOUR-PACKAGE-NAME.sty in there.

If the new path is not recognized you might need to rehash the TeX path:

sudo texhash /home/YOUR-USER/.local/share/textmf

Now all my assignment files for University and other scribbles always start with (as I have a morris.sty):


and I am writing considerably faster and more readable (in my humble opinion).
Instead of:

\pmb{\sigma} = \begin{bmatrix}
    \frac{\exp{\phi_1}}{\sum_i^N \exp{\phi_i}} & \dots

I write:

\B{} = \bM{{\exp{_1}}{_i^N \exp{_i}} & \… }