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}
?
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 '12 at 9:14
If you have TeXLive installed, type texdoc clsguide
as follows.
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, executingtexdoc
right from the search box is a nice tip. (Boo for IE and Chrome though) – doncherry Jul 15 '12 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 typeclsguide
in the search box and get the documentation.:)
– Paulo Cereda Jul 15 '12 at 14:26 -
@doncherry: I removed IE from the screenshot but let Chrome stay intact. – kiss my armpit Jul 15 '12 at 14:39
-
Boo for Adobe and chrome, but nice job on not being Linux snob :) – Vishal Gupta Jan 31 '17 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 '20 at 20:20
exam
class? – Ryan Reich Jul 15 '12 at 7:48