How to tell PDFLaTeX to make hyphenation in place where I want it to be?
I have my document file:
\documentclass[10pt,a4paper]{article}
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
\usepackage[margin=2.5cm]{geometry}
\begin{document}
This is text with \cite{reference}.
\bibliographystyle{unsrt}
\bibliography{bib_file}
\end{document}
and bib_file.bib
file:
@misc{reference,
title = {{Some dummy title in bib.}},
howpublished = {\url{http://docs.oracle.com/javase/1.5.0/docs/relnotes/features.html\#concurrency}},
note = {Last access: 12.03.2013},
}
After building that file, the new line is places just after '.':
1st line: Some dummy title in bib. http://docs.oracle.com/javase/1.5.0/docs/relnotes/features.
2nd line: html#concurrency. Last access: 12.03.2013.
But I wanted to insert hyphenation point on other place, like:
1st line: Some dummy title in bib. http://docs.oracle.com/javase/1.5.0/docs/
2nd line: relnotes/features.html#concurrency. Last access: 12.03.2013.
or even:
1st line: Some dummy title in bib. http://docs.oracle.com/javase/1.5.0/docs/ <-/
2nd line: relnotes/features.html#concurrency. Last access: 12.03.2013.
<-/
– is the enter arrow.
I tried to insert {\-}
and \-
into the url, but it adds in that place \discretionary{-
text
}{}{}
Best Answer
The solution in this answer already shows how to fine tune the line breaking of URL's by specifying
\UrlBreaks
,\UrlBigBreaks
, and\UrlNoBreaks
.To get a carriage return symbol at breaking points, we specify the breaking points as
\UrlSpecials
, that include the symbol when a line break occurs there.To specify breaking points by hand we use a symbol that hopefully won't occur in any URL like a star
*
, and make it a break URL's like the above symbols, but vanishing from the string:In order to have correct links with this solution the star needs to be filtered out from the link, too. We use the gorgeous solution of Qrrbrbirlbel:
Of course, both solutions can be mixed, i.e., we can specify the normal breaking points as
\UrlSpecials
, as well as the star for additional hand made breaking points.Complete code:
yields
All hail to Qrrbrbirlbel for the hard part.