Skip to main content
Use a custom class when multiple documents must follow one format policy. A shared look can live at three levels: a customized preamble, a .sty package, or a .cls document class. Start at the lowest level that does the job and move up only when you need to.

Level 1: Customize the Preamble

article, report and book are more customizable than they look. titlesec (section styling), fancyhdr (headers and footers) and geometry (margins) cover most “we want our own look” requirements:
customized-article.tex
Ready to use this syntax? Continue in the browser editor when you want to adapt the example in a real project.Open LaTeX Cloud Studio
If only one or two documents need this look, stop here. A preamble is the easiest level to understand, debug and hand to a co-author.

Level 2: Move the Preamble into a .sty Package

When the same preamble appears in a second document, move it into a package:
groupstyle.sty
Each document then starts with \documentclass{article} and \usepackage{groupstyle}. Inside package files, use \RequirePackage instead of \usepackage, and give \ProvidesPackage a date so LaTeX can report version mismatches. A package builds on a standard class, so everything written for article keeps working. For most teams this is the right stopping point; see Create a LaTeX package for more.

Level 3: Write a .cls Document Class

Write a class when you need to change what the document is (its title layout, sectioning model or default structure), not only its styling.

Minimal Class Skeleton

myreport.cls

Usage

class-usage.tex

Forward Options and Override the Title

A class that builds on article follows one pattern: declare the class, forward unknown options to the base class, load the base class, then override what must change. This class reuses the Level 2 package and replaces \maketitle:
groupreport.cls
Documents that use the class stay short:
using-class.tex
Building on article with \LoadClass means you inherit its tested behavior and maintain only your differences. Writing a class from scratch is rarely the right call.

Practical Rules

  • \makeatletter and \makeatother are only needed in documents. Inside .sty and .cls files, @ is already a letter, so commands such as \@title work directly.
  • Date the \ProvidesClass line and update it on every change, so you can tell which class version produced a PDF.
  • Keep content out of the class. A class defines how documents look, not what they say. Boilerplate text belongs in a template document.
  • Ship the class with the documents. Put the .cls file in the project, or in a shared Git repository, instead of a local texmf tree. TeX finds files in the project folder first, so every collaborator and every CI build compiles with the same class.