Creating Classes in LaTeX

When you find yourself creating the same type of document but don’t want to copy-and-paste code repeatedly, create a document class to store that configuration. Now keep in mind, if you use the same configuration across many types of documents, it is better to make a custom LaTeX package. You might use a combination of these, creating both a class and package. Configuration can be shared from one class to the next, provided by the package, and configuration specific to each type of document can be provided by the class. These are the steps you take to create and use a class.

Create the Class File

Begin by creating plain text file with the extension .cls somewhere on your computer (maybe in your Documents folder, or a Git repository). We will create a symbolic link to this file in the location that LaTeX expects to find the file.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{yourclass}[2025/10/11 Your Class]

The date used in the \ProvideClass command should be in the format of YYYY/MM/DD. For example, October 14th, 2025 would be 2025/10/14.

Install the Class File

To make LaTeX load the class file, we need to link it in the TEXMFHOME directory. To figure out where this is, run this command:

kpsewhich -var-value=TEXMFHOME

This will output the path to the TEXMFHOME directory, which will look something like this:

/Users/william/Library/texmf

LaTeX expects class files to be located in the tex/latex sub-directory of this folder (it can be one of many places it searches). Create this folder by running:

mkdir -p $(kpsewhich -var-value=TEXMFHOME)/tex/latex

Then, to keep things organized, you can put the class file in yet another sub-directory. For my purposes, I’m going to put it in a folder called “journal”:

cd $(kpsewhich -var-value=TEXMFHOME)/tex/latex
mkdir journal
cd journal

And finally, make the symbolic link to the .cls file we created by using the ln -s command:

ln -s PATH/TO/yourclass.cls ./yourclass.cls

Other Resources