summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/inlinebib/pageranges.sty
blob: 97fa9603340073760a4270ba8f1325064d306bfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
% 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
}}