next up previous contents
Next: Commands for class and Up: The structure of a Previous: Example: a local letter

Example: a newsletter class

A simple newsletter can be typeset with LATEX, using a variant of the article class. The class begins by announcing itself as smplnews.cls.
   \NeedsTeXFormat{LaTeX2e}
   \ProvidesClass{smplnews}[1995/04/01 The Simple News newsletter class]

   \newcommand{\headlinecolor}{\normalcolor}
It passes most specified options on to the article class: apart from the onecolumn option, which is switched off, and the green option, which sets the headline in green.
   \DeclareOption{onecolumn}{\OptionNotUsed}
   \DeclareOption{green}{\renewcommand{\headlinecolor}{\color{green}}}

   \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

   \ProcessOptions\relax
It then loads the class article with the option twocolumn.
   \LoadClass[twocolumn]{article}
Since the newsletter is to be printed in colour, it now loads the color package. The class does not specify a device driver option since this should be specified by the user of the smplnews class.
   \RequirePackage{color}
The class then redefines \maketitle to produce the title in 72pt Helvetica bold oblique, in the appropriate colour.
   \renewcommand{\maketitle}{%
      \twocolumn[%
         \fontsize{72}{80}\fontfamily{phv}\fontseries{b}%
         \fontshape{sl}\selectfont\headlinecolor
         \@title
      ]%
   }
It redefines \section and switches off section numbering.
   \renewcommand{\section}{%
      \@startsection
         {section}{1}{0pt}{-1.5ex plus -1ex minus -.2ex}%
         {1ex plus .2ex}{\large\sffamily\slshape\headlinecolor}%
   }
 
   \setcounter{secnumdepth}{0}
It also sets the three essential things.
   \renewcommand{\normalsize}{\fontsize{9}{10}\selectfont}
   \setlength{\textwidth}{17.5cm}
   \setlength{\textheight}{25cm}
In practice, a class would need more than this: it would provide commands for issue numbers, authors of articles, page styles and so on; but this skeleton gives a start. The ltnews class file is not much more complex than this one.

LaTeX3 Mail Server
1999-07-12