# Raising the hypertarget of chapter labels

When using twocolumn mode, it is a known issue that references to chapter headings point to the baseline rather than the chapter heading.

In a previous question, I asked how to fix this for the table of contents, but I realize that the solution does not solve the same issue for \ref and friends.

My attempt tried to patch \label in the same way as \addcontentsline, but this makes no difference to the \hypertarget of \*ref. How can I modify the target of chapter: labels? If it helps, bookmarks referencing the chapter are always prefixed by chapter:.

Reprex:

\documentclass{scrbook}
\usepackage[twocolumn]{geometry}
\usepackage{varioref}
\usepackage[hypertexnames=false]{hyperref}
\usepackage{cleveref}

\usepackage{etoolbox}

% Add extra hyper target for chapter: chapter..\thechapter
\renewcommand*{\chapterformat}{%
\chapappifchapterprefix{\nobreakspace}\thechapter\hspace{1em}}%
}

\makeatletter
{\Hy@writebookmark}% <search>
{\ifnum\pdfstrcmp{chapter}{#2}=0 % Chapter mark
\edef\@currentHref{.\theHchapter}%
\fi
\Hy@writebookmark}% <replace>
{}{}% <success><failure>

\patchcmd{\label}% <cmd>
{\Hy@writebookmark}% <search>
{\edef\@currentHref{.\theHchapter}%
\Hy@writebookmark}% <replace>
{}{}% <success><failure>

\makeatother

\makeatletter
\makeatother

\begin{document}
\tableofcontents
\part{A}
\chapter{foo\label{chapter:foo}}
\chapter{bar}
\part{B}
\chapter{Baz}\label{chapter:Baz}
\chapter{Foobar}

\Vref{chapter:Baz}.

\Vref{chapter:foo}.

\end{document}


Hyperref automatically provides targets at the top of each page by the name page.\thepage.

\documentclass{scrbook}
\usepackage[twocolumn]{geometry}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}

\newcommand{\topref}[1]% #1 = label

\begin{document}

chapter \topref{chapter:foo}

\part{A}
\chapter{foo}\label{chapter:foo}
\chapter{bar}
\part{B}
\chapter{Baz}\label{chapter:Baz}
\chapter{Foobar}

\end{document}