% Copyright (C) 1999 René Seindal (rene@seindal.dk) % This program can redistributed and/or modified under the terms % of the LaTeX Project Public License Distributed from CTAN % archives in directory macros/latex/base/lppl.txt; either % version 1 of the License, or (at your option) any later version. %% Macros for citing. \let\@DEBUG@CIT\@gobble %\let\@DEBUG@CIT\typeout %% \@PG does #1={a} -> {p.~a} %% and #1={a-} -> {pp.~a~ff} %% and #1={a-b} -> {pp.~a--b} %% and #1={a b} -> {pp.~a b} \def\@PG#1{% \@DEBUG@CIT{START: #1}% {\@@PG#1 \@nil}% } \newcommand\pages[2][\@gobble]{#1{, }\@PG{#2}} \def\@@PG#1 #2\@nil{% \def\@tempa{#1}% \def\@tempb{#2}% \ifx\@tempb\@empty \def\next{\@PGrange#1-\@nil}% \else \let\next\@PGspace \fi \next } %% argument is "a-b"; tmpa="X" tmpb=void \def\@PGrange#1-#2\@nil{\hbox{% \@DEBUG@CIT{RANGE: =#1=#2=}% \def\@tempb{#2}% \ifx\@tempb\@empty p.~#1% \else pp.~#1% \edef\@tempb{\@PGundash#2}% \ifx\@tempb\@empty ff% \else --\@tempb \fi \fi }} \def\@PGundash#1-{#1} %% argument is "a b"; tmpa="a" tmpb="b " \def\@PGspace{% \@DEBUG@CIT{SPACE: =\@tempa=\@tempb=}% \ifx\@tempb\@empty \else p% \fi p.~\expandafter\@PGdash\@tempa-\@nil% \expandafter\@PGdashloop\@tempb\@nil% } %% argument is "b"; tmpa="a" tmpb="b " \def\@PGdashloop#1 #2\@nil{% \@DEBUG@CIT{TEST: =#1=#2=}% \space\@PGdash#1-\@nil% \def\@tempa{#2}% \ifx\@tempa\@empty \else \@PGdashloop#2\@nil% \fi } \def\@PGdash#1-#2\@nil{\hbox{#1% \@DEBUG@CIT{DASH: =#1=#2=}% \def\@tempa{#2}% \ifx\@tempa\@empty \else \edef\@tempa{\@PGundash#2}% \ifx\@tempa\@empty ff% \else --\@tempa \fi \fi }}