83

When I use the \cite command for my citations, often LaTeX will overflow the margins for my lines, and the text looks pretty bad. How can I make LaTeX push long citations to the next line automatically?

2
  • Here's a reference to the same question in 2004, but I don't get the answer tug.org/pipermail/tugindia/2004-September/002975.html
    – Noli
    Sep 5, 2010 at 23:01
  • The email to the Tugindia mailing list links to the TeX FAQ, but this yielded the error message, "This site can’t be reached. Check if there is a typo in www.tex.ac.uk. DNS_PROBE_FINISHED_NXDOMAIN." Aug 22, 2023 at 1:08

6 Answers 6

107

Without a minimal example (i.e., code that will show the problematic behaviour), one can only speculate. However, I've stumbled over this problem in the past, and it may (!) help if you add the following to your preamble:

\usepackage{breakcites}

See the breakcites page at CTAN for details. If it doesn't help, you'll have to provide a minimal example that (above all) shows your document class and your bibliography style.

4
  • 5
    You saved my day.
    – DGoiko
    Jul 15, 2018 at 23:14
  • 2
    You've just halved the number of my overfull \hboxes. Thank you.
    – Martino
    Nov 3, 2018 at 12:25
  • Awesome (6 more to go) May 22, 2019 at 15:58
  • god in sky u in earth Nov 19, 2019 at 7:13
45

The "general solution" for overfull boxes in paragraph mode runs as follows:

  1. Rewrite your text. Seriously. In some cases, this can be the only way to achieve "perfect" typesetting.

  2. Enable the microtype package. Surprisingly enough, this package reduces many occurrences of overfull lines.

  3. Wrap the paragraph with \begin{sloppypar}...\end{sloppypar}. This relaxes LaTeX's rules for how much interword space is acceptable; you'll get less "grey" paragraph, but at least it will stay within its margins.

  4. Finally, if this happens a lot, you can enable \sloppy for the entire document. With this mode in effect, well-typeset paragraphs will (almost almost always) remain just as well typeset, but "bad" paragraphs such as you're talking about will behave as if they were wrapped with sloppypar. I tend not to recommend this route as it can make you lazier about good typesetting—but depending on your document this is not necessarily a bad thing.

5
  • 2
    +1 for microtype, -1 for sloppypar and \sloppy (for me, this is only the last resort).
    – 0x6d64
    Aug 25, 2011 at 7:10
  • 1
    What do you suggest besides microtype+rewriting? I suppose playing with other paragraph settings might get you what you want, but I doubt it would be any better than sloppypar. Note that sloppypar on an already good paragraph will not reduce its quality. Aug 25, 2011 at 8:06
  • microtpe did the trick without more intervention! Feb 24, 2020 at 6:04
  • microtype works for me
    – lenhhoxung
    Jun 3, 2020 at 9:56
  • sloppy works for me
    – kurtkim
    Nov 14, 2023 at 14:40
16

In order to split citation you must add both these packages, otherwise the citation will not properly split.

\usepackage[breaklinks=true]{hyperref}
\usepackage{breakcites}
2
  • 1
    Welcome to TeX.SE. How does your answer differ materially from the one posted by @lockstep? Note that the original posting made no reference to the hyperref package being loaded; it may thus not be a good recommendation to suggest including \usepackage[breaklinks=true]{hyperref}.
    – Mico
    Jan 5, 2014 at 16:22
  • 2
    Although @Mico is right in his comment, this actually solved my problem. +1!
    – astabada
    Apr 15, 2014 at 10:37
4

Just use following command on your LaTeX file

\usepackage{cite}

if you are using LaTeX2e

1
  • 2
    You mean "Just use the cite package.". Also everyone should use LaTeX2e. LaTeX2 is outdated since ages and LaTeX3 isn't around yet. Apr 27, 2011 at 11:24
0

If you are using hyperref, it may help to put breaklinks=true in the options, e.g. \usepackage[breaklinks=true]{hyperref}.

I found this suggested here: [http://www.latex-community.org/forum/viewtopic.php?f=47&t=5455]

1
  • 4
    If the driver does not support breaklinks, then the link area will be messed up. breaklinks is already enabled by default for drivers that support this feature. Sep 10, 2013 at 16:38
0

I don't mean for this to be an answer, though it worked in my case and that is why I'm putting it here - in the odd chance it is helpful to someone else. I tried all these suggestions and I suppose I could have drastically reworded the paragraph but it was best as it was. It had two citations like this: \cite{citation1,citation2} and the second one (though order didn't appear to matter) always ran off into the margin in the bibliography. I finally wound up just putting \penalty-10000 inside the JabRef bib source file where I wanted the break - disappointing way of solving it for sure! Feel free to remove this if people do not think it is helpful.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .