summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatmacros.html
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatmacros.html')
-rw-r--r--Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatmacros.html65
1 files changed, 65 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatmacros.html b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatmacros.html
new file mode 100644
index 00000000000..f37343a9096
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-whatmacros.html
@@ -0,0 +1,65 @@
+<head>
+<title>UK TeX FAQ -- question label whatmacros</title>
+</head><body>
+<h3>What are (TeX) macros</h3>
+<p/>TeX is a <em>macro processor</em>: this is a computer-science-y term
+meaning &ldquo;text expander&rdquo; (more or less); TeX typesets text as it
+goes along, but <em>expands</em> each macro it finds. TeX&rsquo;s macros
+may include instructions to TeX itself, on top of the simple text
+generation one might expect.
+<p/>Macros are a <em>good thing</em>, since they allow the user to
+manipulate documents according to context. For example, the macro
+<code>\</code><code>TeX</code> is usually defined to produce &ldquo;TEX&rdquo; with the &lsquo;E&rsquo; lowered,
+but in these FAQs the default definition of the macro is
+overridden, and it simply expands to the letters &ldquo;TeX&rdquo;. (<em>You</em>
+may not think this a good thing, but the author of the macros has his
+reasons &ndash; see <a href="FAQ-logos.html">TeX-related logos</a>.)
+<p/>Macro names are conventionally built from a <code>\</code>
+followed by a sequence of letters, which may be upper or lower case
+(as in <code>\</code><code>TeX</code>, mentioned above). They may also be
+<code>\&lt;<i>any single character</i>&gt;</code>, which allows all
+sorts of oddities (many built in to most TeX macro sets, all the
+way up from the apparently simple &lsquo;<code>\</code><code> </code>&rsquo; meaning &ldquo;insert a space
+here&rdquo;).
+<p/>Macro programming can be a complicated business, but at their very
+simplest they need little introduction &mdash; you&rsquo;ll hardly need to be
+told that:
+<blockquote>
+<pre>
+\def\foo{bar}
+</pre>
+</blockquote><p>
+replaces each instance of <code>\</code><code>foo</code> with the text &ldquo;bar&rdquo;. The
+command <code>\</code><code>def</code> is Plain TeX syntax for defining commands;
+LaTeX offers a macro <code>\</code><code>newcommand</code> that goes some way towards
+protecting users from themselves, but basically does the same thing:
+<blockquote>
+<pre>
+\newcommand{\foo}{bar}
+</pre>
+</blockquote><p>
+Macros may have &ldquo;arguments&rdquo;, which are used to substitute for marked
+bits of the macro expansion:
+<blockquote>
+<pre>
+\def\foo#1{This is a #1 bar}
+...
+\foo{2/4}
+</pre>
+</blockquote><p>
+or, in LaTeX speak:
+<blockquote>
+<pre>
+\newcommand{\foo}[1]{This is a #1 bar}
+...
+\foo{3/4}
+</pre>
+</blockquote><p>
+Macro writing can get very complicated, very quickly. If you are a
+beginner (La)TeX programmer, you are well advised to read something
+along the lines of the <a href="FAQ-books.html">TeXbook</a>; once you&rsquo;re under
+way, <a href="FAQ-ol-books.html">TeX by Topic</a> is possibly a more satisfactory
+choice. Rather a lot of the answers in these FAQs tell you
+about various issues of how to write macros.
+<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=whatmacros">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=whatmacros</a>
+</body>