summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-writecls.html
blob: 492b1347ae9babf6094f87fa9c10552314e15765 (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
38
39
40
41
42
43
<head>
<title>UK TeX FAQ -- question label writecls</title>
</head><body>
<h3>Learning to write LaTeX classes and packages</h3>
<p/>There&rsquo;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 &lsquo;LaTeX2e for class and package writers&rsquo;
(<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-ol-books.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&rsquo;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> &mdash; an example of this
technique may be seen in <i>ltxguide.cls</i>
<p/>An 
<a href="http://tug.org/TUGboat/Articles/tb28-1/tb88flynn.pdf">annotated version of <i>article</a></i>,
as it appears in <i>classes.dtx</i>, was published in
<i>TUGboat</i> 28(1).  The article, by Peter Flynn, which is some help in
understanding <i>classes.dtx</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>clsguide.pdf</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/doc/clsguide.pdf">macros/latex/doc/clsguide.pdf</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>