Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When adding citations in the body of a document I'm used to write

... in some interesting paper~\cite{interesting}.

So that (if I'm using numbered references) the word “paper” and the citation number stick together and do not accidentally end up in two different lines.

It seems, however, that the \citet command from natbib (which should produce something like “Authors [4]”), does not use a ~ between the names of the authors and the citation number so that, on a few rare occasions, I end up with something like

                                                  ... Authors
[4].

Which is annoying. Is there an easy way to make natbib use a non-breaking space there?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Looks like \NAT@spacechar needs to be redefined:

\documentclass{article}

\usepackage[numbers]{natbib}

\makeatletter
% \def\NAT@spacechar{\ }% OLD
\def\NAT@spacechar{~}% NEW
\makeatother

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{a01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
\end{filecontents}

\begin{document}

Let's test if author and citation number end up in different lines: \citet{a01}.

\bibliographystyle{plainnat}
\bibliography{\jobname}

\end{document}
share|improve this answer
    
Thanks! It does the trick. I wonder why this isn't the default behavior of natbib or, at least, there is an option to more easily set this. –  Juan A. Navarro Oct 25 '10 at 15:49
1  
I guess the default behavior was chosen with author-year-citations in mind, where allowing a line break between author and year is acceptable. –  lockstep Oct 25 '10 at 15:58
    
Hey! I realize this is an almost 4 year old question, but I just tried to solve exactly the same line-breaking \citet{} problem, and trying your suggestion did not make any difference. (I inserted the re-definition in the document preamble). Do you have any idea why that might be, or what I might try? –  penelope Jun 24 at 12:48

Since \NAT@spacechar is used, this redefinition prevents such breaks:

\makeatletter
\renewcommand*{\NAT@spacechar}{~}
\makeatother

This could affect also places where a break could be desired. Thus, an easy way for your rare occasions would be to use just \mbox around the citation:

... in the paper \mbox{\citet{interesting}}.
share|improve this answer
1  
Also thanks for the suggestion. However note that the \mbox wont always produce the desired result if the author name contains several words (or there are several authors), as there is nothing wrong with breaking the line between those names. –  Juan A. Navarro Oct 25 '10 at 15:52
    
Stefans suggestion will also prevent hyphenation of author names. –  lockstep Oct 25 '10 at 15:55
    
@Juan @lockstep: that's right! It's just intended to fix the line breaking for such occasions like in the question, where the author isn't hyphenated. Of course, such adjustment should be done at last, when the final version is being produced. This local correction avoids the global effect of changing \NAT@spacechar to be unbreakable. –  Stefan Kottwitz Oct 25 '10 at 16:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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