Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linebreak in url with Bibtex and hyperref package

Tags:

Why is this item not shown properly in my bibliography?

 @misc{ann,     abstract = {ANN is an implbmentation of nearest neighbor search.},     author = {David M. Mount and Sunil Arya},     howpublished = {\url{http://www.cs.umd.edu/~mount/ANN/}},     keywords = {knn},     posted-at = {2010-04-08 00:05:04},     priority = {2},     title = {ANN.},     url = "http://www.cs.umd.edu/~mount/ANN/",     year = {2008} }  @misc{Nilsson96introductionto,       author = {Nilsson, Nils J.},       citeulike-article-id = {6995464},       howpublished = {\url{http://robotics.stanford.edu/people/nilsson/mlbook.html}},       keywords = {*file-import-10-04-11},       posted-at = {2010-04-11 06:52:28},       priority = {2},       title = {Introduction to Machine Learning: An Early Draft of a Proposed Textbook.},       year = {1996}   }   

alt text


EDIT:

I am using

\usepackage{hyperref} 

not

\usepackage{url} 

. It produces error when using url package together with it. So can the two not work together?

I would like to use hyper links inside pdf file, so I want to use hyperref package instead of url package. I googled a bit, and try

\usepackage[hyperindex,breaklinks]{hyperref} 

but there is still no line break just as before. How can I do it?


EDIT:

When using url and hyperref together, if it is just

\usepackage{hyperref}   \usepackage{url} 

the compilation by latex is fine, but the link is still hyperlink and has still no linebreak. If I do not use hyperref package, the link has linebreak, but I lose hyper links. Since \url can be used in both hyperref and url packages, how can I specify which package's \url is being used?

If it is

\usepackage{hyperref}   \usepackage[hyphens]{url} 

the compilation by latex command will report clash with url:

! LaTex Error: Option clash for package url.

So I wonder how I should do?

like image 508
Tim Avatar asked Apr 12 '10 21:04

Tim


People also ask

How do you shorten a link in LaTeX?

“latex short url” Code Answer %Use \href{URL}{DESCRIPTION} to add a link with description. %Use \url{URL} to add a link without a description.

How do you make a line break in LaTeX?

\\ (two backslashes) \newline.

How do you make a link in LaTeX?

How Do You Hyperlink in Latex? You can add a hyperlink into your LaTeX article using the command \usepackage{hyperref} and then including the command \href{YOUR URL}{TEXT FOR YOUR HYPERLINK}.


2 Answers

You should use them in this order:

\usepackage[hyphens]{url} \usepackage{hyperref}   

You get this error when you use them the other way around.

! LaTex Error: Option clash for package url. 

since the hyperref package loads the url package somewhere internally without that hypens option, and then you want to load it with the option, so it clashes.

Turning the order around does what you want and does not give this error (since the package is already loaded hyperref won't load it again with different options)

edit: this was with pdftex, I did not test with other tools.

edit2:

or as mentioned by PatrickT in a comment: \PassOptionsToPackage{hyphens}{url} if you're using a class that already loads the package, e.g. beamer.

like image 128
Jens Timmerman Avatar answered Nov 17 '22 15:11

Jens Timmerman


I just ran across almost the same problem and found it solved by putting

\PassOptionsToPackage{hyphens}{url} 

before the

\usepackage[...]{hyperref} 
like image 26
5gon12eder Avatar answered Nov 17 '22 17:11

5gon12eder