URLs in bibliography: LaTeX not breaking line as expected

The url package provides an interesting extra piece of flexibility, via the construct \Urlmuskip. This specifies the spacing around the breakable characters. By default it is 0mu however you can set it some glue specification:

\Urlmuskip=0mu plus 1mu

(Unfortunately the example in the url manual is wrong. It says \Urlmuskip=0pt plus 1mu. Being a mathematical skip expression the only units allowed are mu.)

Anyway in your example this gives:

Sample output

\documentclass[paper]{ieice}

\usepackage[hyphens]{url}
\usepackage[hidelinks]{hyperref}
\hypersetup{breaklinks=true}
\urlstyle{same}
\usepackage{cite}

\title{Test document}
\begin{document}

this\cite{upnp_spec} is a test\cite{android_javascriptinterface} \cite{Author:Title}

\Urlmuskip=0mu plus 1mu\relax
\bibliographystyle{plain}
\bibliography{refs_min}

\end{document}

with an extra entry in your bib file.

Other things one might try to help in general include making the bibliography ragged right. The easiest way to this is just to write \raggedright before your \bibliography command. Better ragged right formatting is provided by the ragged2e package. Unfortunately your class defines Center environemnt that clashes with the ragged2e, so in this case you would have to load it as follows:

\let\clsCenter\Center\let\clsendCenter\endCenter
\let\Center\undefined\let\endCenter\undefined
\usepackage{ragged2e}
\let\Center\clsCenter
\let\endCenter\clsendCenter

You could then issue \RaggedRight just before your \bibliography command. If there is text after the bibliography, you can turn on normal formatting again with the \justifying command.


https://norwied.wordpress.com/2012/07/10/how-to-break-long-urls-in-bibtex/

\usepackage{url}
\def\UrlBreaks{\do\/\do-}
\usepackage{breakurl}
\usepackage[breaklinks]{hyperref}

When using biblatex, this can also be achieved with the block=ragged option, see §3.1.2.1 in http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/biblatex/doc/biblatex.pdf i.e. \usepackage[block=ragged]{biblatex} will do the trick