diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-patch.html')
-rw-r--r-- | Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-patch.html | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-patch.html b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-patch.html index 059f2bf68af..e28fd2f4b22 100644 --- a/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-patch.html +++ b/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-patch.html @@ -22,7 +22,6 @@ command, which we can then use in the redefinition of the command. So: <blockquote> <pre> -\let\OldSmooth\smooth \renewcommand{\smooth}{\mumble\OldSmooth} </pre> </blockquote><p> @@ -65,13 +64,34 @@ after </blockquote><p> we will have a new version of <code>\</code><code>b</code> defined as “<code>abc</code>”. <p/>The <i>ted</i> package is a ‘token list editor’, and provides a -command <code>\</code><code>Substitute*</code> which will patch the contents of a macro, -putting the result in a token-list, or (optionally) using the result -to (re)define a macro. The package may also be used as a powerful -debugging tool. +command <code>\</code><code>substitute</code> which will patch the +contents of a macro, putting the result in a token-list, or +(in the form <code>\</code><code>Substitute*</code>) using the result to (re)define a +macro. The following example defines a simple macro, and then changes +its definition: +<blockquote> +<pre> +\newcommand{\myfont}% + {\Large\sffamily\selectfont} +\Substitute*[\renewcommand{\myfont}]{\myfont}% + {\Large\sffamily}{\huge\itshape} +</pre> +</blockquote><p> +The macro’s definition is now: +<blockquote> +<pre> +\huge\itshape\selectfont +</pre> +</blockquote><p> +<p/>The package also offers a command <code>\</code><code>ShowTokens</code>, which shows the +content of its argument, one token to a line, with details of the +token’s category code, etc. This is recommended as a debugging tool. <p/>The <i>etoolbox</i> (which provides user access to e-TeX’s -programming facilities) provides a command <code>\</code><code>patchcmd</code> which will -perform a “string substitution” in a macro’s definition. The +programming facilities) provides a command <code>\</code><code>patchcmd</code> which is +very similar to <code>\</code><code>Substitute</code>, except that it only replaces a +single instance of the token(s) in its search pattern. Since not all +commands may be patched in this way, <code>\</code><code>patchcmd</code> takes extra +arguments for <em>success</em> and <em>failure</em> cases. The package also provides commands that prepend (<code>\</code><code>pretocmd</code>) or append (<code>\</code><code>apptocmd</code>) to the definition of a command. Not all commands may be patched in this way; the package provides a command @@ -83,20 +103,18 @@ string.) usable, but not really recommendable. <i>Patch</i> gives you an ingenious (and difficult to understand) mechanism, and comes as an old-style LaTeX documented macro file, which can no longer be -processed (as in - - <a href="FAQ-install-doc.html">generating documentation for a new package</a>). +processed to <a href="FAQ-install-doc.html">produce formatted documentation, etc.</a>. Fortunately, the file (<i>patch.doc</i>) may be input directly, and “documentation” may found by reading the source of the package. Roughly speaking, one gives the command a set of instructions analogous to <i>sed</i> substitutions, and it regenerates the -command thus amended. Unless you can’t do your job any other way, you -had probably best avoid <i>patch</i>. +command thus amended. Unless you can’t do your job any other way, +<i>patch</i> is best avoided. <dl> -<dt><tt><i>etoolbox.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk tex-archive/macros/latex/contrib/etoolbox.zip">macros/latex/contrib/etoolbox</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk tex-archive/macros/latex/contrib/etoolbox/">browse the directory</a>) -<dt><tt><i>patch.doc</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk tex-archivemacros/generic/misc/patch.doc">macros/generic/misc/patch.doc</a> -<dt><tt><i>patchcommand.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk tex-archive/macros/latex/contrib/patchcmd.zip">macros/latex/contrib/patchcmd</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk tex-archive/macros/latex/contrib/patchcmd/">browse the directory</a>) -<dt><tt><i>ted.sty</i></tt><dd><a href="http://www.tex.ac.uk/www.tex.ac.uk tex-archive/macros/latex/contrib/ted.zip">macros/latex/contrib/ted</a> (or <a href="http://www.tex.ac.uk/www.tex.ac.uk tex-archive/macros/latex/contrib/ted/">browse the directory</a>) +<dt><tt><i>etoolbox.sty</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/etoolbox.zip">macros/latex/contrib/etoolbox</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/etoolbox/">browse the directory</a>) +<dt><tt><i>patch.doc</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/generic/misc/patch.doc">macros/generic/misc/patch.doc</a> +<dt><tt><i>patchcommand.sty</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/patchcmd.zip">macros/latex/contrib/patchcmd</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/patchcmd/">browse the directory</a>) +<dt><tt><i>ted.sty</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/ted.zip">macros/latex/contrib/ted</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/ted/">browse the directory</a>) </dl> <p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=patch">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=patch</a> </body> |