35

I want to design a new LaTeX for my college thesis, so that all students could use it. I have decent understanding of how LaTeX works.

I am looking for some nice article explaining how to write a LaTeX class file. Whether it would be nice to modify an existing one or start from the scratch?

4 Answers 4

23

The first question you need to answer before you embark on such an endeavour is the raison d'être for writing a new class. In many cases a small package might be a better idea.

I would start from using and understanding an existing class such as classicthesis, make a list of the changes that you want and then fork it into something new.

My suggestion is to target any new thesis class for XeLaTeX to get more freedom for fonts and utf-8 encoding.

A good source of information on the technicalities of writing a class is Reference guide to begin writing a class and/or a package.

2
  • 2
    I like that link, but what the heck is "raison d'être" May 22, 2012 at 20:18
  • 1
    @macmadness86 Simply put, what is the purpose of the class? May 22, 2012 at 20:32
19

I can only point to some bibliography I recently ran into:

@Aditya's comment to this question led me to the following video: Boris Veytsman, Class Writing for Wizard Apprentices, TUG 2009; I didn't listen to the full video since I'm not a Wizard Apprentice, but he points to some very interesting articles for beginners like me:

  • Jim Hefferon, "Minutes in Less Than Hours", TUGBoat 26/3 (2005) (PDF)

  • Peter Flynn, "Rolling your own Document Class: Using LaTeX to Keep Away From the Dark Side, TUGBoat 28/1 (2007) (PDF)

  • Scott Parkin, "Good Things Come in Little Packages: An Introduction to Writing .ins and .dtx files", TUGBoat 29/2 (2008) (PDF)

  • Niall Mansfield, "How to Develop Your Own Document Class — Our Exeperience", TUGBoat 29/3 (2008) (PDF)

  • Peter Flynn, "A university thesis class: automation and its pitfalls.", TUGboat, 33/2t (2012) (PDF)

  • David S. Latchman, "Preparing your thesis in LATEX.", TUGboat, 33/2 (2012) (PDF)

3
  • Latest by Peter Flynn, A university thesis class: automation and its pitfalls.TUGboat 2012, tug.org/tug2012/booklet/flynn/flynn00.pdf Nov 2, 2012 at 17:35
  • @texlearner Thanks! I turned the answer into a CW, so people can add new references.
    – henrique
    Nov 3, 2012 at 0:02
  • Thanks,I just pasted the link from tug.org, your compilation list was good Nov 3, 2012 at 0:08
17

Following up on Yiannis' answer, I think you will feel the need to write a class instead of a package only if you work in a field that requires rather specific things which are currently not offered by standard classes and packages. So this would mainly apply if you are working in the humanities or social sciences, for which the main classes will be memoir, classicthesis and some school-made classes.

If you need something more specific and that requires a lot of coding, including dealing with some internals, or if your layout parameters need to be loaded very early, you may want to create your own class.

For this, I would suggest you pick up a class you want to use as a base, then you can build on it. The easiest way is to create a class that will load it and then modify some of its macros. You will have to study the chosen class quite carefully (documentation and code) to find which macros you need to change in order to get what you want. To get you started on this, I would recommend Peter Flynn's article: "Rolling-up your own Document Class". He analyses the article class, but the same would have to be done for any other class.

Then, on the more practical side of class writing, I suggest you have a look at "LaTeX2ε for class and package writers", which explains many things about the expected formatting of your class, how to create options, how to load another class, etc.

So your basic code would look like:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{yourclass}%
    [YYYY/MM/DD v1.0 Description of your class]

% Create, execute and process options here, possibly with a key-value interface
% Insert any code you imperatively need before loading the class

\LoadClass{memoir}% or 
%\LoadClass{classicthesis}

% Modify the class here

Then, if you come across specific questions, someone of us will probably be able to answer them here.

12

I'd answer three main questions before starting any thesis class or package:

  1. Is your university in the U.S. or elsewhere?

    U.S. universities often have very strict requirements on thesis formatting, and though those requirements can almost certainly be met with LaTeX, you may not have the time to satisfy them. Their documentation on formatting requirements are almost always written with Microsoft Word users in mind, and you may have to translate what they're asking for into LaTeX terms (I went rounds with our graduate school trying to translate "just hit Enter N times when you're double-spaced" to "what does that mean in terms of baseline height?").

    Non-U.S. universities have much looser rules, and what requirements they do have are often much closer to what LaTeX does by default. That means more time spent writing your thesis, and less time spent fighting with the format.

  2. Has someone else at the university already written part or all of a thesis class or package? A mathematics or computer science faculty, or someone in engineering? If so, what parts of it are lacking?

  3. What's the schedule for your graduation? I wouldn't try to write a thesis class or package on top of my own writing if I needed to get done quickly. It took me three attempts (starting from scratch each time) to get a good working thesis class, though I learned a lot each time. However, writing that class was a side project, during a several-year period between finishing my M.S. and starting a PhD. If I had been a full-time graduate student, I doubt I'd have time to write my own class in time for graduation.

1
  • My university is in India. Now they give word doc template. But they want it to be converted into LaTeX template. The problem is that the thesis in India is different from US style. So I couldn't just take one from a US university and update it to suite my requirement. Also I have plenty of time with me :)
    – tex
    Apr 15, 2012 at 1:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .