TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a package that provides a variant of the \cite command that tolerates arbitrary whitespace? That is, I would like to be able to write something like

\cite{foo, bar, baz}


    foo, bar, baz,
    baf, bah, bam

without any ill effect.

To keep things interesting, it should work flawlessly with other commonly used packages such as cite, natbib, and hyperref, and it should also work without those packages.

Edit: Examples...


    author={Bar Bar},

    author={Foo Foo},



    \cite{foo, bar }.


Here pdflatex test1 works OK but bibtex test1 gives the following error:

White space in argument---line 2 of file test1.aux
 : \citation{foo,bar
 :                   }
I'm skipping whatever remains of this command



    \cite{foo, bar }.


Again, pdflatex test2 works OK but bibtex test2 produces the following error:

White space in argument---line 3 of file test2.aux
 : \citation{bar
 :               }
I'm skipping whatever remains of this command



    \cite{foo, bar }.


This seems to work fine! But naturally it has all the side-effects of the cite package as well, which isn't always compatible with other packages.

share|improve this question
As I recall, the only place it doesn't tolerate whitespace is before the closing }. – TH. Oct 24 '10 at 20:43
@TH.: Thanks, I have never investigated exactly where it tolerates and where it doesn't; I have just noticed that sometimes something fails badly if I have whitespace in \cite. – Jukka Suomela Oct 24 '10 at 21:06
up vote 9 down vote accepted

Sorry if I'm being stupid, but for me the simple answer is: It works if I use the cite package. (This works flawlessly with cite, but it doesn't work without cite ;-).)

share|improve this answer
Gah! I knew there had to be something much simpler! In fact loading either cite or natbib both solve the problem. – Juan A. Navarro Nov 4 '10 at 12:55
Really?? Whitespace problems with \cite and natbib was what actually inspired me to post this question! – Jukka Suomela Nov 4 '10 at 13:27
If you have a minimal example please add it to your question. The small example I tried seems to work fine. – Juan A. Navarro Nov 4 '10 at 13:31
Sure, I have clearly been too lazy with the formulation of the question and doing my homework, I'll try to put together some examples soon. – Jukka Suomela Nov 4 '10 at 13:48
You're right, it doesn't work with natbib. I just changed cite to natbib and ignored all the compilation errors when running for the second time :S. Anyway, I know that my alternative solution is not nice, but at least it does work with natbib. – Juan A. Navarro Nov 4 '10 at 20:32

So I decided to give it a go. The problem seems to be with any spaces after each individual entry and before the , or the closing }. If you can avoid spaces there then that's probably the best thing to do.

If you really insist in being able to have spaces anywhere in the list, then I was able to come up with the following very hackish solution.


Which allows you then to write

\Cite{  paper1  ,  paper2,  paper3  }

The short explanation is that \@strip will take two arguments: a command name (\@args in the example) and some arbitrary argument. It will then strip away all spaces in the argument and store the result in the command you provided, then you can use \@args as a valid argument of, say, \cite.

Of course, if you use natbib or other packages for citations you will have to define corresponding macros such as \Citet and \Citep with appropriate interfaces (e.g. optional arguments, etc.).

I really hope someone could come up with something better/easier.

share|improve this answer

Your Answer


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.