Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hyperref and backref link colouring issue

24 views
Skip to first unread message

chri_s...@yahoo.com

unread,
Jul 26, 2005, 3:30:24 PM7/26/05
to

In a pdf, hyperref does a great job at colouring all pagerefs and refs,
and putting links to them. But how does one get a link that contains

(1) "Reference \cite{4}" all coloured and made into a link?

(2) "Page \pageref{mylabel}" all coloured and made into a link?

(3) For the backref, "Cited on page xzy, uzzt and uziz." all coloured
and made into a link?

I'd like to use this in my freely downloadable 1100 page physics text.

\autoref is not designed for this; my trials with hyperpage
did not work; and the manual of hyperref does not seem
to help.

Thank you for any hint.

Cheers

Christoph Schiller

Heiko Oberdiek

unread,
Jul 27, 2005, 8:30:49 AM7/27/05
to
chri_s...@yahoo.com wrote:

> (2) "Page \pageref{mylabel}" all coloured and made into a link?

\hyperref[mylabel]{Page \pageref*{mylabel}}

> (3) For the backref, "Cited on page xzy, uzzt and uziz." all coloured
> and made into a link?

A link that points to three location at the same time? This is not
possible.
For configuring the back references you can use the
\backrefalt interface:

| * Alternative interface for formatting of backref entries, example:
|
| \documentclass[12pt,UKenglish]{article}
|
| \usepackage{babel}
| \usepackage[pagebackref]{hyperref}
|
| % Some language options are detected by package backref.
| % This affects the following macros:
| % \backrefpagesname
| % \backrefsectionsname
| % \backrefsep
| % \backreftwosep
| % \backreflastsep
|
| \renewcommand*{\backref}[1]{
| % default interface
| % #1: backref list
| %
| % We want to use the alternative interface,
| % therefore the definition is empty here.
| }
| \renewcommand*{\backrefalt}[4]{%
| % alternative interface
| % #1: number of distinct back references
| % #2: backref list with distinct entries
| % #3: number of back references including duplicates
| % #4: backref list including duplicates
| \par
| #3 citation(s) on #1 page(s): #2,\par
| \ifnum#1=1 %
| \ifnum#3=1 %
| 1 citation on page %
| \else
| #3 citations on page %
| \fi
| \else
| #3 citations on #1 pages %
| \fi
| #2,\par
| \ifnum#3=1 %
| 1 citation located at page %
| \else
| #3 citations located at pages %
| \fi
| #4.\par
| }
|
| \begin{document}
|
| \section{Hello}
| \cite{ref1, ref2, ref3, ref4}
| \section{World}
| \cite{ref1, ref3}
| \newpage
|
| \section{Next section}
| \cite{ref1}
| \newpage
|
| \section{Last section}
| \cite{ref1, ref2}
| \newpage
|
| \pdfbookmark[1]{Bibliography}{bib}
| \begin{thebibliography}{99}
| \bibitem{ref1} Dummy entry one.
|
| \bibitem{ref2} Dummy entry two.
|
| \bibitem{ref3} Dummy entry three.
|
| \bibitem{ref4} Dummy entry four.
|
| \end{thebibliography}
|
| \end{document}

Yours sincerely
Heiko <ober...@uni-freiburg.de>

chri_s...@yahoo.com

unread,
Jul 29, 2005, 12:57:56 AM7/29/05
to

Heiko Oberdiek wrote:

> > (2) "Page \pageref{mylabel}" all coloured and made into a link?
>
> \hyperref[mylabel]{Page \pageref*{mylabel}}

Thank you; that works perfectly!

> > (3) For the backref, "Cited on page xzy, uzzt and uziz." all coloured
> > and made into a link?
>
> A link that points to three location at the same time? This is not
> possible.

True, this was a question that made no sense. Oops.

But maybe I can specify my point (1) in better words.
Bibliographic references in my book look like

"\cite{#1}" "=" "\marginpar{Ref. #1}"
(in quotes because this is meant symbolically)

I implemented this by defining the hack:

\renewcommand{\@cite}[2]{\marginpar{Ref. #1}\if@tempswa{, #2}\else\fi}
(In fact, there is a bit more, but this is not important here)

This is surely not as intended, but I have not yet found a better way.
It works well with hyperref, which is the main thing.
The disadvantage is that the four characters "Ref." are not made into
a coloured link with hyperref.

Is there a better way to do this? How can one put the "Ref. nr" in
the margin, and have it all coloured and made into a link by hyperref?

It seems to me that varioref and the similar packages from the latex
comanion
(2nd edition) do not support this; on the
other hand, there must be more people who want this?

Thanky in advance for any help!

Christoph Schiller


P.S. The present limitations of the hyperrefs that I use can be seen
on the downloadable pdf found at www.motionmountain.net.
I'd like to use the better solution in the upcoming revsion.

0 new messages