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.

Say I want to cite a range of authors like this:

[3-11]

When I write \cite{bibitem3-bibitem11} then it does not compile in LaTeX, so I write \cite{bibitem3,bibitem4,...,bibitem11}. But this is very big and not nice. How I should do the range of citations?

share|improve this question
    
Welcome to tex.SE Narek. I’ve added some formatting to your otherwise excellent question. Feel free to look at the source code of the question (there’s a little “edit” link below the question which lets you look at the code) to see how to apply these formattings yourself. –  Konrad Rudolph Jan 28 '11 at 11:36
add comment

1 Answer 1

up vote 4 down vote accepted

You should not name your references bibitemn, but use a short but meaningful key, like author + year. There is no real nice way to avoid long \cite{...} calls in your text. There are no packages I know of for this case, because no one uses that naming scheme.

If you really want to do it you could use a for loop for it, e.g. the one provided by pgffor. It allows the use of ... to define ranges. See the pgf manual for the full syntax:

\documentclass{article}

\usepackage{pgffor}
\makeatletter
\newcommand*\rcite[1]{%
    \def\@gtempa{}%
    \foreach \n in {#1} {%
        \edef\@tempa{,bibitem\n}%
        \expandafter\g@addto@macro\expandafter\@gtempa
        \expandafter{\@tempa}%
    }%
    \edef\@gtempa{{\expandafter\@gobble\@gtempa}}%
    \expandafter\cite\@gtempa
}
\makeatother

\begin{document}

% 3-10
\rcite{3,...,10}

% 2, 5-10
\rcite{2,5,6,...,10}

% 3, 5, 7, 9
\rcite{3,5,...,10}

\end{document}
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.