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.

If I cite a bibliography item with an additional argument, for example \cite[p.~6]{bib_item}, it can happen that there is a line break before the automatically inserted argument, such as:

text text text [4,

p. 6]

or

text text text [5, pp. 11-

13]

Is there a way to prevent this?

share|improve this question
1  
A workaround would be to wrap the \cite command in an \mbox. –  Andrey Vihrov May 13 '11 at 8:52
    
@Andrey I was just going to mention it, but my experiments show that the command \sloppy is often necessary as it tends to exceed the margin. –  Harold Cavendish May 13 '11 at 8:56
    
@Harrold: It's natural that you get overrun lines when you use longer boxes often. But instead of \sloppy I would advise changing the text (adding, deleting or swapping a word or two) so that TeX does not issue warnings. –  Andrey Vihrov May 13 '11 at 8:59
add comment

1 Answer 1

Assuming you're not using any packages redefining \cite & friends, here's a solution. (Andrey Vihrov's comments about \mboxes and \sloppy still apply.)

\documentclass[11pt]{article}

\makeatletter
% \def\@cite#1#2{[{#1\if@tempswa , #2\fi}]}% OLD
\def\@cite#1#2{[{#1\if@tempswa ,~#2\fi}]}% NEW
\makeatother

\begin{document}

Some text that is just long enough to create an unwanted line break \cite[p.~99]{test}.

\begin{thebibliography}{9}
\bibitem{test} A bibitem.
\end{thebibliography}

\end{document}

EDIT: Replaced \penalty\@m\ with ~ in the definition of \@cite.

share|improve this answer
add comment

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.