18

I'm using the memoir and biblatex packages together. In general, I'm very happy with both. However, in my bibliography, I get some overflows and I don't have any clue how to avoid them... are there packages / commands / settings / tricks to achieve a nice looking bibliography and avoid overflows as depicted below? I know that latex does its best about type setting, but maybe there are some pitfalls I'm not aware of. Thank you!

enter image description hereenter image description here

UPDATE Using the block=ragged option avoids overflows, but also omits the text justification I like so much :-) (see next figure) So unfortunately, this is not an alternative.

enter image description here

  • 2
    Perhaps put DOI and ISBN numbers on a line of their own? – Bernard Aug 11 '14 at 18:15
  • 3
    Well, there are three (bad) options: go \sloppy, go \raggedright or allow linebreaks inside DOI. – yo' Aug 11 '14 at 18:16
  • 2
    btw, did I mention \usepackage{microtype} ? It's a must-have in these borderline cases. – yo' Aug 11 '14 at 18:32
  • 4
    Microtype affects the whole document by default (usually for the better). – jon Aug 11 '14 at 19:19
  • 2
    You can also try \begingroup \setlength{\emergencystretch}{4em} \printbibliography \endgroup. Credits to egreg (I think!). – sudosensei Aug 12 '14 at 0:13
9

As mentioned in the comments, microtype is your friend here, and produces nicer output for the rest of the document as well.

Because all of these options depend on your reference list/reference style/margin settings/font choices (which we do not have), I've listed a few options and compared them using a sample text (\lipsum) and sample reference list biblatex-examples.bib which should be included on any system with biblatex installed.

In addition to microtype, I'd recommend a setting for biblatex's block= option. cgnieder suggested block=ragged, but I think this will be not acceptable for you given the update to your question. I've included it for future visitors, though. :-)

I think block=space would look closer to your ideal output. It allows extra space to be inserted between "blocks" in the bibliography, which can alleviate would-be line-breaking problems.

Another option could be \RaggedRight from ragged2e, which enables hyphenation without full justification, but this didn't look the greatest either considering your dissatisfaction with the block=ragged option. But again, this is highly dependent on the text/font/margins, so I've included it as an option for future visitors to try.

MWE

Here's the base test MWE I used to compare the settings:

\documentclass[draft]{memoir} % `draft' to show overfull \hboxes
\usepackage{lipsum}
%\usepackage{ragged2e}
\usepackage[final]{microtype} % `final' to prevent disabling
\usepackage[
  backend=biber, % default, but avoids warnings
  block=space,   % allow additional horizontal space between blocks
%  block=ragged,  % set the bibliography ragged right and introduce a line break penalty
]{biblatex}
\addbibresource{biblatex-examples.bib} % bunch of sample entries

\begin{document}
\lipsum    % print the sample text
\nocite{*} % print all references in the bibliography

%\raggedright
%\Raggedright
\printbibliography
\end{document}

Spoiler alert: the "best" (IMHO and for my test input/references) combination is shown in the sample above.

Comparison

I've left out anything that's "too ragged" (except for the default result) based on your update above. From "worst" to "best":

  • Default configuration; no \raggedright, no \RaggedRight, no microtype, default block=none: 14 bad boxes, worst 26.46pt too wide enter image description here
  • Add microtype with default settings: 4 bad boxes, worst 8.09pt too wide
  • Add block=space in addition to microtype: 1 bad box, 1.12pt too wide enter image description here

I've shown the worst offender in the screenshots, but line breaks around long DOI/URL-like strings were also vastly improved. Two examples:

Before: enter image description here enter image description here After: enter image description here enter image description here

Notes

If for some reason you really want microtype enabled only in the bibliography (though I'd recommend to just use it throughout the document), you can use \microtypesetup{disable} and \microtypesetup{enable} at the appropriate places in your document, as detailed in this answer. These keys are still undocumented, but you can find the code in lines 4118–4128 of the current (v2.5a) package code (p. 125 of the v2.5a documentation).

  • Well, I wouldn't say I »recommend« block=ragged. »suggest« is maybe a better word... A ragged bibliography avoids nearly all bad boxes and the bibliography is much more readable than with justification. (But that's only my personal opinion :) – clemens Aug 15 '14 at 16:28
  • Fair enough @cgnieder; I'll update my word choice. :-) – Paul Gessler Aug 15 '14 at 16:33
  • 1
    block=space does the trick for me, thanks! – crwang Dec 31 '16 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.