2

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}
\hypersetup{colorlinks=true,linkcolor=Red,citecolor=Red}

\usepackage{amsmath}

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

\begin{document}
\hi{This is an equation
\begin{equation} \label{myref}
    a = b.
\end{equation}
%
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?

[1] Writing paragraphs in \textcolor

1
  • 1
    Please be aware that if you distribute your document as pdf, people will still be able the text you are trying to hide Jan 21, 2019 at 13:43

1 Answer 1

1

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}
\hypersetup{colorlinks=true,linkcolor=Red,citecolor=Red}

\usepackage{amsmath}

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

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

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .