3
votes
1answer
30 views

How to re-define \space using \space in its definition

I am trying to implement a counter that counts the white spaces in order to give a rough estimate of the number of words contained in a paragraph. In order to do so, I set a new counter ...
20
votes
1answer
385 views

Please tutor the usage of patchcmd and xpatch

I understand that the patchcmd package provides a command \patchcommand that can be used to add material at the beginning and/or end of the replacement text of an existing macro. It works for macros ...
6
votes
2answers
292 views

How to redefine or patch the '\newcommand' command?

The Problem There are several packages I would like to write which require me to redefine the \newcommand (\renewcommand, etc.) command so I can track or change the commands that authors subsequently ...
8
votes
1answer
290 views

Is there a workaround for this limitation of \patchcmd?

The \patchcmd command of the well-known etoolbox package has a minor limitation: Patching seems to fail whenever \patchcmd is used in the argument of another command and the search/replacement texts ...
33
votes
4answers
3k views

Can I redefine a command to contain itself?

I'd like to "add to" an existing command by writing something like \renewcommand{\somecommand}{\begin{something}\somecommand\end{something}} but (not surprisingly) I get errors about being "too ...
15
votes
1answer
857 views

biblatex: Is it possible to patch macros created with \newbibmacro?

This question led to a new feature in a package: xpatch The etoolbox package provides various tools that "are useful to hook into or modify existing code" (etoolbox manual, section 3.4). The ...
19
votes
5answers
1k views

How does one append material to a token list?

Several times, the floatrow package uses \newtoks which (according to this website) means that a token register is allocated. An example code snippet is ...
10
votes
2answers
918 views

What is the right way to redefine macros defined by babel?

If I want to use the babel package and redefine a macro such as \contentsname, what is the right way to go about this? Just putting \renewcommand in the preamble doesn't work. This sort of works ...
13
votes
1answer
783 views

How to patch a package

I have a document that uses symbols both from the marvosym package as well as the eurosym package. There are two commands that clash and I get an error message (due to \newcommand being used and ...