# fancy-preview with other \ref-like commands (such as \autoref and \cref)

I finally got fancy-preview working, and I found the place (around line 97) in the script to add to the list of environments which it catches (to add propositions and so on). But what I can't find after a quick read-through is a way to have fancy-preview pick up \autoref, \cref, and other \ref-like commands. Does anybody know how to do this? (I don't know perl or low-level latex, so I could have easily missed something obvious.)

I much prefer using \autoref to \ref. After spending way too much time setting up fancy-preview, it would be pretty disappointing to have to give up \autoref to use it.

EDIT: After looking into this a bit further, I don't think this is controlled in the fancy-preview script. I think it's in the actual fancytooltips.dtx, around line 756. I don't yet know how to adjust this code to also redefine \autoref, but I think I'm at least looking in the right place.

The following code works for me. Save as file.tex and compile by fancy-preview file

Explanation:

• In fancytooltips.sty the original command \ref is saved into \fancy@oldref and replaced by a command which acts like \ref and adds the tooltip.
• Similarly, we store the comand \autoref to \oldautoref and replace it by a command which acts like old \autoref, ant then acts like \ref but the referrence is not printed (\fancy@oldref is temporarily redefined) and only the tooltip remains.

.

\documentclass{article}
\usepackage{tikz,hyperref,amsmath}

\makeatletter
\let\oldautoref\autoref
\def\autoref#1{\oldautoref{#1}{\def\fancy@oldref##1{}\ref{#1}}}
\makeatother

\begin{document}
\section{First}\label{sec:1}
Consider equation
$$\label{equation} x^2+y^2=\frac 1\pi$$

\begin{figure}
\centering
\begin{tikzpicture}
\draw[red,fill=blue] (0,0) circle (2cm);
\end{tikzpicture}
\caption{Caption of the figure}
\label{figure}
\end{figure}

\section{Second}\label{sec:2}