| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- %From: reingold@emr.cs.uiuc.edu (Edward M. Reingold)
- %Newsgroups: comp.text.tex
- %Subject: Re: short form references like [1-4]
- %Date: 26 Mar 91 22:44:32 GMT
- %Organization: University of Illinois at Urbana-Champaign
- %
- %In article <880@imec.UUCP> symons@imec.be (Jan Symons) writes:
- %
- % with LaTeX, the \cite{key1,key2,key3,key4} puts a [1,2,3,4] reference
- % in the text. However, what I want to see is more like [1-4].
- %
- % Can somebody please explain how this can be achieved with LaTeX ?
- %
- %
- %Here is rangecite.sty that we cobbled together for just this purpose:
- %
- %-----------------------------rangecite.sty---------------------------------
- % RANGECITE DOCUMENT-STYLE OPTION FOR ANY STYLE WITH NUMERIC CITATIONS
- %
- % This redefines the LaTex \@cite macro to gather consecutive citation numbers
- % i,i+1,...,j into a range i-j
- %
- % Nachum Dershowitz (nachum@cs.uiuc.edu)
- % Edward M. Reingold (reingold@cs.uiuc.edu)
- %
- % These macros are in the public domain. You may use them and copy them at
- % will, provided you retain the authorship information. We wrote these for
- % temporary use in a single paper, so use them at your own risk!
- %
- % Written 12 Apr 1990
- %
- %
- \newif\if@first%
- \newcounter{@@@first}%
- \newcounter{@@@state}%
- %
- % A simple four-state finite automaton:
- % State 0: No references in current range
- % State 1: One reference in current range
- % State 2: Two references in current range
- % State 3: More than two references in current range
- %
- \newcounter{@@@next}%
- \newcounter{@@@cur}%
- \newcounter{@@@curt}%
- \newcommand{\b@@@ENDLIST}{9999}%
- \def\@citex[#1]#2{%
- \if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi%
- \def\@citea{}%
- \@cite{%
- \@firsttrue%
- \setcounter{@@@state}{0}%
- \@for\@citeb:=#2,@@ENDLIST\do{%
- \@ifundefined{b@\@citeb}%
- {{\bf ?}%
- \@warning{Citation `\@citeb' on page \thepage \space undefined}}%
- % else%
- {\setcounter{@@@next}{\csname b@\@citeb\endcsname}%
- \ifcase\the@@@state%
- % state 0:
- \setcounter{@@@state}{1}%
- \or% state 1:
- \ifnum\value{@@@next}=\value{@@@curt}%
- \setcounter{@@@state}{2}%
- \setcounter{@@@first}{\value{@@@cur}}%
- \else%
- \if@first{}\else{,\ }\fi%
- \the@@@cur%
- \@firstfalse%
- \fi%
- \or% state 2:
- \ifnum\value{@@@next}=\value{@@@curt}%
- \setcounter{@@@state}{3}%
- \else%
- \setcounter{@@@state}{1}%
- \if@first{}\else{,\ }\fi%
- \the@@@first,\ \the@@@cur%
- \@firstfalse%
- \fi%
- \or% state 3:
- \ifnum\value{@@@next}=\value{@@@curt}%
- \else%
- \setcounter{@@@state}{1}%
- \if@first{}\else{,\ }\fi%
- \the@@@first-\the@@@cur%
- \@firstfalse%
- \fi%
- \fi%
- \setcounter{@@@cur}{\value{@@@next}}%
- \setcounter{@@@curt}{\value{@@@cur}}%
- \addtocounter{@@@curt}{1}}}}%
- {#1}}%
|