4

I've been told that I have to make all URLs in the bibliography for this document non-clickable. However, I am using hyperref to do internal linking within the document (c.f. citations).

I looked at the package options for hyperref but couldn't find an option to make URLs non-clickable. Is there a secret hack?

Update 1: Here's an MWE that shows that modifying href seemed not to work.

\documentclass{article}
\usepackage[colorlinks]{hyperref}

\begin{document}

\renewcommand\href[3][\relax]{#3}

Here's a cite:~\cite{ChaudhuriMS:11pperm}.


\bibliographystyle{IEEEtran}
\bibliography{example}
\end{document}

example.bib:

@article{ChaudhuriMS:11pperm,
    Author = {Kamalika Chaudhuri and Claire Monteleoni and Anand Dilip Sarwate},
    Date-Added = {2014-07-15 22:54:03 +0000},
    Date-Modified = {2014-07-15 22:54:03 +0000},
    Journal = {Journal of Machine Learning Research},
    Local-Url = {pdfs/ChaudhuriMS11erm.pdf},
    Month = {March},
    Pages = {1069--1109},
    Title = {Differentially private empirical risk minimization},
    Url = {http://jmlr.csail.mit.edu/papers/v12/chaudhuri11a.html},
    Volume = {12},
    Year = {2011},
    Bdsk-Url-1 = {http://jmlr.csail.mit.edu/papers/v12/chaudhuri11a.html}}

I am getting an warning: Package hyperref Message: Driver (autodetected): hpdftex. Is that undoing the href redefinition? Note I'm using pdflatex on MacOS.

Update 2: Here's a new MWE -- it seems that if I put a \newpage before the references, it makes all URLs clickable, and if not, then the fix works... I can hack this in my document but I find this behavior a bit... unexpected? Does \newpage clear some settings?

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{ChaudhuriMS:11pperm,
    Author = {Kamalika Chaudhuri and Claire Monteleoni and Anand Dilip Sarwate},
    Journal = {Journal of Machine Learning Research},
    Month = {March},
    Pages = {1069--1109},
    Title = {Differentially private empirical risk minimization},
    Url = {http://jmlr.csail.mit.edu/papers/v12/chaudhuri11a.html},
    Volume = {12},
    Year = {2011}}
\end{filecontents*}

\usepackage[colorlinks]{hyperref}

\begin{document}

Here is a cite: \cite{ChaudhuriMS:11pperm}.

\newpage % comment to make URL not clickable

\let\url\nolinkurl% Make \url be equivalent to \nolinkurl
\bibliographystyle{IEEEtran}
\bibliography{\jobname}
\end{document}

Update 3: Here's the .bbl file that is produced by TeXShop (perhaps I should return to the command line?). I still get that the link is non-clickable if and only if the \newpage is commented out. The .bbl file is identical whether I comment or don't comment the \newpage command.

% Generated by IEEEtran.bst, version: 1.13 (2008/09/30)
\begin{thebibliography}{1}
\providecommand{\url}[1]{#1}
\csname url@samestyle\endcsname
\providecommand{\newblock}{\relax}
\providecommand{\bibinfo}[2]{#2}
\providecommand{\BIBentrySTDinterwordspacing}{\spaceskip=0pt\relax}
\providecommand{\BIBentryALTinterwordstretchfactor}{4}
\providecommand{\BIBentryALTinterwordspacing}{\spaceskip=\fontdimen2\font plus
\BIBentryALTinterwordstretchfactor\fontdimen3\font minus
  \fontdimen4\font\relax}
\providecommand{\BIBforeignlanguage}[2]{{%
\expandafter\ifx\csname l@#1\endcsname\relax
\typeout{** WARNING: IEEEtran.bst: No hyphenation pattern has been}%
\typeout{** loaded for the language `#1'. Using the pattern for}%
\typeout{** the default language instead.}%
\else
\language=\csname l@#1\endcsname
\fi
#2}}
\providecommand{\BIBdecl}{\relax}
\BIBdecl

\bibitem{ChaudhuriMS:11pperm}
\BIBentryALTinterwordspacing
K.~Chaudhuri, C.~Monteleoni, and A.~D. Sarwate, ``Differentially private
  empirical risk minimization,'' \emph{Journal of Machine Learning Research},
  vol.~12, pp. 1069--1109, March 2011. [Online]. Available:
  \url{http://jmlr.csail.mit.edu/papers/v12/chaudhuri11a.html}
\BIBentrySTDinterwordspacing

\end{the bibliography}

Update 4: This phenomenon seems particular to Apple's Preview PDF reader (the solution given by Werner works great if you view the PDF in Adobe. I still have no idea why \newpage causes this difference, but at least I now have plausible deniability about the URLs. Thanks!

  • 1
    How are the URLs entered into the bibliography? A minimal working example (MWE) would help users diagnose the issue. – Matthew Leingang Jul 15 '14 at 17:48
  • Added an example above, sorry for not getting that earlier. – Anand Sarwate Jul 15 '14 at 23:12
  • Did you tried to clear your aux file? Note that in @AnandSarwate 's answer, \renewcommand\href[3][\relax]{#3} was intended to be place just before \bibliographystyle{IEEEtran}. – Clément Jul 15 '14 at 23:21
9

To de-activate the URL capability in the bibliography, set \url to be equivalent to \nolinkurl (also provided by hyperref; see section 4 Additional user macros of the hyperref HTML documentation):

enter image description here

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{ChaudhuriMS:11pperm,
    Author = {Kamalika Chaudhuri and Claire Monteleoni and Anand Dilip Sarwate},
    Date-Added = {2014-07-15 22:54:03 +0000},
    Date-Modified = {2014-07-15 22:54:03 +0000},
    Journal = {Journal of Machine Learning Research},
    Local-Url = {pdfs/ChaudhuriMS11erm.pdf},
    Month = {March},
    Pages = {1069--1109},
    Title = {Differentially private empirical risk minimization},
    Url = {http://jmlr.csail.mit.edu/papers/v12/chaudhuri11a.html},
    Volume = {12},
    Year = {2011},
    Bdsk-Url-1 = {http://jmlr.csail.mit.edu/papers/v12/chaudhuri11a.html}}
\end{filecontents*}

\usepackage[colorlinks]{hyperref}

\begin{document}

Here's a cite:~\cite{ChaudhuriMS:11pperm}.

\let\url\nolinkurl% Make \url be equivalent to \nolinkurl
\bibliographystyle{IEEEtran}
\bibliography{\jobname}
\end{document}
  • That is a nice answer,but I think that for the sake of generality you should preserve then restore the original \url command, as Andrew did in his answer. – Clément Jul 15 '14 at 23:26
  • Weirdly, this work on the MEW, but not in the full text of my document. The links are not blue anymore, but they are still clickable... – Anand Sarwate Jul 16 '14 at 0:00
  • @AnandSarwate: Then we need more information... – Werner Jul 16 '14 at 0:03
  • Added a new MWE... it seems \newpage is the culprit? – Anand Sarwate Jul 16 '14 at 0:22
  • 2
    @AnandSarwate: Have you tried viewing it in a different browser? I've tried compiling with all possible compilers (LaTeX > dvips > ps2pdf, pdfLaTeX, XeLaTeX, LauLaTeX) and nothing seems to produce the URL hyperlinked, when viewed in Adobe. – Werner Jul 16 '14 at 4:12
1

Assuming that you are using hyperref in the standard way then the links in the bibliography are being created using \href. You can disable these links by redefining the \href command just before your bibliography starts. As the syntax for \href is

\href[optional arguments]{url}{text}

you want to pick up the third argument to \href and discard the rest (#1 is the optional argument). Therefore, you need something like the following:

\documentclass{article}
\cite{one_paper}
\cite{another_paper}
\begin{document}

\renewcommand\href[3][\relax]{#3}     % this is the crucial line

\bibliographystyle{alpha}
\bibliography{mypapers}
\end{\document}

If you have links made with hyperref that appear after your bibliography then you should "save" the original \href command and then restore it afterwards:

\let\orighref=\href
\renewcommand\href[3][\relax]{#3}  
\bibliography{mypapers}
\let\href=\orighref
  • It doesn't quite seem to work for me (see edited example above) -- but maybe it's my rendering pipeline? – Anand Sarwate Jul 15 '14 at 23:00
  • This solution also doesn't work in the new MWE above -- the link is still colored and clickable. – Anand Sarwate Jul 16 '14 at 0:24
  • 1
    @AnandSarwate The reason that my solution doesn't work with your MWE is that your "Update 3" shows that the links in your bibliography are created using \url rather than with \href. In any case, the solution provided by @werner is better, not only because it works for you but because it directly addresses the problem with \url. – Andrew Jul 16 '14 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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