The Editors

## Class & Style

An introduction to LaTeX document classes and styles

by The Editors

A reader wrote, An article that I would certainly read with enormous interest would have the title "Compleat Idiot's guide to using .class and .sty files". In other words a blow-by-blow description of how to use those types of files for someone very new to LaTeX.

Let's start with class and style in LaTeX. Consider this short document:

   \documentclass{article}

\begin{document}

A Pascal (Pa) is equal to a Newton per square meter, $N/(m^2)$.

\end{document}


Class. This document uses the article document layout, also called the article documentclass. A documentclass defines the general appearance of a document: it sets margins, the type size for section heads, the placement of page numbers, and other document design features.

Style. A LaTeX style introduces new functionality and commands. As an illustration, let's add some style changes to make the document above more professional looking. The scientific units, $N/(m^2)$, as they stand will format, but not correctly for a scientific journal. There are standards for this, and you could look them up and try to get LaTeX to follow the rules. Fortunately, there is an easier way. A LaTeX user developed a package or style called SIunits that will correctly format scientific units.

If you use a style package your LaTeX document will look like the following:

   \documentclass{article}

\usepackage{SIunits}  % Scientific units package

\begin{document}

A Pascal (\pascal) is equal to a Newton per square meter,
\newton\per\square\metre.

\end{document}


Notice that a new command, \usepackage{SIunits}, appears in the document preamble. Also notice that now you can use some new commands: \pascal, \newton, \per, etc. These were introduced by the style package SIunits. If this document is formatted, you will see that the scientific units are formatted correctly. (It's nice that someone else figured this out so that you don't have to!)

In the above example, we have shown how to format a LaTeX document using a documentclass, and how to add new LaTeX commands by the use of a style package.

Class & Style. To tie this in to the theme of this issue, Class & Style: the article documentclass is found in a file called article.cls and is sometimes called a Class (.cls) file; the package SIunits is found in a file called SIunits.sty and is sometimes called a Style (.sty) file.

### Changing the Class

One way to change the appearance of a LaTeX document is through the \documentclass command options. To change the text font size, for example, add an option to \documentclass:

 \documentclass[12pt]{article}


This will change the text size from 10 point (the default) to 12 point.

Another way to change the appearance of a document is to change to another documentclass. For example, change \documentclass{article} to

 \documentclass{memoir}


Format the document and notice that the overall appearance is slightly different. Some alternate Classes are shown in the TeX Catalogue. Note that the TeX Catalogue has an easy way to view documentation for Classes and Styles.

### Finding Styles

In the above example we used a package SIunits to format scientific units. You can find this in the TeX Catalogue Topic Index under Science and then Typesetting Physical Units.

There are more than 2,000 LaTeX Style packages. The TeX Catalogue is a good starting point to locate the package you need. Another resource is CTAN. You can also try an online search engine. Try typing LaTeX physical units package into Google.com, for example, and it will find a few references to the SIunits package.

### More on Class & Style

Jim Hefferon, What I Wish I Had...When I Was A Lad: Using LaTeX Resources
Jim Hefferon, CTAN for Starters
Jim Hefferon, Minutes in Less Than Hours: Using LaTeX Resources

Page generated June 9, 2010 ; TUG home page; search; contact webmaster.