Skip to main content
To create a custom LaTeX document class, save a .cls file next to main.tex that declares itself with \NeedsTeXFormat{LaTeX2e} and \ProvidesClass, builds on a base class with \LoadClass, and defines your layout overrides. If you only need to pick an existing standard class (article, report, book, or beamer) rather than write a .cls file, see the Document classes reference. If you want reusable macros or styling on top of a standard class without changing its document structure, write a .sty package instead—see Create a LaTeX package.

Step 1: Write a minimal .cls file and load it from main.tex

A custom class usually extends article, report, or book instead of defining every sectioning and float command from scratch. Put four elements in the .cls file:
  1. \NeedsTeXFormat{LaTeX2e} declares the required LaTeX format.
  2. \ProvidesClass{name}[YYYY/MM/DD description] identifies the class; name should match the filename without .cls, and the optional date lets LaTeX warn about outdated versions.
  3. \LoadClass[options]{base} loads the base class inside your .cls file.
  4. \RequirePackage loads supporting packages (use \RequirePackage rather than \usepackage inside class and package files), followed by your custom commands and \endinput.
Inside .cls files, @ is already a letter, so internal commands such as \@title, \@author, and \@date work directly without \makeatletter.
techreport.cls
main.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

Step 2: Declare class options and forward unknown options

A bare \LoadClass[11pt,a4paper]{article} ignores options passed by the user to \documentclass[...]{techreport} (and calling \ProcessOptions\relax without \DeclareOption* triggers an Unused global option(s) warning). To support both custom class options and standard base-class options:
  1. Define custom options with \DeclareOption{name}{code}.
  2. Catch all other options with \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}.
  3. Run \ProcessOptions\relax before \LoadClass so forwarded options are queued before the base class loads.
If your class defines no custom options of its own and simply forwards everything verbatim to article, you can replace \DeclareOption*, \ProcessOptions\relax, and \LoadClass with \LoadClassWithOptions{article}.
groupreport.cls
main.tex
In the example above, compact is handled inside groupreport.cls to tighten the geometry margins, while 12pt is forwarded to article through \PassOptionsToClass.

Step 3: Save the .cls file where TeX finds it

TeX searches the directory of the main .tex file before system texmf trees. Keeping techreport.cls or groupreport.cls in the same folder as main.tex ensures every collaborator and build environment uses the exact same class without installing files locally. In LaTeX Cloud Studio, projects hold multiple files (including .cls and .sty files), and the compiler places all project files into the build directory beside main.tex on TeX Live 2026 (full distribution), so standard base classes and supporting packages such as geometry, titlesec, and fancyhdr are already available.

Common mistakes

  • Mismatched class name and filename: Saving \ProvidesClass{myreport} in techreport.cls emits a You have requested document class ..., but the document class provides ... warning.
  • Calling \LoadClass before \ProcessOptions\relax: Options queued with \PassOptionsToClass are not applied if \LoadClass has already executed.
  • Using \LoadClass inside a .sty file: LaTeX raises Two \LoadClass commands when the package is loaded after \documentclass (or \LoadClass in package file if loaded beforehand via \RequirePackage); use \LoadClass inside .cls files, not packages.
  • Putting document content inside the .cls file: Keep boilerplates and sample sections in a .tex template file; reserve the .cls file for layout rules and macros.

Try it in the editor

Start from the Basic Article template in LaTeX Cloud Studio, replace main.tex with the complete example, and add techreport.cls or groupreport.cls alongside it in the project.