I would like to specify custom hierarchies of tikz nodes where I do a few geometry calculations related to text depth, text width, text height, and so on.
In the process of writing custom commands to automate some of these calculations, I end up wanting to use TeX conditionals mixed in with tikz code. I read in another question that \pgfextra{} can be used for this. However, it seems that this only works at the level of the tikzpicture environment.
A minimal example of what I would like to do is the following:
\documentclass[class=minimal, border=0pt]{standalone}
\usepackage{tikz}
\newif\ifDebug
%\Debugtrue
\Debugfalse
\newcommand\MyNode{
\node[anchor=north west,
minimum width=5cm,
minimum height=5cm,
fill=green,
\pgfextra{\ifDebug opacity=0.2,\fi}
] at (current page.north west) {}}
\begin{document}
\begin{tikzpicture}
\MyNode{};
\end{tikzpicture}
\end{document}
The line containing \pgfextra is giving me trouble. What should I do to conditionally change arguments to \node?
Thanks!