# How do I alter all text colour within a space?

I've written a command to hide' text, equations, and content, by changing its colour (e.g. to all white). Based on the discussion in [1] I'm using the command:

\newcommand{\hi}[1]{{\leavevmode\color{gray!0}{#1}}}


It's important that it colours all text, all equations, and all environments (like enumerate). This works well. However, where it seems to fail is if hyperref colours the links. Here is a minimal example:

\documentclass{minimal}

\usepackage[usenames, dvipsnames]{xcolor}
\usepackage{hyperref}

\usepackage{amsmath}

\newcommand{\hi}[1]{{\leavevmode\color{gray!0}{#1}}}

\begin{document}
\hi{This is an equation
$$\label{myref} a = b.$$
%
I will reference the equation \eqref{myref}.}
\end{document}


On this minimal example, the equation reference \eqref{myref} produces a red-coloured number 1. Is there a way to keep coloured links on' (in areas of the document not affected by '\hi{}') and yet colour them appropriately in affected areas?

• Please be aware that if you distribute your document as pdf, people will still be able the text you are trying to hide – samcarter is at topanswers.xyz Jan 21 '19 at 13:43

If you use \hypersetup{hidelinks} within the group of your hidden content, you can temporally hide the links

\documentclass{minimal}

\usepackage[usenames, dvipsnames]{xcolor}
\usepackage{hyperref}
$$\label{myref} a = b.$$