diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-verbwithin.html')
-rw-r--r-- | Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-verbwithin.html | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-verbwithin.html b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-verbwithin.html deleted file mode 100644 index e53d6391b0f..00000000000 --- a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-verbwithin.html +++ /dev/null @@ -1,144 +0,0 @@ -<head> -<title>UK TeX FAQ -- question label verbwithin</title> -</head><body> -<h3>Why doesn’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> and -<code>\</code><code>begin{verbatim}</code> have to assume that they are getting the -first look at the parameter text; if they aren’t, TeX has already -assigned category codes so that the verbatim command doesn’t have a -chance. For example: -<blockquote> -<pre> -\verb+\error+ -</pre> -</blockquote><p> -will work (typesetting ‘<code>\</code><code>error</code>’), but -<blockquote> -<pre> -\newcommand{\unbrace}[1]{#1} -\unbrace{\verb+\error+} -</pre> -</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 the -rather more helpful ‘<code>\</code><code>verb</code> illegal in command argument’. 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 ‘File ended while scanning use of -<code>\</code><code>@xverbatim</code>’, 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 “normal” 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 -indication of problems.) -<p/>The first question to ask yourself is: “is <code>\</code><code>verb</code> actually -necessary?”. -<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 - <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 - address or the like, then the <code>\</code><code>url</code> command from the - <i>url</i> will help: it doesn’t suffer from all the problems of - <code>\</code><code>verb</code>, though it’s still not robust; - “<a href="FAQ-setURL.html">typesetting URLs</a>” offers advice here. -<li> If you’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> - environmen)t: -<blockquote> -<pre> -\newsavebox{\mybox} -... -\begin{lrbox}{\mybox} - \verb!VerbatimStuff! -\end{lrbox} -\fbox{\usebox{\mybox}} -</pre> -</blockquote><p> -</ul> -<p/>If you can’t avoid verbatim, the <code>\</code><code>cprotect</code> command (from the -package <i>cprotect</i>) might help. The package manages to make a -macro read a verbatim argument in a “sanitised” way by the simple -medium of prefixing the macro with <code>\</code><code>cprotect</code>: -<blockquote> -<pre> -\cprotect\section{Using \verb|verbatim|} -</pre> -</blockquote><p> -The package (at the time this author tested it) was still under -development (though it <em>does</em> work in this simple case) and -deserves consideration in most cases; the package documentation gives -more details. -<p/>Other than the <i>cprotect</i> package, there are three partial -solutions to the problem: -<ul> -<li> Some packages have macros which are designed to be responsive - to verbatim text in their arguments. For example, - the <i>fancyvrb</i> package defines a command - <code>\</code><code>VerbatimFootnotes</code>, which redefines the <code>\</code><code>footnotetext</code> - command, and hence also the behaviour of the <code>\</code><code>footnote</code>) - command, in such a way that you can include <code>\</code><code>verb</code> commands in - its argument. This approach could in principle be extended to the - arguments of other commands, but it can clash with other packages: - for example, <code>\</code><code>VerbatimFootnotes</code> interacts poorly with the - <code>para</code> option of the <i>footmisc</i> package. -<p/> The <i>memoir</i> class defines its <code>\</code><code>footnote</code> command so that - it will accept verbatim in its arguments, without any supporting package. -<li> The <i>fancyvrb</i> package defines a command <code>\</code><code>SaveVerb</code>, - with a corresponding <code>\</code><code>UseVerb</code> command, that allow you to save - and then to reuse the content of its argument; for details of this - extremely powerful facility, see the package documentation. -<p/> Rather simpler is the <i>verbdef</i> package, whose <code>\</code><code>verbdef</code> - command defines a (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>_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 - <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\us=`\_ -... -\section{... \texttt{my\us name}} -</pre> - </blockquote><p> - Such a definition is ‘naturally’ robust; the construction - “<<i>back-tick</i>><code>\</code><code><<i>char</code></i>>” may be used for any - troublesome character (though it’s plainly not necessary for things - like percent signs for which (La)TeX already provides - robust macros). -</ul> -<dl> -<dt><tt><i>cprotect.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/cprotect.zip">macros/latex/contrib/cprotect</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/cprotect/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/cprotect.html">catalogue entry</a> -<dt><tt><i>fancyvrb.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/fancyvrb.zip">macros/latex/contrib/fancyvrb</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/fancyvrb/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/fancyvrb.html">catalogue entry</a> -<dt><tt><i>memoir.cls</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/memoir.zip">macros/latex/contrib/memoir</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/memoir/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/memoir.html">catalogue entry</a> -<dt><tt><i>url.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/url.zip">macros/latex/contrib/url</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/url/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/url.html">catalogue entry</a> -<dt><tt><i>verbdef.sty</i></tt><dd><a href="http://mirror.ctan.org/macros/latex/contrib/verbdef.zip">macros/latex/contrib/verbdef</a> (or <a href="http://mirror.ctan.org/macros/latex/contrib/verbdef/">browse the directory</a>); <a href="http://mirror.ctan.org/help/Catalogue/entries/verbdef.html">catalogue entry</a> -</dl> -<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin</a> -</body> |