# How to force citations within text width

I am using the named bibliography style with the following citation formulation provided by karlkoeller:

\makeatletter
\let\@internalcite\cite
\def\cite{\def\citeauthoryear##1##2{##1, ##2}\@internalcite}
\def\shortcite{\def\citeauthoryear##1##2{##2}\@internalcite}
\def\@biblabel#1{\def\citeauthoryear##1##2{##1, ##2}[#1]\hfill}
\makeatother


While this formulation produces the desired style, it is printing a large number of citation beyond the text width, into the margin space:

Is there a way to force these citations remaining within the text body?

• You can use \sloppy, but \linebreak[3] at the front of \cite might work better. If you had provided an NWE I would run some tests. – John Kormylo Aug 28 '15 at 16:16
• \sloppy does it, \linebreak[3] has no effect; please insert this as an answer. P.S.: You can use the MWE provided by karlkoeller to test. – Luís de Sousa Aug 29 '15 at 14:28

Normally, \hfil will expand as much as \parendskip, but \hfil\linebreak[3] doesn't seem to expand at all.

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Book{Batty:2007,
author    = {Michael Batty},
title     = {Cities and Complexity},
publisher = {MIT Press},
year      = 2007}
\end{filecontents*}

\makeatletter
\let\@internalcite\cite
\def\cite{\def\citeauthoryear##1##2{##1, ##2}\@internalcite}
\def\shortcite{\def\citeauthoryear##1##2{##2}\@internalcite}
\def\@biblabel#1{\def\citeauthoryear##1##2{##1, ##2}[#1]\hfill}
\makeatother

\begin{document}
\sloppy