3
\label{References}
\renewcommand{\bibname}{References}
\lhead{\emph{References}}
\bibliographystyle{abbrvnat}
\bibliography{Bibliography}

I want to have all urls in my references list to be hyperlinked say under the word "URL". I've 100+ urls and its not looking very nice. I'm using BibTeX; so far, abbrvnat is the best style that has worked for me.

I'm using a template, hyperref is working fine. (I can hyper jump within the document.) Any quick solution, i.e. not having to do this manually with each bib entry?

11
  • Have you tried \url{..,}? Or possibly \string\url Commented Jan 22, 2015 at 15:07
  • Sorry, what's that??
    – user70997
    Commented Jan 22, 2015 at 15:08
  • A command from hyperref which links to urls Commented Jan 22, 2015 at 15:09
  • With biblatex (i just removed the tag) this would be the default. It is modern and flexible. If you have the choice, choose the modern system.
    – Johannes_B
    Commented Jan 22, 2015 at 15:10
  • @Mico Apologies, I'm a newbie, I think am using BibTex.. Am using the third option on here latextemplates.com/cat/theses (Masters/Doctoral Theses)
    – user70997
    Commented Jan 22, 2015 at 15:14

2 Answers 2

3

The following solution operates only on the contents of url fields. URLs given in other fields are not treated. Since hyperlinking is being performed, the hyperref package must be loaded.

  • Find the file abbrvnat.bst in your TeX distribution. Make a copy of this file, naming the copy (say) myabbrvnat.bst. (Don't edit directly an original file from your TeX distribution.)

  • Open myabbrvnat.bst in a text editor. (The editor you use for your tex files will do fine.)

  • Locate the function format.url. In my copy of the file, the function starts on line 306.

  • In this function, replace the line

    { new.block "URL \url{" url * "}" * }
    

    with

    { new.block "\href{" url * "}{URL}" * }
    
  • Save the file myabbrvnat.bst, either in the directory where your main tex file is located, or in a directory that's searched by BibTeX. If you choose the latter method, be sure to update the filename database of your TeX distribution.

  • Start using the new bibliography style by specifying it as the argument of the \bibliographystyle instruction. Be sure to run LaTeX, BibTeX, and LaTeX twice more to propagate all changes.

In the pdf file version of the screenshot shown below, the blue "URL" stub is a hyperlink to this question.

enter image description here

The files main.tex and main.bib that generated this screenshot are as follows:

main.tex

\documentclass{article}
\bibliographystyle{myabbrvnat}
\usepackage{natbib}
\usepackage[colorlinks,urlcolor=blue]{hyperref}
\begin{document}
\nocite{*}
\bibliography{main}
\end{document}

main.bib

@misc{xyz,
  author = "User70997",
  title  = "How to show {URLs} in a bibliography as (hyperlinked) stubs?",
  year   = 2015,
  month  = "January",
  url    = "http://tex.stackexchange.com/q/224403/5001",
}
4
  • Please uncomment package filecontents. Too many users have overwritten their files for a lack of knowledgement. btw: the stub really looks odd ;-)
    – Johannes_B
    Commented Jan 22, 2015 at 21:00
  • @Johannes_B - Did you mean "comment out" instead of "uncomment"? Please advise. btw: I agree that the stub takes some getting used to.
    – Mico
    Commented Jan 22, 2015 at 21:04
  • Yes, i meant comment out. It's late ;-)
    – Johannes_B
    Commented Jan 22, 2015 at 21:11
  • @Johannes_B - Done.
    – Mico
    Commented Jan 22, 2015 at 21:19
-1

Personally I like the formatting style of the book class. So here would be an example to add a hyperlink to this citation, by using the note parameter of the book class, simply inserting a \href{...} command

Main document

\documentclass[a4paper,11pt]{report}
\usepackage{hyperref} %Make hyperlinks available
\usepackage{cite}     %BibTeX support for bibliography and citing

\begin{document}

%An example citation
How to hyperlink all Bibliography URLs? It's easy \cite{Stack}.

\bibliography{bibl}{}
\bibliographystyle{plain}
\end{document}

bibl.bib file

@book{Stack,
  title     = "How to hyperlink all Bibliography URLs?",
  author    = "stackexchange",
  publisher = "stackexchange",
  year      = "2015",
  note      = "\href{http://tex.stackexchange.com/questions/224403/how-to-hyperlink-all-bibliography-urls}{link-text}"

}

4
  • note = "\href{tex.stackexchange.com/questions/224403/…}{link-text}"
    – user70997
    Commented Jan 22, 2015 at 15:39
  • This means I have to do it manually for each entry??? Sorry man that's just too difficult to do when I have 200 urls already!
    – user70997
    Commented Jan 22, 2015 at 15:40
  • This answer disregards the information that the OP uses the bibliography style abbrvnat and, most likely, that natbib citation management package (and thus, likely, does not use the cite package).
    – Mico
    Commented Jan 22, 2015 at 15:52
  • to user70997: its a quick job with grep magic ;-) To Mico: There was no information about the citation management package, so I couldn't know that, what I was showing is a quick and easy way to insert a url using the note field, which should be applyable in any bibliography style
    – HeXor
    Commented Jan 26, 2015 at 12:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .