9

I have tried several top answers with no luck. Here is what I have in my preamble(compiling with xelatex and bibtex).

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\usepackage{natbib}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{setspace}
\usepackage{url}

Here is a sample reference in Bibtex

@misc{DemandAccounting,
author={Henry Blodget},
title={Demand Media's Q3 revenue and pageview growth looks fine. But the company continues to capitalize its content costs,...},
month={November},
year={2011},
url={http://www.businessinsider.com/demand-medias-q3-revenue-and-pageview-growth-looks-fine-but-the-company-continues-to-capitalize-its-content-costs-2011-11},
publisher={Business Insider},
note={[10/11/2011]}
}

Here is the output

Even pointing out which solution is right for me and closing this questions down would hugely helpful. Thank you

sebey
  • 227

1 Answers1

11

The package url is set up so that, by default, URLs are not broken at hyphens. With the option hyphens they will:

\usepackage[hyphens]{url}

If you want this only in selected parts of your document, you can define

\makeatletter
\newcommand\URLhyphenOn{\def\do@url@hyp{\do\-}}
\newcommand\URLhyphenOff{\def\do@url@hyp{}}
\makeatother

in your preamble. Then loading \usepackage{url} will have break at hyphens inhibited, but from a \URLhyphenOn declaration onwards, the URL will be possibly broken at hyphens, until the group or environment in which the declaration is issued ends or a \URLhyphenOff declaration appears.

egreg
  • 1,121,712