[Tex/LaTex] Cross-reference Bibliography itself with biblatex and memoir

biblatexcleverefcross-referencinghyperrefmemoir

Is it possible to insert a cross-reference link to the Bibliography itself — not just to individual items in the Bibliography — with biblatex, hyperref, and cleverref under the memoir class?

That is, as in the following source, what label could be created where and how, so that the \cref{WHAT} shown in the Preface would point to the Bibliography? (So that clicking that link would take one to the Bibliography's first page.)

\documentclass[12pt]{memoir}

\usepackage[backend=bibtex]{biblatex}

\usepackage{hyperref}
\hypersetup{hyperindex,colorlinks, citecolor=red} 

\begin{filecontents}{biblatexdoc.bib}
@article{Archimedes200,author = {Archimedes},title = {Pi's the limit },
journal = {Syracuse J. Gastronom.\ Math.}, year = {200BCE},volume = {10},pages={\textsc{CCCXV}--\textsc{CCCXIV}}}

@article{EulerE1776,Author = {Euler, Leonhard},Title = {All about E},
Journal = {Math.\ Psychol.},Year = {1776},Volume = {4},pages={1--2718}}
\end{filecontents}

\addbibresource{biblatexdoc}

\begin{document}

\frontmatter
\tableofcontents

\chapter{Prefarc}

The Bibliography (\cref{WHAT}) includes only works actually cited.

\chapter{Math}

Archimedes~\cite{Archimedes200} and Euler~\cite{EulerE1776} studied the constants, $\pi$ and $e$,  respectively.

\printbibliography

\end{document} 

Best Answer

\nameref{WHAT} seems to be a better variant than \cref{WHAT}, the latter requires a label to a counter (well, \nameref does need this at well, but it is easier to fake the label with a wrapper, say, \biblabel which will use \label internally and automatically adds the hyperlink to the bibliography.

\documentclass[12pt]{memoir}

\usepackage[backend=bibtex]{biblatex}
\usepackage{hyperref}
\hypersetup{hyperindex,colorlinks, citecolor=red} 
\usepackage{cleveref}

\begin{filecontents}{biblatexdoc.bib}
@article{Archimedes200,author = {Archimedes},title = {Pi's the limit },
journal = {Syracuse J. Gastronom.\ Math.}, year = {200BCE},volume = {10},pages={\textsc{CCCXV}--\textsc{CCCXIV}}}

@article{EulerE1776,Author = {Euler, Leonhard},Title = {All about E},
Journal = {Math.\ Psychol.},Year = {1776},Volume = {4},pages={1--2718}}
\end{filecontents}

\addbibresource{biblatexdoc}

\makeatletter
\newcommand{\biblabel}[1]{%
  \phantomsection
  \edef\@currentlabel{\bibname}%
  \edef\@currentlabelname{\bibname}% Provide the \nameref - anchor name
  \label{#1}%
}
\makeatother


\begin{document}

\frontmatter
\tableofcontents

\chapter{Preface}

The \nameref{WHAT} includes only works actually cited.

\chapter{Math}

Archimedes~\cite{Archimedes200} and Euler~\cite{EulerE1776} studied the constants, $\pi$ and $e$,  respectively.


\printbibliography\biblabel{WHAT}

\end{document} 

enter image description here

Update

Support for more than one bibliography.

\documentclass[12pt]{memoir}

\usepackage[backend=bibtex]{biblatex}
\usepackage{hyperref}
\hypersetup{hyperindex,colorlinks, citecolor=red} 
\usepackage{cleveref}

\begin{filecontents}{biblatexdoc.bib}
@article{Archimedes200,author = {Archimedes},title = {Pi's the limit },
journal = {Syracuse J. Gastronom.\ Math.}, year = {200BCE},volume = {10},pages={\textsc{CCCXV}--\textsc{CCCXIV}}}

@article{EulerE1776,Author = {Euler, Leonhard},Title = {All about E},
Journal = {Math.\ Psychol.},Year = {1776},Volume = {4},pages={1--2718}}
\end{filecontents}

\addbibresource{biblatexdoc}

\makeatletter
\define@key{blx@bib2}{title}{\gdef\blx@thetitle{#1}}
\newcommand{\biblabel}[1]{%
  \phantomsection
  \edef\@currentlabel{\bibname}%
  \@ifundefined{blx@thetitle}{%
    \edef\@currentlabelname{\bibname}%
  }{%
    \edef\@currentlabelname{\blx@thetitle}%
  }%
  \label{#1}%
}
\makeatother


\begin{document}

\frontmatter
\tableofcontents

\chapter{Preface}

The \nameref{WHAT} includes only works actually cited, however, there is another \nameref{WHATOTHER}.

\chapter{Math}

Archimedes~\cite{Archimedes200} and Euler~\cite{EulerE1776} studied the constants, $\pi$ and $e$,  respectively.

\printbibliography[title={My sophisticated bibliography}]\biblabel{WHAT}

\printbibliography[title=Bib2]\biblabel{WHATOTHER}

\end{document} 

Update for multi-page bibliographies

\documentclass[12pt]{memoir}

\usepackage[backend=bibtex]{biblatex}
\usepackage{hyperref}
\hypersetup{hyperindex,colorlinks, citecolor=red} 

%\usepackage{msc}
\usepackage{cleveref}

\begin{filecontents}{biblatexdoc.bib}
@article{Archimedes200,author = {Archimedes},title = {Pi's the limit },
journal = {Syracuse J. Gastronom.\ Math.}, year = {200BCE},volume = {10},pages={\textsc{CCCXV}--\textsc{CCCXIV}}}

@article{EulerE1776,Author = {Euler, Leonhard},Title = {All about E},
Journal = {Math.\ Psychol.},Year = {1776},Volume = {4},pages={1--2718}}
\end{filecontents}

\addbibresource{biblatexdoc}
\addbibresource{biblatex-examples}


\makeatletter
\define@key{blx@bib2}{title}{\gdef\blx@thetitle{#1}}
\newcommand{\biblabel}[1]{%
  \phantomsection
  \@ifundefined{blx@thetitle}{%
    \edef\@currentlabelname{\bibname}%
    \edef\@currentlabel{\bibname}%
  }{%
    \edef\@currentlabel{\blx@thetitle}%
    \edef\@currentlabelname{\blx@thetitle}%
  }%
  \label{#1}%
}

\newcommand{\biblabelnote}[1]{%
  \defbibnote{#1}{\biblabel{#1}}%
}

\makeatother


\begin{document}

\frontmatter
\tableofcontents

\chapter{Preface}

The \nameref{WHAT} includes only works actually cited, however, there is another \nameref{WHATOTHER}.

\chapter{Math}
\nocite{*}

Archimedes~\cite{Archimedes200} and Euler~\cite{EulerE1776} studied the constants, $\pi$ and $e$,  respectively.

\biblabelnote{WHAT}
\printbibliography[title={My sophisticated bibliography},prenote={WHAT}]

\biblabelnote{WHATOTHER}
\printbibliography[title=Bib2,prenote={WHATOTHER}]

\end{document}