summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-ltxhash.html
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-05-22 23:51:44 +0000
committerKarl Berry <karl@freefriends.org>2009-05-22 23:51:44 +0000
commit566f5207d7e3cafb0633d31277067336ccd9cca7 (patch)
tree7af53e7ac405185168bc1dc38c4e820f442b78d0 /Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-ltxhash.html
parentb0beea26ffffd915bb6d9b82f2d65a0a05b7e23b (diff)
move generic english documents out of texmf-doc
git-svn-id: svn://tug.org/texlive/trunk@13396 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-ltxhash.html')
-rw-r--r--Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-ltxhash.html55
1 files changed, 55 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-ltxhash.html b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-ltxhash.html
new file mode 100644
index 00000000000..0e3d777727f
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-ltxhash.html
@@ -0,0 +1,55 @@
+<head>
+<title>UK TeX FAQ -- question label ltxhash</title>
+</head><body>
+<h3>Defining LaTeX commands within other commands</h3>
+<p/>LaTeX command definition is significantly different from the TeX
+primitive form discussed in an
+<a href="FAQ-hash.html">earlier question</a> about definitions within
+macros.
+<p/>In most ways, the LaTeX situation is simpler (at least in part
+because it imposes more restrictions on the user); however, defining a
+command within a command still requires some care.
+<p/>The earlier question said you have to double the <code>#</code> signs in command
+definitions: in fact, the same rule holds, except that LaTeX
+already takes care of some of the issues, by generating argument lists
+for you.
+<p/>The basic problem is that:
+<blockquote>
+<pre>
+\newcommand{\abc}[1]{joy, oh #1!%
+ \newcommand{\ghi}[1]{gloom, oh #1!}%
+}
+</pre>
+</blockquote><p>
+followed by a call:
+<blockquote>
+<pre>
+\cmdinvoke{abc}{joy}
+</pre>
+</blockquote><p>
+typesets &ldquo;joy, oh joy!&rdquo;, but defines a command <code>\</code><code>ghi</code> that takes
+one parameter, which it ignores; <code>\</code><code>ghi{gloom}</code> will expand to
+&ldquo;gloom, oh joy!&rdquo;, which is presumably not what was expected.
+<p/>And (as you will probably guess, if you&rsquo;ve read the earlier question)
+the definition:
+<blockquote>
+<pre>
+\newcommand{\abc}[1]{joy, oh #1!%
+ \newcommand{\ghi}[1]{gloom, oh ##1!}%
+}
+</pre>
+</blockquote><p>
+does what is required, and <code>\</code><code>ghi{gloom}</code> will expand to
+&ldquo;gloom, oh gloom!&rdquo;, whatever the argument to <code>\</code><code>abc</code>.
+<p/>The doubling is needed whether or not the enclosing command has an
+argument, so:
+<blockquote>
+<pre>
+\newcommand{\abc}{joy, oh joy!%
+ \newcommand{\ghi}[1]{gloom, oh ##1!}%
+}
+</pre>
+</blockquote><p>
+is needed to produce a replica of the <code>\</code><code>ghi</code> we defined earlier.
+<p/><p/><p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=ltxhash">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=ltxhash</a>
+</body>