How to develop your own document class — our experience

Niall Mansfield
Play (21min) Download: MP4 | MP3

We recently started re–using LaTeX for large documents — professional computing books. Years ago (1987) I had personally used a LaTeX 2.09 custom class (although it wasn’t called a class file then) for a book I was writing. The class file was written by a colleague, because I found it impossible to understand the low–level TeX mechanisms needed then.In 2006 I wanted to use this class for a new book of my own, and also as the basis for all our camera–ready books submitted by other authors.I had the choice of converting it to a new .cls file, which much of the documentation suggests is the thing to do, or writing “add–on” .sty file for the standard book.cls. We decided to try the .sty approach, as there were several packages that seemed to do most of what we wanted.

We found that the .sty approach was straightforward, and much easier than expected. The resulting style is much shorter, easier to understand and maintain, and is much more flexible than our old one — we can use most standard packages to add extra features with no effort, because we still provide all the hooks that add–on packages rely on.

Our paper works through what we did as a case study, highlighting the bad bits as well as the good bits, so others can use it as a guide. The hardest thing was coming to grips with LaTeX hooks, its sectioning mechanism, and how the two interact; we had to document these, and we include that rudimentary documentation in our paper. Fortunately and surprisingly, little of this documentation work was required.

Had we tried to do this work as a new .cls file, we would have failed miserably, and would probably have ended up using InDesign or Quark Express for typesetting instead of LaTeX.

You may also like:

  1. Rolling your own document class
  2. xindy revisited — multilingual index creation for the UTF–8 age
  3. Observations of a TeXnician for hire
  4. A newbie’s experiences with Lilypond, Lilypond–book, LaTeX, and Perl
  5. Towards an Document Object Model (DOM) for Scribus

  • Share
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Loading ... Loading ...