diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-activechars.html')
-rw-r--r-- | Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-activechars.html | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-activechars.html b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-activechars.html index 8ceaf24df9b..0308ebb2596 100644 --- a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-activechars.html +++ b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-activechars.html @@ -4,20 +4,29 @@ <h3>Defining characters as macros</h3> <p/>Single characters can act as macros (defined commands), and both Plain TeX and LaTeX define the character -“<code>~</code>” as a “non-breakable space”. A -character is made definable, or “active”, by setting its +“<code>~</code>” as a “non-breakable space”. A +character is made definable, or “active”, by setting its <em>category code</em> (catcode) to be <code>\</code><code>active</code> (13): -<code>\catcode‘_=\active</code>. -<p/>Any character could, in principle, be activated this way and defined -as a macro (<code>\</code><code>def</code><code>_{</code><code>\</code><code>_</code><code>}</code> — the simple answer to - -<a href="FAQ-underscore.html">using underscores</a>), but you must be +<blockquote> +<pre> +\catcode`\_=\active +</pre> +</blockquote><p> +Any character could, in principle, be activated this way and defined +as a macro: +<blockquote> +<pre> +\def_{\_} +</pre> +</blockquote><p> +which could be characterised as an over-simple answer to +<a href="FAQ-underscore.html">using underscores</a>. However, you must be wary: whereas people expect an active tilde, other active characters may be unexpected and interact badly with other macros. Furthermore, -by defining an active character, you preclude the character’s use for -other purposes, and there are few characters “free” to be subverted +by defining an active character, you preclude the character’s use for +other purposes, and there are few characters “free” to be subverted in this way. -<p/>To define the character “<code>z</code>” as a command, one would say something +<p/>To define the character “<code>z</code>” as a command, one would say something like: <blockquote> <pre> @@ -25,10 +34,10 @@ like: \def z{Yawn, I'm tired}% </pre> </blockquote><p> -and each subsequent “<code>z</code>” in the text would become a yawn. This would be +and each subsequent “<code>z</code>” in the text would become a yawn. This would be an astoundingly bad idea for most documents, but might have special -applications. (Note that, in “<code>\def z</code>”, “<code>z</code>” is no longer interpreted as -a letter; the space is therefore not necessary — “<code>\defz</code>” would do; we +applications. (Note that, in “<code>\def z</code>”, “<code>z</code>” is no longer interpreted as +a letter; the space is therefore not necessary — “<code>\defz</code>” would do; we choose to retain the space, for what little clarity we can manage.) Some LaTeX packages facilitate such definitions. For example, the <i>shortvrb</i> package with its <code>\</code><code>MakeShortVerb</code> command. @@ -42,17 +51,17 @@ purposes (the <code>\</code><code>verb</code> command does this), then the alter characters will not be interpreted properly when they appear in the argument to another command (as, for example, in -“<a href="FAQ-verbwithin.html"><code>\</code><code>verb</code> in command arguments</a>”). +“<a href="FAQ-verbwithin.html"><code>\</code><code>verb</code> in command arguments</a>”). An exemplary case is the <i>doc</i> package, which processes .dtx files using the <i>shortvrb</i> package to define -<code>|…|</code> as a shorthand for -<code>\</code><code>verb</code><code>|…|</code>. But <code>|</code> is +<code>|…|</code> as a shorthand for +<code>\</code><code>verb</code><code>|…|</code>. But <code>|</code> is also used in the preambles of tabular environments, so that tables in <code>.dtx</code> files can only have vertical line separation between columns by employing special measures of some sort. <p/>Another consequence is that catcode assignments made -in macros often don’t work as expected -(see “<a href="FAQ-actinarg.html">Active characters in command arguments</a>”). +in macros often don’t work as expected +(see “<a href="FAQ-actinarg.html">Active characters in command arguments</a>”). For example, the definition <blockquote> <pre> @@ -77,10 +86,10 @@ use: \endgroup </pre> </blockquote><p> -The alternative (“tricksy”) way of creating such an isolated +The alternative (“tricksy”) way of creating such an isolated definition depends on the curious properties of <code>\</code><code>lowercase</code>, which changes characters without altering their catcodes. Since there is -always <em>one</em> active character (“<code>~</code>”), we +always <em>one</em> active character (“<code>~</code>”), we can fool <code>\</code><code>lowercase</code> into patching up a definition without ever explicitly changing a catcode: <blockquote> @@ -109,12 +118,12 @@ special active <em>maths code</em>, as with </pre> </blockquote><p> The special character does not need to be redefined whenever it is -made active — the definition of the command persists even if the -character’s catcode reverts to its original value; the definition +made active — the definition of the command persists even if the +character’s catcode reverts to its original value; the definition becomes accessible again if the character once again becomes active. <dl> -<dt><tt><i>doc.sty</i></tt><dd>Distributed as part of the source of LaTeX, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/base.zip">macros/latex/base</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/base/">browse the directory</a>) -<dt><tt><i>shortvrb.sty</i></tt><dd>Distributed as part of <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/tools.zip">macros/latex/required/tools</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/tools/">browse the directory</a>) +<dt><tt><i>doc.sty</i></tt><dd>Part of the LaTeX distribution <a href="http://www.tex.ac.uk/tex-archive/macros/latex/base.zip">macros/latex/base</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/base/">browse the directory</a>); <a href="http://www.tex.ac.uk/tex-archive/help/Catalogue/entries/doc.html">catalogue entry</a> +<dt><tt><i>shortvrb.sty</i></tt><dd>Part of the LaTeX distribution <a href="http://www.tex.ac.uk/tex-archive/macros/latex/base.zip">macros/latex/base</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/base/">browse the directory</a>); <a href="http://www.tex.ac.uk/tex-archive/help/Catalogue/entries/shortvrb.html">catalogue entry</a> </dl> <p/><p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=activechars">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=activechars</a> </body> |