summaryrefslogtreecommitdiff
path: root/info/examples/tex-in-practice/ts-page2.tip
blob: 974be452c2ee7b36fbb25fcb9e8221450e7114c5 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
% This macro source file is from the four volume series
% "TeX in Practice" by Stephan von Bechtolsheim, published
% 1993 by Springer-Verlag, New York.
% Copyright 1993 Stephan von Bechtolsheim.
% No warranty or liability is assumed.
% This macro may be copied freely if no fees other than
% media cost or shipping charges are charged and as long
% as this copyright and the following source code itself
% is not changed. Please see the series for further information.
%
% Version: 1.0
% Date: May 1, 1993
%
%
% This source code is documented in 30.8.6.3, p. III-571.
% Original source in file "pp1.TEX", starting line 1937.
\wlog{L: "ts-page2.tip" ["pp1.TEX," l. 1937, p. III-571]}%
% This file DOES belong to format "texip."
\InputD{part-cr.tip}
\InputD{rangetst.tip}
\InputD{ts-pager.tip}
\catcode`\@ = 11
\newcount\@PageRefLimitLow
\newcount\@PageRefLimitHigh
\newif\if@CloseByReference
\newcount\@PageCloseRefCount
\newcount\@PageNumberActual
\def\NoSpecialPageRef{%
    \global\@NoSpecialPageReftrue
}
\newif\if@NoSpecialPageRef
\@NoSpecialPageReffalse
\def\@PageRef #1{% 
    \def\@PageRefResult{}%
    \global\@CloseByReferencefalse
    \StepCounter{CloseByReferenceCount}%
    \CounterToRegister{\global\@PageCloseRefCount}%
        {CloseByReferenceCount}%
    \@ref{1}{#1}%
    \if\StringsEqualConditional{\@TheExpandedLabel}{??}%
        \def\@PageRefResult{??}%
    \else
        \if\PrefixConditional
            {\@TheExpandedLabel}%
            {\TheCounter{VolumeNo}-}%
            \DropPrefix{\@TheExpandedLabel}{\TheCounter{VolumeNo}-}%
                       {\@TheShortenedLabel}%
            \def\@PageRefResult{\@TheShortenedLabel}%
            \Label{@READ@-%
                \@ThisLabel-\the\@PageCloseRefCount}%
            \@PageRefLimitLow = \@TheShortenedLabel
            \advance\@PageRefLimitLow by -1
            \@PageRefLimitHigh = \@TheShortenedLabel
            \advance\@PageRefLimitHigh by 1
            \edef\@Ref@Temp@Name{%
                \@LabelRefPrefix @READ@-% 
                \@ThisLabel-\the\@PageCloseRefCount
            }%
            \if\NameDefinedConditional{\@Ref@Temp@Name}%
                \edef\@Ref@Temp@NameTwo{% 
                    \NameUse{\@Ref@Temp@Name}% 
                }%
                \wlog{@READ@: 1 \@Ref@Temp@Name / 
                    \@Ref@Temp@NameTwo}%
                    \edef\@Ref@Temp@NameThree{%
                        \expandafter\PickSecondOfTwo
                            \@Ref@Temp@NameTwo
                    }%
                \wlog{@READ@ 1a: \@Ref@Temp@NameThree}% 
                \DropPrefix
                    {\@Ref@Temp@NameThree}%
                    {\TheCounter{VolumeNo}-}%
                    {\@ResultLocalRef}%
%               \show\@ResultLocalRef
                \@PageNumberActual = \@ResultLocalRef
            \else
                \wlog{@READ@ 2}%
                \@PageNumberActual = \count0
                \@PageRefLimitLow = -10
                \@PageRefLimitHigh = -10
            \fi
            \if\InRangeConditional
                {\@PageNumberActual}%
                {\@PageRefLimitLow}%
                {\@PageRefLimitHigh}%
                \wlog{@READ@ 3}%
                \@CloseByReferencetrue
                \if@NoSpecialPageRef
                    \@CloseByReferencefalse
                \fi
            \else
                \wlog{@READ@ 4}%
                \@CloseByReferencefalse
            \fi
            \global\@NoSpecialPageReffalse
            \if@CloseByReference
                \ifnum\@PageNumberActual = \@PageRefLimitLow
                    \wlog{\string\PageRef: Reference "\@ThisLabel,"
                        on page \the\@PageNumberActual
                        \space refers to the next page.}%
                    \def\@PageRefResult{the next}%
                \fi
                \ifnum\@PageNumberActual = \@TheShortenedLabel
                    \wlog{\string\PageRef: Reference "\@ThisLabel"
                        on page \the\@PageNumberActual
                        \space refers to the current page.}%
                    \def\@PageRefResult{this}%
                \fi
                \ifnum\@PageNumberActual = \@PageRefLimitHigh
                    \wlog{\string\PageRef: Reference "\@ThisLabel"
                        on page \the\@PageNumberActual
                        \space refers to the preceding page.}%
                    \def\@PageRefResult{the previous}%
                \fi
            \fi
        \else
            \def\@PageRefResult{\@TheExpandedLabel}%
        \fi
    \fi
    \edef\@PageRefResult{\@PageRefResult}%
}
\catcode`\@ = 12