[Tex/LaTex] Creating new class file: Where to start

documentclass-writingjournalpackage-writing

Recently, a journal I have some editorial involvement with has decided that for its 'rapid publication' outlet, it will no longer accept submissions where LaTeX has been used to format the document. They now demand everything be submitted as a (sigh) Word document.

After much whining, bitching and moaning from me (and some others), they've relented — partially. They'll take LaTeX submissions if we can build a strong stylesheet – one wherein the generated PDF looks "pretty damned close to exactly like the published form" (their words).

The actual (published) format they want isn't particular complex. Fore example, see

http://www.esajournals.org/doi/pdf/10.1890/ES12-00286.1

Now, I'm 'good enough' with laTeX to be able to use this package, and that, a few tweaks here and there, to cobble together something pretty damned close. But, that approach isn't particularly portable. What they want (and I would agree) is a .cls file (and a .bst for the bib) which a user could apply to their document, and presto chango, out comes the paper.

I've never tried writing a .cls file. Those that I've accumulated over the years (e.g., Springer etc), I can follow pretty well, but I'm not quite sure where to start.

Suggestions? Of course, if any of your smart folks who can do this in your sleep wanna take 15 minutes and put it together, ( (and oh, say, 500 or so folks who use LaTeX for this journal) would be forever indebted – virtual beers on us for life. Real ones if we ever crossed corporeal paths.

Best Answer

I recently had to write a new class without very much LaTeX experience at all. I found LaTeX2e for class and package writers (http://www.ctan.org/pkg/clsguide) a great way to get started. It includes several examples.

It sounds like you already know what you're doing, so apologies if this is obvious, but a good way to start is to load a standard LaTeX class like article and then some extra packages on top of it, with something like:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{yourclass}[yyyy/mm/dd Your class description]

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

\LoadClass[a4paper,twoside]{article}

\RequirePackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}

This is just an example, but that worked for me, and I found that I could get fairly far by just adding packages. The class guide has better examples.