Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a way to make bibliography back-references display and hyperlink in a PDF file but not print in a hard copy.

When I use

\usepackage[colorlinks=false,backref=page]{hyperref}

I get a red frame around hyperlinks that is not printed. Can I get this kind of behavior applied to the link itself using the backref hooks?

share|improve this question
2  
Have you seen Is it possible to distinguish between the soft copy and the hard copy of a pdf? That might be a proof-of-concept that can get you started, but you'd still have to patch up the back-references. –  doncherry Dec 1 '12 at 2:52
    
@Mike I don't quite understand: You've got you bibliography with 10 books and articles. One article has been cited four times in your text. To which of the four citations would you like to have the link from your bibliography? –  Keks Dose Dec 4 '12 at 17:05
    
@KeksDose What I would like is for the page numbers of those four backrefs to be displayed as separate links in the PDF file e.g. [10,13,18], but not have these backrefs display at all in the hardcopy –  Mike Dec 4 '12 at 20:48
    
@Mike So you've got two issues: Firstly, you'd like to know, how to create a bibliography which lists the pagenumbers, where the item (book, article, whatever) of the bibliography has been cited in the text, and secondly, you are asking how to link from the bibliography to the text, but only in the PDF, not in the printout? If yes, would you edit your question, please? –  Keks Dose Dec 4 '12 at 20:57
    
@KeksDose The purpose of the option backref=page is to place links to the relevant pages at the end of each bib entry. So this is not part of my question, I am only interested in making sure that those page references only appear in soft-copy. –  Mike Dec 5 '12 at 17:06
add comment

1 Answer

I have taken the code from Is it possible to distinguish between the soft copy and the hard copy of a pdf? and reversed the view/print states to define a viewonly environment, then wrapped \BR@backref in that environment. It appears to work but note that the content is only invisible when printed, but still occupies space, and so may result in blank lines in printed editions.

Note that it is not necessary to actually print the document to see if it works; the print preview mode should show the difference.

Update: Now uses ocg-p package version 0.4 (or greater) for more concise and reliable code. (Old answer available through revision history.)

Example here uses a test .bib file that should come with your distribution.

\documentclass[10pt,a4paper]{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage[backref=page]{hyperref}

% "viewonly" environment for content which should only be visible when the document is viewed on screen, not when it is printed
\usepackage{ocg-p}
\newenvironment{viewonly}{\begin{ocg}[printocg=never,listintoolbar=never]{Soft copy only}{viewonly}{1}}{\end{ocg}}

\makeatletter
\let\oldBR@backref=\BR@backref
\renewcommand{\BR@backref}[1]{\begin{viewonly}\oldBR@backref{#1}\end{viewonly}}
\makeatother


\begin{document}
This text is always visible. \cite{GSM97,RudolphGrabowskiGraubmann96}

\begin{viewonly}
This can not be seen if the document is printed.
\end{viewonly}

This text is visible in both the soft and the hard copy. \cite{Lam94}

\bibliography{biblio}
\end{document}

Original document side-by-side with print preview

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.