I would like to define a LaTeX (!) command which would change its behavior if it occurs withing the scope of another command. Something like:
\newcommand{\aaa}[1]{#1}
\newcommand{\bbb}[1] IF WITHIN \aaa{} >>> {\it #1}
ELSE> {\bf #1}
Sorry for the "code" but I have little idea where to start looking for it or how to formulate my question correctly.
For example,
\bbb{sometext}
prints: sometext
while
\aaa{\bbb{sometext}}
prints: sometext
What I was able to find is only a similar question from some years ago: Detecting if inside \section. The answer was to use "modes" in ConTeXt which is impossible for me as I am restricted to LaTeX due to very specific packages I need.
\bbb
detecting if it's within\aaa
? Could\aaa
locally redefine\bbb
instead?