Assume I want to use some nice TikZ feature, such as casting a shadow, or something else. I may want to do that inside or outside a tikzpicture environment. So I am wondering if there is a (simple) way to find out if a command is executed in a tikzpicture environment. To be more specific, consider the MWE:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\tikzset{CastShadow/.style={anchor=south,inner sep=0,font=\ttfamily\Huge}}
\newcommand{\CastShadowOutsideTikZ}[2][]{
\begin{tikzpicture}[baseline=(temp.base)]
\node[CastShadow,#1](temp){#2};
\node[scope fading=south,opacity=0.4,yscale=-1,CastShadow,#1]{#2};
\end{tikzpicture}
}
\newcommand{\CastShadowInsideTikZ}[2][]{
\node[CastShadow,#1]{#2};
\node[scope fading=south,opacity=0.4,yscale=-1,CastShadow,#1]{#2};
}
\begin{document}
\CastShadowOutsideTikZ{Quack} \CastShadowOutsideTikZ[scale=2]{Quack}
\begin{tikzpicture}
\CastShadowInsideTikZ[at={(0,0)},scale=2]{Feep}
\end{tikzpicture}
\end{document}
I'd like to unify the commands \CastShadowOutsideTikZ and \CastShadowInsideTikZ to a single command \CastShadow, which behaves like \CastShadowInsideTikZ when called within a tizkpicture and like \CastShadowOutsideTikZ otherwise.
(I am aware of this post), but my question is whether there is a simpler way.)