I make handouts/slides for my students. I like to produce three different versions of these
- Solutions mode - Contains my solutions (usually in blue).
- Student mode - Solutions are hidden.
- Darkmode - Like student mode, but the background is dark and text is light (easier on the eyes for zoom classes)
The way I've been handling this is to call either \solutionsversion, \studentversion \darkmodeversion in the preamble, and this sets the colors of things (all the macros tidied away into a style file I wrote). I have a command \answer{...} which I put around stuff that is considered an answer. If \solutionsversion is called, this command sets the textcolor to be blue, if one of the other versions are called, it sets the textcolor to be the same as the background color, so text is hidden.
This works great until something I want to be an answer is living in something whose color is different than the standard background color, for instance, in a beamer block environment.
A partial fix I have found is to change the definition of \answer to make the text temporarily transparent with the following definition
\newcommand{\answer}[1]{\pgfsetfillopacity{0} #1 \pgfsetfillopacity{1}}
However, I have found that the dividing lines in fractions using \frac{}{} as well as the augmenting line in the answer to this question don't go transparent.
Does anyone have an idea of how I could have a single command that sets the content's color to be the same as the current background color, or should I stop trying to have a single macro to do everything.
Fixed: I was initially using \pgfsetfillopacity from the pgfplots package to make the text transparent. I have found that \texttransparent{0}{...} from the transparency package also gets the parts that pgfplots was missing.

\ifblock to just not to typeset them, so the color is not a problem... – Rmano May 31 '22 at 15:19\phantomor, if you want to leverage beamer (I assume based on the code you showed and that you said something about slides) use\visible. – Willie Wong May 31 '22 at 16:30