# Automatically change cref name on non-first mention

I'm using cleveref to make a references in format "img. NN". My university's instructions require to use "img. NN" format on the first reference and to write something like "see img. NN" on the second and further references. It seems, cleveref provides no such functionality. So I wonder, is it possible to do it automatically with the help of any other package?

Below is MWE, which shows what I would like to have.

\documentclass{article}
\usepackage{cleveref}
\begin{document}
First introduction of the image \cref{fig:1}. It should look like "fig. 1" (without quotes).

\begin{figure}[htb]
\caption{\label{fig:1}The first test image}
\end{figure}

Second mention of our figure (\cref{fig:1}) after its introduction.
The reference should look like "see fig. 1" instead of "fig. 1".
\end{document}

• Welcome to TeX.SE! Please provide an MWE (minimum working example) that shows what you've tried to do so far. In particular, please be sure to mention any language-specific settings you've chosen as well as how the counter "img" is defined in your document. – Mico Nov 30 '13 at 21:30
• It should be possible to implement that functionality with a TeX switch, but as Mico wrote, we need to see some MWE before we can suggest anything. – jub0bs Nov 30 '13 at 22:04

Here is an approach that stores all occurences of a reference used in a \cref or \Cref and checks whether this has been used before already and branches accordingly.

Update with shorter code

\documentclass{article}

\usepackage{xparse}

\usepackage{cleveref}

\ExplSyntaxOn
\seq_new:N \g_pashkoff_ref_seq

\cs_new:Nn \pashkoff_store_ref:n {%
\seq_gput_right:Nn \g_pashkoff_ref_seq {#1}%
}

\cs_new:Nn \pashkoff_redefine_crefcommand:n {%
\cs_gset_eq:cc {origcleveref#1} {#1}
\cs_gset:cpn {#1} ##1 {%
\seq_if_in:NnTF \g_pashkoff_ref_seq  {##1} {% Yes, used already
}{% No, not used so far
\pashkoff_store_ref:n {##1}%
\use:c{origcleveref#1}{##1}%
}% End of \seq_if_in:NnTF
}
}

\NewDocumentCommand{\RedefineCrefCommand}{m}{%
\pashkoff_redefine_crefcommand:n{#1}%
}

\ExplSyntaxOff

\AtBeginDocument{
\RedefineCrefCommand{cref}
\RedefineCrefCommand{Cref}
}

\begin{document}
First introduction of the image \cref{fig:1}. It should look like "fig. 1" (without quotes).

\begin{figure}[htb]
\caption{The first test image}\label{fig:1}
\end{figure}

Second mention of our figure (\cref{fig:1}) after its introduction. However, \Cref{fig:1}.
The reference should look like "see fig. 1" instead of "fig. 1".
\end{document}