« first day (149 days earlier)      last day (4801 days later) » 

11:46 AM
Idle question for the TeXperts here, in an answer just now I wanted to add a little extra code at the end of an already-defined macro (which took arguments). If doing so at the beginning, I would do \let\origcmd=\cmd \def\cmd{New Code\cmd}. For the end, I was reduced to \let\origcmd=\cmd \def\cmd#all#original#parameter#stuff{\cmd{#1}{#2}...{#n}New Code}. Is there a neater way to do that?
 
 
2 hours later…
1:32 PM
@AndrewStacey: The \apptocmd macro from the etoolbox packages allows you to append material to macros with arguments.
There is also the possibility to to use the similar technique of \g@addto@macro where you expand (using \expandafter) the original definition and use #1 etc. as arguments. Then the original #1 is replaced by the new #1, i.e. stays the same, and you can add material afterwards.
Example:
\def\A#1#2{(#1)(#2)}
\expandafter\def\expandafter\A\expandafter
#\expandafter1\expandafter#\expandafter2\expandafter{\A{#1}{#2}\newstuff{#1}{#2}}
> \A=macro:
#1#2->(#1)(#2)\newstuff {#1}{#2}.
@AndrewStacey: See also the code of the filehook package where I have some internal hooks which take an argument. The above technique is used there.
 
2:00 PM
I wish someone at my health insurance company would read the booktabs documentation
My policy has several such indecipherable "tables"
 
 
1 hour later…
3:09 PM
@MartinScharrer Phew, this version with \expandafters is even worse that having to put #all#original#parameter#stuff, isn't it? But \apptocmd sounds good.
 
@HendrikVogt You are right about the \expandafter. They can be avoided/reduced by placing \def\A#1#2 in a temp. macro.
 
 
2 hours later…
4:49 PM
@HendrikVogt One advantage of the \expandafters over #all#original#parameter#stuff is that the original macro can be redefined.
 
5:31 PM
@MartinScharrer Errrrmmm ... in that \expandafter version you also have the #all#original#parameter#stuff, so I'm not sure what you mean. And what do you mean by "that the original macro can be redefined"? That it can be redefined without the use of any temporary macros?
 
 
2 hours later…
7:53 PM
@HendrikVogt Exactly. And I'm aware the the original parameters must be replicated. I only use it in one occasion with a macro with one argument. The \expandafters can also be replaced by \edef and \unexpanded\expandafter{\oldmacro{#1}...}. But just use \apptocmd. I just posted the code to demonstrate the possibility.
 

« first day (149 days earlier)      last day (4801 days later) »