summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-cmdstar.html
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-doc/doc/english/FAQ-en/html/FAQ-cmdstar.html')
-rw-r--r--Master/texmf-doc/doc/english/FAQ-en/html/FAQ-cmdstar.html37
1 files changed, 19 insertions, 18 deletions
diff --git a/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-cmdstar.html b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-cmdstar.html
index 0caaa1afd29..cb44adfe439 100644
--- a/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-cmdstar.html
+++ b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-cmdstar.html
@@ -2,7 +2,7 @@
<title>UK TeX FAQ -- question label cmdstar</title>
</head><body>
<h3>Commands defined with * options</h3>
-<p>LaTeX commands commonly have "versions" defined with an asterisk
+<p>LaTeX commands commonly have &ldquo;versions&rdquo; defined with an asterisk
tagged onto their name: for example <code>\</code><code>newcommand</code> and
<code>\</code><code>newcommand*</code> (the former defines a <code>\</code><code>long</code> version of the
command).
@@ -17,7 +17,7 @@ of the <i>ifthen</i> package:
\newcommand{\mycommandStar}{starred version}
\newcommand{\mycommandNoStar}[1]{normal version}
</pre>
-</blockquote>
+</blockquote><p>
This does the trick, for sufficiently simple commands, but it has
various tiresome failure modes, and it requires <code>\</code><code>mycommandnostar</code>
@@ -25,20 +25,21 @@ to take an argument.
<p>Of course, the LaTeX kernel has something slicker than this:
<blockquote>
<pre>
-\newcommand{\mycommand}[1]{\@ifstar
- \mycommandStar%
- \mycommandNoStar%
+\newcommand{\mycommand}{\@ifstar
+ \mycommandStar%
+ \mycommandNoStar%
}
-\newcommand{\mycommandStar}{starred version}
-\newcommand{\mycommandNoStar}{normal version}
+\newcommand{\mycommandStar}[2]{starred version}
+\newcommand{\mycommandNoStar}[1]{normal version}
</pre>
-</blockquote>
-Which is all very well, is fast and efficient, but requires the
-definition to be <a href="FAQ-atsigns.html"><code>\</code><code>makeatletter</code> protected</a>.
-The technique doesn't interfere at all with the definitions of
-<code>\</code><code>mycommandStar</code> or <code>\</code><code>mycommandNoStar</code>; they can have any
-combination of optional and mandatory arguments that you could define
-them to have in the ordinary way.
+
+</blockquote><p>
+(Note that arguments to <code>\</code><code>mycommandStar</code> and <code>\</code><code>mycommandNoStar</code>
+are independent &mdash; either can have their own arguments, unconstrained
+by the technique we&rsquo;re using, unlike the trick described above.)
+The <code>\</code><code>@ifstar</code> trick is all very well, is fast and efficient, but
+it requires the definition to be
+<a href="FAQ-atsigns.html"><code>\</code><code>makeatletter</code> protected</a>.
<p>A pleasing alternative is the <i>suffix</i> package. This elegant
piece of code allows you to define variants of your commands:
@@ -47,18 +48,18 @@ piece of code allows you to define variants of your commands:
\newcommand\mycommand{normal version}
\WithSuffix\newcommand\mycommand*{starred version}
</pre>
-</blockquote>
-The package needs <a href="FAQ-NTS.html">e-LaTeX</a>, but any new enough
+</blockquote><p>
+The package needs <a href="FAQ-etex.html">e-LaTeX</a>, but any new enough
distribution defines LaTeX as e-LaTeX by default. Command
arguments may be specified in the normal way, in both command
-definitions (after the "<code>*</code>" in the <code>\</code><code>WithSuffix</code>
+definitions (after the &ldquo;<code>*</code>&rdquo; in the <code>\</code><code>WithSuffix</code>
version). You can also use the TeX primitive commands, creating a
definition like:
<blockquote>
<pre>
\WithSuffix\gdef\mycommand*{starred version}
</pre>
-</blockquote>
+</blockquote><p>
<dl>
<dt><tt><i>ifthen.sty</i></tt><dd>Part of the LaTeX distribution
<dt><tt><i>suffix.sty</i></tt><dd>Distributed as part of <a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/bigfoot.zip">macros/latex/contrib/bigfoot</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/bigfoot.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/bigfoot/">browse</a>)