Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

5 Answers 5

up vote 16 down vote accepted

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.

share|improve this answer
1  
I like that link, but what the heck is "raison d'être" –  macmadness86 May 22 '12 at 20:18
    
@macmadness86 Simply put, what is the purpose of the class? –  Yiannis Lazarides May 22 '12 at 20:32

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)

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

I guess you don't care about anwsers like doing this using packages instead, about questions if your university is in US...

That is only spam. You would just like to know how to do it in raw, writing your own example.cls from nothing.

Well i am sorry to tell you that whole LaTeX comunity haven't managed to produce a single didactical tutorial on how to do that in complete. Thats why most of us are stucked on book, report, article, letter...

Sad? True!

share|improve this answer
2  
This should be a comment to the question, not an answer. –  Jake Aug 23 '12 at 15:33
1  
It is too long for a comment... –  71GA Aug 24 '12 at 9:46
1  
If you want to write such a document that'd be great, I know I'd look at it. In my experience, though, when people ask how to write a thesis class they just want a way to get on to the thesis. –  Jim Hefferon Nov 3 '12 at 11:22

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.

share|improve this answer
    
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 '12 at 1:03

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.