Created
October 31, 2011 06:35
-
-
Save admackin/1327022 to your computer and use it in GitHub Desktop.
Replace Latex Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%The following's adapted from the TeX Frequently Asked Questions - Rather than overwriting an old command it's common to want to add some code at the beginning or the end of it. Suppose we want a version of a command that does some small extension of its original definition: we might try: | |
\renewcommand{\splat}{addedcode\splat} | |
%However, this would not work: a call to \splat would execute addedcode, and then call the redefined \splat again; this is an infinite recursive loop. Fortunately, the TeX primitive \let command comes to our rescue; it allows us to take a "snapshot" of the current state of a command, which we can then use in the redefinition of the command. So: | |
\let\Oldsplat\splat | |
\renewcommand{\splat}{addedcode\Oldsplat} | |
%effects the required patch, safely. Adding things at the end of a command works similarly. | |
%If \splat takes arguments, one must pass them on: | |
\renewcommand{\splat}[2]{addedcode\Oldsplat{#1}{#2}} | |
% (lifted from http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/extending_latex.html ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment