Code: Select all
\let\old@sect\@sect
\renewcommand{\@sect}{\old@sect\if<condition><do stuff>\fi}
Is it even possible to play around with this macro the way I want to? If so, any hints or suggestions that I can try?
Code: Select all
\let\old@sect\@sect
\renewcommand{\@sect}{\old@sect\if<condition><do stuff>\fi}
it's certainly possible, but not using \renewcommand (as you guessed). the good news is that the fact that #7 is (seemingly) optional has been ironed out by the time we get into \@sect. so it's all actually rather straightforward, except that we have to use the primitive \def command in place of \renewcommand:rspringuel wrote:I'm writing a class file in which I need the \@sect macro to function just like it does normally most of the time, but under certain conditions (as determined by the evaluation of an \if statement) to do something extra. If this was just a normal command, I would use the following kind of code:However, \@sect is a macro built into the kernel so I'm not sure if this is entirely kosher, especially since I'd like the <do stuff> to be able to use arguments #7 and #8 from \@sect (the short and long name for the section being created). It's this last part in particular that prevents me from just trying my luck since argument #7 is optional for \@sect and \renewcommand requires that the first argument be the optional one, if any.Code: Select all
\let\old@sect\@sect \renewcommand{\@sect}{\old@sect\if<condition><do stuff>\fi}
Is it even possible to play around with this macro the way I want to? If so, any hints or suggestions that I can try?
Code: Select all
\let\@old@sect\@sect
\def\@sect#1#2#3#4#5#6[#7]#8{%
\@old@sect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8}%
\if<something><do something>\fi
}