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.

In my references, I want to allow DOI's to break on a slash '/' character (or as a last resort on any character) to avoid underfull lines like the third reference below. Note that URL's are already breaking on slashes, and DOI's are already breaking on dashes.

image with problematic entry

\documentclass{article}

\usepackage[left=1.5in,right=1.5in]{geometry}

\usepackage{natbib}
\usepackage[colorlinks,breaklinks,urlcolor=blue]{hyperref}
\usepackage{doi}
\urlstyle{rm}
\bibliographystyle{sp}

\begin{document}
\nocite{Endriss:09} \nocite{Evans:80} \nocite{Szabolcsi:10}
\bibliography{references}
\end{document}

Here are some .bib entries:

@article{Evans:80, Author={Gareth Evans}, Journal={Linguistic Inquiry}, Number={2},
    Pages={337--362}, Title={Pronouns}, Url={http://www.jstor.org/stable/4178164},
    Volume={11}, Year={1980}}

@book{Szabolcsi:10, Author={Anna Szabolcsi}, Doi={10.1017/CBO9780511781681},
    Publisher={Cambridge University Press}, Title={Quantification}, Year={2010}}

The bibliography style file can be downloaded as part of a zip file (containing also the actually used class file) here: Instructions for S&P authors using LATEX 2ε | von Fintel | Semantics and Pragmatics.

share|improve this question
    
Adding \penalty 0 to the .bbl file manually produces a break, but messes up the link destination. –  Noah Aug 23 '12 at 22:07
add comment

1 Answer 1

up vote 4 down vote accepted

If you want the “doi:” also in roman font, as it seems to me, you need to replace the package doi with an own command \doi declared with url’s own facilities. It doesn’t matter, that it’s already defined in the class file sp.cls. Otherwise you could also use the package uri. Compare also my answer here: Produce a hyperlinked DOI?.

\documentclass{sp} % based on "article"

\usepackage[left=1.5in,right=1.5in]{geometry}

\usepackage{filecontents}
% will produce a BIB file with the same name like your main tex file
\begin{filecontents*}{\jobname.bib}
@article{Evans:80,
  Author={Gareth Evans},
  Journal={Linguistic Inquiry},
  Number={2},
  Pages={337--362},
  Title={Pronouns},
  Url={http://www.jstor.org/stable/4178164},
  Volume={11}, Year={1980}
}
@book{Szabolcsi:10,
  Author={Anna Szabolcsi},
  Doi={10.1017/CBO9780511781681},
  Publisher={Cambridge University Press},
  Title={Quantification},
  Year={2010}
}
\end{filecontents*}

\usepackage{natbib} % actually not needed: already defined in the class "sp"
\bibliographystyle{sp} % actually not needed: already defined in the class "sp"


% already loaded with the class "sp", throws out an error, if separately loaded:
% \usepackage[colorlinks,breaklinks,urlcolor=blue]{hyperref} % loads "url"
%
\urlstyle{rm} % actually not needed: already defined in the class "sp"
% see the documentation of "url" for the next command
% "doi:" is not part of the link:
\DeclareUrlCommand\doi{\def\UrlLeft##1\UrlRight{doi:\href{http://dx.doi.org/##1}{##1}}\urlstyle{rm}}
% "doi:" is part of the link:
% \DeclareUrlCommand\doi{\def\UrlLeft##1\UrlRight{\href{http://dx.doi.org/##1}{doi:##1}}\urlstyle{rm}}

\begin{document}
\nocite{Evans:80} \nocite{Szabolcsi:10}
\bibliography{\jobname}
\end{document}
share|improve this answer
    
Thanks, this did the trick! (Using package uri almost worked, except that “doi:” became part of the link.) –  Noah Aug 24 '12 at 4:10
    
Note, though, that this will not parse the doi for unwanted characters such as <, > and ; , as the doi package does. –  episanty Feb 25 '13 at 12:00
    
@episanty In doi.sty explicitly is written: “Some publishers have elected to use some nasty characters in their doi numbering scheme (<, >, ; have all been spotted).” For an example with semicolon see my linked answer. –  Speravir Feb 25 '13 at 16:01
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.