summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-verbwithin.html
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-doc/doc/english/FAQ-en/html/FAQ-verbwithin.html')
-rw-r--r--Master/texmf-doc/doc/english/FAQ-en/html/FAQ-verbwithin.html79
1 files changed, 49 insertions, 30 deletions
diff --git a/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-verbwithin.html b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-verbwithin.html
index 7f6a82228dc..988287f42ce 100644
--- a/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-verbwithin.html
+++ b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-verbwithin.html
@@ -1,47 +1,66 @@
<head>
<title>UK TeX FAQ -- question label verbwithin</title>
</head><body>
-<h3>Why doesn't <code>\</code><code>verb</code> work within ...?</h3>
+<h3>Why doesn&rsquo;t verbatim work within ...?</h3>
<p>The LaTeX verbatim commands work by changing category codes. Knuth
-says of this sort of thing "Some care is needed to get the timing
-right...", since once the category code has been assigned to a
-character, it doesn't change. So <code>\</code><code>verb</code> has to assume that it is
-getting the first look at its parameter text; if it isn't, TeX has
-already assigned category codes so that <code>\</code><code>verb</code> doesn't have a
+says of this sort of thing &ldquo;Some care is needed to get the timing
+right...&rdquo;, since once the category code has been assigned to a
+character, it doesn&rsquo;t change. So <code>\</code><code>verb</code> and
+<code>\</code><code>begin{verbatim}</code> have to assume that they are getting the
+first look at the parameter text; if they aren&rsquo;t, TeX has already
+assigned category codes so that the verbatim command doesn&rsquo;t have a
chance. For example:
<blockquote>
<pre>
\verb+\error+
</pre>
-</blockquote>
-will work (typesetting '<code>\</code><code>error</code>'), but
+</blockquote><p>
+will work (typesetting &lsquo;<code>\</code><code>error</code>&rsquo;), but
<blockquote>
<pre>
\newcommand{\unbrace}[1]{#1}
\unbrace{\verb+\error+}
</pre>
-</blockquote>
+</blockquote><p>
will not (it will attempt to execute <code>\</code><code>error</code>). Other errors one
-may encounter are '<code>\</code><code>verb</code> ended by end of line', or even '<code>\</code><code>verb</code>
-illegal in command argument'.
+may encounter are &lsquo;<code>\</code><code>verb</code> ended by end of line&rsquo;, or even the
+rather more helpful &lsquo;<code>\</code><code>verb</code> illegal in command argument&rsquo;. The
+same sorts of thing happen with <code>\</code><code>begin{verbatim}</code> ...
+<code>\</code><code>end{verbatim}</code>:
+<blockquote>
+<pre>
+\ifthenelse{\boolean{foo}}{%
+\begin{verbatim}
+foobar
+\end{verbatim}
+}{%
+\begin{verbatim}
+barfoo
+\end{verbatim}
+}
+</pre>
+</blockquote><p>
+provokes errors like &lsquo;File ended while scanning use of
+<code>\</code><code>@xverbatim</code>&rsquo;, as <code>\</code><code>begin{verbatim}</code> fails to see its
+matching <code>\</code><code>end{verbatim}</code>.
<p>This is why the LaTeX book insists that verbatim
commands must not appear in the argument of any other command; they
-aren't just fragile, they're quite unusable in any command parameter,
+aren&rsquo;t just fragile, they&rsquo;re quite unusable in any command parameter,
regardless of <a href="FAQ-protect.html"><code>\</code><code>protect</code>ion</a>. (The <code>\</code><code>verb</code>
-command tries hard to detect if you're misusing it; unfortunately, it
-can't always do so, and the error message is therefore not a reliable
+command tries hard to detect if you&rsquo;re misusing it; unfortunately, it
+can&rsquo;t always do so, and the error message is therefore not a reliable
indication of problems.)
-<p>The first question to ask yourself is: "is <code>\</code><code>verb</code> actually
-necessary?".
+<p>The first question to ask yourself is: &ldquo;is <code>\</code><code>verb</code> actually
+necessary?&rdquo;.
<ul>
<li> If <code>\</code><code>texttt{<em>your text</em>}</code> produces the same result
- as <code>\</code><code>verb</code><code>+<em>your text</em>+</code>, then there's no need of
+ as <code>\</code><code>verb</code><code>+<em>your text</em>+</code>, then there&rsquo;s no need of
<code>\</code><code>verb</code> in the first place.
-<li> If you're using <code>\</code><code>verb</code> to typeset a URL or email
+<li> If you&rsquo;re using <code>\</code><code>verb</code> to typeset a URL or email
address or the like, then the <code>\</code><code>url</code> command from the
- <i>url</i> package will help: it doesn't suffer from the problems
- of <code>\</code><code>verb</code>.
-<li> If you're putting <code>\</code><code>verb</code> into the argument of a boxing
+ <a href="FAQ-setURL.html"><i>url</i> package</a> will help: it doesn&rsquo;t suffer
+ from the problems of <code>\</code><code>verb</code>.
+<li> If you&rsquo;re putting <code>\</code><code>verb</code> into the argument of a boxing
command (such as <code>\</code><code>fbox</code>), consider using the <code>lrbox</code>
environment:
<blockquote>
@@ -53,7 +72,7 @@ necessary?".
\end{lrbox}
\fbox{\usebox{\mybox}}
</pre>
-</blockquote>
+</blockquote><p>
</ul>
<p>Otherwise, there are three partial solutions to the problem.
<ul>
@@ -77,23 +96,23 @@ necessary?".
(robust) command which expands to the verbatim argument given.
<li> If you have a single character that is giving trouble (in
its absence you could simply use <code>\</code><code>texttt</code>), consider using
- <code>\</code><code>string</code>. <code>\</code><code>texttt{my<code>\</code><code>string</code>_</code>name}
+ <code>\</code><code>string</code>. <code>\</code><code>texttt{my<code>\</code><code>string</code>_name}</code>
typesets the same as
<code>\verb+my_name+</code>, and will work in the argument of a command. It
- won't, however, work in a moving argument, and no amount of
+ won&rsquo;t, however, work in a moving argument, and no amount of
<a href="FAQ-protect.html"><code>\</code><code>protect</code>ion</a> will make it work in
such a case.
<p> A robust alternative is:
<blockquote>
<pre>
-\chardef\bs=`\_
+\chardef\us=`\_
...
-\section{... \texttt{my\bs name}}
+\section{... \texttt{my\us name}}
</pre>
- </blockquote>
- Such a definition is 'naturally' robust; the construction
- "&lt;<i>back-tick</i>&gt;<code>\</code><code>&lt;<i>char</i>&gt;</code>" may be used for any
- troublesome character (though it's plainly not necessary for things
+ </blockquote><p>
+ Such a definition is &lsquo;naturally&rsquo; robust; the construction
+ &ldquo;&lt;<i>back-tick</i>&gt;<code>\</code><code>&lt;<i>char</code></i>&gt;&rdquo; may be used for any
+ troublesome character (though it&rsquo;s plainly not necessary for things
like percent signs for which (La)TeX already provides
robust macros).
</ul>