BibTeX, biblatex and biberWrong break in Bibliography

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
antonio314159
Posts: 2
Joined: Fri May 08, 2020 6:51 pm

Wrong break in Bibliography

Post by antonio314159 »

Hi everyone.

I am writing my master thesis using overleaf. My problem is in the bibliography section since some entries are causing overfull \hbox. Do you know how to fix this?

I am using biblatex with these specifications:

\usepackage{hyperref}
\hypersetup{colorlinks,citecolor={black},urlcolor={black}}

\usepackage{csquotes}
\PassOptionsToPackage{
natbib=true,
style=authoryear-comp,
hyperref=true,
backend=biber,
giveninits=true,
uniquename=init,
maxcitenames=2,
parentracker=true,
url=true,
doi=true,
isbn=true,
eprint=true,
backref=true,
} {biblatex}
\usepackage{biblatex}
\DeclareNameAlias{sortname}{family-given}



% mit "month" and "language" from Bibliography
\AtEveryBibitem{%
\clearfield{month}{}%
\clearlist{language}{}%
}

% some natbib backwards compatibility
\let\citealp\cite
\let\cite\textcite

% increase vertical space between bibliography items.
\setlength\bibitemsep{0.5ex}
\setlength\bibnamesep{1.2ex}

% Comma before and after journal volume. Thanks to lockstep.
\renewbibmacro*{volume+number+eid}{%
\setunit*{\addcomma\space}% NEW
\printfield{volume}%
\printfield{number}%
\printfield{eid}}
\DeclareFieldFormat[article]{number}{(#1)}% number of a journal

% Citation Hyperlinks (not just years), thanks to Audrey.
\makeatletter
\renewbibmacro*{cite}{% Based on cite bib macro from authoryear-comp.cbx
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\printtext[bibhyperref]{% Include labelname in hyperlink
\DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
\usebibmacro{cite:label}%
\setunit{\addspace}%
\usebibmacro{cite:labelyear+extrayear}}%
\usebibmacro{cite:reinit}}
{\iffieldequals{namehash}{\cbx@lasthash}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma}%
\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{labelyear}{\cbx@lastyear}}}
{\printtext[bibhyperref]{% Include labelname in hyperlink
\DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
\printnames{labelname}%
\setunit{\nameyeardelim}%
\usebibmacro{cite:labelyear+extrayear}}%
\savefield{namehash}{\cbx@lasthash}%
\savefield{labelyear}{\cbx@lastyear}}}}
{\usebibmacro{cite:shorthand}%
\usebibmacro{cite:reinit}}%
\setunit{\multicitedelim}}

\renewbibmacro*{textcite}{% Based on textcite bib macro from authoryear-comp.cbx
\iffieldequals{namehash}{\cbx@lasthash}
{\iffieldundef{shorthand}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma}%
\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:labelyear+extrayear}%
\savefield{labelyear}{\cbx@lastyear}}}
{\setunit{\compcitedelim}%
\usebibmacro{cite:shorthand}%
\global\undef\cbx@lastyear}}
{\ifnameundef{labelname}
{\printtext[bibhyperref]{% Include labelname in hyperlink
\DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\addspace\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labelyear+extrayear}}
{\usebibmacro{cite:shorthand}}%
\ifthenelse{\iffieldundef{postnote}\AND
\(\value{multicitetotal}=0\AND\value{citetotal}=1\)}
{\bibcloseparen% Include closing parenthesis in hyperlink
\global\boolfalse{cbx:parens}}
{}}}
{\printtext[bibhyperref]{% Include labelname in hyperlink
\DeclareFieldAlias{bibhyperref}{default}% Prevent nested hyperlinks
\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\addspace\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\iffieldundef{shorthand}
{\iffieldundef{labelyear}
{\usebibmacro{cite:label}}
{\usebibmacro{cite:labelyear+extrayear}}%
\savefield{labelyear}{\cbx@lastyear}}
{\usebibmacro{cite:shorthand}%
\global\undef\cbx@lastyear}%
\ifthenelse{\iffieldundef{postnote}\AND
\(\value{multicitetotal}=0\AND\value{citetotal}=1\)}
{\bibcloseparen% Include closing parenthesis in hyperlink
\global\boolfalse{cbx:parens}}
{}}%
\savefield{namehash}{\cbx@lasthash}}}%
\setunit{%
\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}%
\multicitedelim}}

\makeatother

% Backrefs "cited" instead of "cit"
\DefineBibliographyStrings{english}{%
backrefpage={cited on p\adddot},
backrefpages={cited on pp\adddot}
}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Wrong break in Bibliography

Post by Bartman »

The source code is more pleasant to read, if you use the BBCode for code blocks.

Somewhere in your bibliography there is at least one entry where the line break does not work and the content towers over the margin.

Try to create a minimal as possible example that shows the entry or entries in the bibliography.
antonio314159
Posts: 2
Joined: Fri May 08, 2020 6:51 pm

Wrong break in Bibliography

Post by antonio314159 »

Hello! Thanks for your answer and sorry for the code!

This is one of my entries in my .bib file where the text goes beyond the margins.

Code: Select all

@article{Kazemi_2015, 
    title={Modeling downstream petroleum supply chain: The importance of multi-mode transportation to strategic planning}, 
    volume={83},
    url={http://dx.doi.org/10.1016/j.tre.2015.09.004},
    DOI={10.1016/j.tre.2015.09.004},
    journal={Transportation Research Part E: Logistics and Transportation Review}, 
    publisher={Elsevier BV}, 
    author={Kazemi, Yasaman and Szmerekovsky, Joseph},
    year={2015}, 
    month={Nov}, 
    pages={111–125} 
    }
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Wrong break in Bibliography

Post by Bartman »

Without a Infominimal working example you can only guess. If the word petroleum causes the problem, you can use the commands \hyphenation, \babelhyphenation (babel) or \DefineHyphenationExceptions (biblatex) to specify the hyphenation in the preamble yourself.

The hyphenated compound word multi-mode is unlikely to be the cause because of its central position in the line. On the other hand, such words are a possible cause of problems and should therefore be treated with babel shorthands.
Post Reply