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.

How do I put a non-breaking space inside a \cite macro with several citations? \cite{ref1,~ref2} causes an error. If I leave the space out, one is inserted and this is causing the citation to span two lines. I am using bibstyle plain.

share|improve this question
    
Why do you want an unbreakable space after a comma? A comma at the end of a line is a perfect position for a line break! –  Marc van Dongen Jan 25 '12 at 0:35
    
I am using bibstyle plain and I end up with [1, 2,\n 3, 4] which looks bad. –  jaybee Jan 25 '12 at 10:16
    
@jaybee: well, when you have 4 references in one bracket (which is generally correct), I suggest to leave it as is, i.e. [1, 2,\n 3, 4], because the bracket is long and the lines would be too empty/full. The only other possibility is to re-phrase the text slightly, but this should be done in the final version. –  tohecz Jan 25 '12 at 23:38

3 Answers 3

up vote 6 down vote accepted

If it is an isolated thing (i.e. you need to do it once in your document), put \hbox{\cite{ref1, ref2}}

share|improve this answer

have you tried the option [space] with the package cite ?

share|improve this answer
4  
This is more of a question/comment than an answer. –  qubyte Jan 24 '12 at 10:59
    
@MarkS.Everitt On the other hand, it is somehow an answer (and probably a correct answer), just written down with a question mark in the end... –  tohecz Jan 25 '12 at 23:39
    
@tohecz: It's rude to answer a question with a question. ;) –  qubyte Jan 26 '12 at 1:53

Assuming you don't use any packages that modify \cite & friends, a general solution is to change the definition of \@citex, namely, to replace the breakable space (accompanied by a penalty of 1000) with a non-breakable space. (Note: For convenience, I'm using the etoolbox package to do so.)

\documentclass{article}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@citex}{%
  ,\penalty\@m\ %
}{%
  ,~%
}
\makeatother

\begin{document}

XXXXXXX XXXXXXX XXXXXXX XXXXXXX XXXXXXX XXiiiiiii \cite{x,y}.

\begin{thebibliography}{9}
\bibitem{x} A bibitem.

\bibitem{y} Another bibitem.
\end{thebibliography}

\end{document}
share|improve this answer

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.