# Hiding and unhiding math text

Can Latex be used to type a math article containing invisible proofs, each of which becomes visible under the relevant theorem when a button or link is clicked?

-
Do you mean a hyperlink or something else? –  DJP Apr 13 at 0:45
Welcome to TeX.SX! –  Heiko Oberdiek Apr 13 at 0:51
Thanks very much for some very helpful answers, although I don't think Optical is a very good way of spelling Optional. –  Sanford Smith Apr 14 at 14:26

You can use fancytooltips; one restriction is that this won't work in most PDF viewers; you need Acrobat Reader:

Your main document will look something like this:

\documentclass{article}
\usepackage{xcolor}
\usepackage[filename=proofs,mouseover,noextratext]{fancytooltips}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{lipsum}

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
\lipsum[4]
\end{theorem}

\begin{theorem}
\lipsum[4]
\end{theorem}

\end{document}


the proofs.tex document containing the proofs; I placed every proof inside a tcolorbox, but, of course, you can use the formatting that best suits your needs:

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage[createtips]{fancytooltips}
\usepackage{tcolorbox}

\tcbset{
colframe=cyan,
colback=cyan!30,
colbacktitle=cyan,
title=Proof,
fonttitle=\bfseries
}

\begin{document}

\keytip{proofi}
\begin{tcolorbox}
Some test text for the proof; I will include some math expressions for the test:
\begin{align}
a ( b + c ) &= ab + ac \\
&= ba + ca \\
&= ( b + c) a
\end{align}
\end{tcolorbox}

\clearpage

\keytip{proofii}
\begin{tcolorbox}
Here we add some other expressions for another proof
$I_3 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$
\end{tcolorbox}

\end{document}


Here's an image of the output produced by the main document:

And some images of what you get when your mouse hovers over the text "Click here to see the proof.":

and

-
Unfortunately, I was not able to reproduce the image popup when clicking the blue texts. The texts are clickable with Adobe Reader X using Windows but nothing happens (but the file proofs.pdf exists). Maybe, Adobe Acrobat instead of Adobe Reader in needed ... ? –  Thomas F. Sturm Apr 14 at 10:39
@ThomasF.Sturm Weird. I used Adobe Reader to view my document and generate the images. If you want, just to test, I could produce the PDF and send it to you, so you can test with my working PDF? –  Gonzalo Medina Apr 14 at 12:51
I just tested on another system. There, it worked. This system has Adobe Reader XI for Windows installed. So, I guess, it's an Adobe Reader version problem. 'X' does not work, 'XI' does. Anyway, thanks for this interesting application :-) –  Thomas F. Sturm Apr 14 at 14:23

This can be achieved with Optical Content Groups (OCG). There are some packages that support OCG. A CTAN search revealed the following packages:

Example for ocgx (randomly choosen):

\documentclass{article}
\usepackage{ocgx}
\begin{document}
\noindent My theorem.
\begin{ocg}{OCG 1}{ocg1}{0}
My proof.
\end{ocg}
\switchocg{ocg1}{\fbox{Toggle proof}}
\end{document}


The package requires pdflatex (or lualatex) and at least two LaTeX runs are needed. (The rerun warning is missing.)

The text "My proof." should be invisible first. After pressing "Toggle proof" the proof should appear.

However, OCGs are not supported by all PDF viewers.

-