blob: bb3d69069d166151a7e455dba64f60b7cd86112e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<head>
<title>UK TeX FAQ -- question label writecls</title>
</head><body>
<h3>Learning to write LaTeX classes and packages</h3>
<p>There's nothing particularly magic about the commands you use when
writing a package, so you can simply bundle up a set of LaTeX
<code>\</code><code>(re)newcommand</code> and <code>\</code><code>(re)newenvironment</code> commands, put them in
a file <i>package.sty</i> and you have a package.
<p>However, any but the most trivial package will require rather more
sophistication. Some details of LaTeX commands for the job are to
be found in 'LaTeX2e for class and package writers'
(<i>clsguide</i>, part of the LaTeX documentation distribution).
Beyond this, a good knowledge of TeX itself is valuable: thus books
such as the <a href="FAQ-books.html">TeXbook</a> or
<a href="FAQ-tutorials.html">TeX by topic</a> are relevant. With good TeX
knowledge it is possible to use the documented source of LaTeX as
reference material (dedicated authors will acquaint themselves with the
source as a matter of course). A complete set of the documented
source of LaTeX may be prepared by processing the file
<i>source2e.tex</i> in the LaTeX distribution, but individual files
in the distribution may be processed separately with LaTeX, like
any well-constructed <a href="FAQ-dtx.html"><code>.dtx</code> file</a>.
<p>Writing good classes is not easy; it's a good idea to read some
established ones (<i>classes.dtx</i>, for example, is the documented
source of the standard classes other than <i>Letter</i>, and may
itself be formatted with LaTeX). Classes that are not part of the
distribution are commonly based on ones that are, and start by loading
the standard class with <code>\</code><code>LoadClass</code> - an example of this
technique may be seen in <i>ltxguide.cls</i>
<dl>
<dt><tt><i>classes.dtx</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/base/classes.dtx">macros/latex/base/classes.dtx</a>
<dt><tt><i>ltxguide.cls</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/base/ltxguide.cls">macros/latex/base/ltxguide.cls</a>
<dt><tt><i>LaTeX documentation</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/doc.zip">macros/latex/doc</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/doc.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/doc/">browse</a>)
<dt><tt><i>source2e.tex</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/base/source2e.tex">macros/latex/base/source2e.tex</a>
</dl>
<p><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=writecls">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=writecls</a>
</body>
|