I need a way to get to display three first words of the title in citations and if some words did not get displayed add dots. I am using Biblatex.

\nfirstwords[3]{I Like Apples and Oranges}{\dots}
\nfirstwords[3]{I Like Apples}{\dots}

Would give:

I Like Apples...
I Like Apples
  • 3
    Maybe this can be done with xstring.
    – N.N.
    Nov 24, 2011 at 7:12
  • xstring looks good, but I have not managed to compare \ StrCount output with a constant in a conditional.
    – Andres
    Nov 27, 2011 at 16:33

2 Answers 2


If you are using biber, you can do this while reading the .bib file by using this biber.conf file:

<?xml version="1.0" encoding="UTF-8"?>
    <maps datatype="bibtex" map_overwrite="1">
        <map_step map_field_source="TITLE"

Note that this is the biber 0.9.8 config file format for which you'll need to be using the biber 0.9.8 beta. Obviously there are all sorts of regular expressions you could use to do this, the above is just an example.

  • I can not rely on availability of biber for now and will use the other solution. Still thanks.
    – Andres
    Nov 30, 2011 at 10:14

It might be tricky for arbitrary n, but if you know beforehand that you need 3 words (and that the string will not contain \\, although this is easily changed by substituting another control sequence in the following code), this MWE should do the trick:


\usepackage{etoolbox}% I need \ifblank to put \dots if something nonblank gets deleted


\def\@threefirstwords #1 #2 #3 #4\\#5{%
  #1 #2 #3\ifblank{#4}{}{#5}%
\edef\threefirstwords#1#2{\noexpand\@threefirstwords #1\space\space\space\noexpand\\{#2}}



\threefirstwords{This is a test}{\dots}

\threefirstwords{This is a}{\dots}

\threefirstwords{This is}{\dots}



Ah, and this seems to have nothing to do with biblatex or even bibliographies.

  • 1
    You're welcome. Notice that you might want to accept some answer (and to be sincere, the other one seems better to me, although it is biber-specific) as the "best" one. Also, you might want to look at my blog (link in my profile), where I elaborated a bit more on this solution.
    – mbork
    Nov 28, 2011 at 0:21
  • 1
    the original version seems to produce extra spaces when less than three words are present. Trial-and-error to rescue: \def\@threefirstwords #1 #2 #3 #4\\#5{% \ifblank{#1}{}{#1}\ifblank{#2}{}{ #2}\ifblank{#3}{}{ #3}\ifblank{#4}{}{#5}} \edef\threefirstwords#1#2{\noexpand\@threefirstwords#1\space\space\space\noexpand\\{#2}}
    – Andres
    Jan 14, 2012 at 19:36

You must log in to answer this question.

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