Is it possible to amend to a macro without storing the original one in a tmp variable?
Approach is similar to this one here: Redefine macro in terms of old one. But without the OldMacro
I came up with something using groups, but doesn't work.
\def\abc{abc}
\begingroup\let\orgabc\abc\def\abc{\orgabc\endgroup def}
EDIT: It's indeed partially working. But not to my expectations.
\documentclass{article}
\def\abc{abc}
\begingroup\let\orgabc\abc\def\abc{\orgabc\endgroup def}
\begin{document}
\abc
\end{document}
Output: abcdef (Works, as expected)
\documentclass{article}
\def\abc{abc}
\begingroup\let\orgabc\abc\def\abc{\orgabc\endgroup def}
\begin{document}
\abc
\abcorg
\end{document}
Output: Error: undefined control sequence (Works as desired, because \abcorg
is not defined)
\documentclass{article}
\def\abc{abc}
\begingroup\let\orgabc\abc\def\abc{\orgabc\endgroup def}
\begin{document}
\orgabc
\end{document}
Output: abc (Why is \orgabc
defined here?)
EDIT: The redefinition somehow clashes with the titlesec package. I opened a new question here
abcdef
.\g@addto@macro
, so\g@addto@\abc{foo}
→\abc
expands toabcfoo
then\g@addto@macro\abc{foo}
above...