I need to write a document class or template, as for an article, letter, etc. Is there software for this? How do I set it up so that anyone can use my class just like \documentclass{article}?

  • Welcome to TeX.SE](meta.tex.stackexchange.com/questions/1436/welcome-to-tex-sx). Jul 15, 2012 at 6:41
  • 7
    How much experience do you have with LaTeX? Writing a documentclass can be very intricate. Is this an actual design project, or do you simply need a class to produce a particular result, like a letter? If the latter, you should search on CTAN to see if an existing one will work. Otherwise, could you give some detail on what you want to accomplish?
    – Ryan Reich
    Jul 15, 2012 at 6:52
  • I've edited your question for style; I hope you don't mind. I hope I didn't remove anything that needed to be there!
    – Ryan Reich
    Jul 15, 2012 at 7:03
  • thank you for your response. :) its ok i dont mind if you edited my question. Anyway, This is perhaps my first time to make a document class. I simply need to make a class in making an exam template. This template would include a customized names of the types questions. I read some tutorials on making one but i don't know where to make it? should be in windows? or Ubuntu? what software i should use for my project to function? hmmmm
    – Kayla
    Jul 15, 2012 at 7:37
  • 1
    @Kayla You say in your other comment that you don't have TeX Live. Do you have MikTeX, then? I ask because it sounds like you are a beginner, in which case you shouldn't try to write a documentclass. Have you looked at the exam class?
    – Ryan Reich
    Jul 15, 2012 at 7:48

2 Answers 2


Based on my comments, here is an answer. To write a document class, all you need (really) is to create a file, say, myclass.cls, and put it in the same place as your document; then it can be loaded with \documentclass{myclass} and any macros defined in it will be available to the document. The document clsguide.pdf that Higgs Boson linked describes all the various structured commands you ought to put in your class in order to give it a standardized appearance. For example, you can declare its version and the version of LaTeX you need it to use, load other packages or classes in it, and accept options in the form \documentclass[option,option2]{myclass}.

As far as creating a class, no special software is needed. A .cls file is exactly the same as any .tex file and you can write it in whatever text editor you normally write LaTeX documents in (perhaps you are using WinEdt, for example?). There are a few questions around this site about what editors are recommended; this one is a pretty big list.

If you are a beginner, you can look at existing classes for inspiration. For example, since you are building an exam class, you might look at exam.cls, which (though quite complex) is well-written and well-commented, so you might learn something about what a document class typically does. Also see their documentation.

I should say that if you are really a beginner, you should not be writing a class at all, and this example of a real documentclass will probably make no sense to you. Start out by defining some new commands and environments in the default article class. You can spin them off into an independent package later.

  • Thank you so much. Since this is a given project to us, i have no more options of changing it. I know it is quite complicated for me to create a new class rather than modifying an existing one as a beginner. But it is also a part of a beginner to learn what and how should it be done. That's what i am actually doing right now. Searching and Asking the veterans of the LaTeX world to have a more specified idea about the question i raised a while ago. Thank you! It really helped me. :P Good Day.
    – Kayla
    Jul 15, 2012 at 9:14

If you have TeXLive installed, type texdoc clsguide as follows.

enter image description here

Pressing enter will open a manual for writing document class.

Or you can download it from CTAN, here clsguide.pdf.

  • 5
    texdoc clsguide works with MiKTeX as well. +1 for the screenshot, executing texdoc right from the search box is a nice tip. (Boo for IE and Chrome though)
    – doncherry
    Jul 15, 2012 at 11:02
  • 4
    @Kayla: our friend Stefan Kottwitz has a dedicated server for querying and browing TeX and LaTeX package information and general documentation, based on texdoc: texdoc.net You can type clsguide in the search box and get the documentation. :) Jul 15, 2012 at 14:26
  • @doncherry: I removed IE from the screenshot but let Chrome stay intact. Jul 15, 2012 at 14:39
  • Boo for Adobe and chrome, but nice job on not being Linux snob :) Jan 31, 2017 at 17:00
  • The link in the post does not work, but I believe the document was moved and this is the same file.
    – natka_m
    Apr 8, 2020 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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