# \pageref, but for columns

I need to point to a label on a page, but as my text is layed out in two columns, I'd also like to include the column (1 or 2). Is there a way to find out which column a label is in?

\documentclass{icgg}
\begin{document}
\section{First chapter}
\label{explanation}
Some text explaining some things.
...
... see page \pageref{explanation} for ...

\end{document}


I'd like to use something like:

see page \pageref{explanation}, column \columnref{explanation} for ...


Possible?

ps. the document class is provided by someone else and it defines the two-column format.

• Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Feb 9, 2014 at 15:49
• Where does icgg.cls come from? Can you give us a link to it? Feb 10, 2014 at 6:39
• icgg.cls is provided by the people who run the conference which this paper is for. I've put the cls class in my dropbox folder: dl.dropboxusercontent.com/u/38313625/icgg.cls Feb 10, 2014 at 11:08
• Feb 11, 2014 at 0:53

This is an attempt.

The class icgg.cls loads hyperref. We create a new command \collabel which is executed each time a \label command is issued.

If, for example, you issue \label{foo} a new label called col:foo is created at the same point of the document. if you want to know the column to which \label{foo} refers to, you have to use the command \columnref{col:foo}.

Here's an example (replace \documentclass[twocolumn]{article} \usepackage{hyperref} with \documentclass{icgg} in your document):

\documentclass[twocolumn]{article}
\usepackage{hyperref}
\usepackage{lipsum} %only for the example

\makeatletter
\AtBeginDocument{%
\let\oldlabel\label
\newcommand*\collabel[1]{%
\begingroup
\protected@write\@auxout{}{%
\string\newlabel{col:#1}{%
{\if@firstcolumn 1\else 2\fi}%
{}%
{}%
{}%
{}%
}%
}%
\endgroup
}
\renewcommand*\label[1]{%
\collabel{#1}\oldlabel{#1}
}
\def\columnref#1{%
\HyRef@StarSetRef{#1}\@firstoffive
}
}
\makeatother

\begin{document}

\section{First section}\label{sec:first}
\lipsum[1-4]

\section{Second section}\label{sec:second}
\lipsum[1-3]\label{sec:third}

Section \ref{sec:first} starts at page \pageref{sec:first} in column \columnref{col:sec:first},
while section \ref{sec:second} starts at page \pageref{sec:second} in column \columnref{col:sec:second}

\end{document}


Output:

Zoom on the relevant part:

Note that the command \if@firstcolumn sometimes fails to detect the right column, so you may have some wrong references.