summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/genmisc/pagereference.tex
blob: 34ebc44c68c08fce3dd914d705176adce5f4e75e (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
%%%%%%%%  PAGEREFERENCE MACROS
%              May 2nd, 1994
% Peter Ungar, 914 723 7187, laxa@acfcluster.nyu.edu
% 109 Lee Road, Scarsdale, N.Y. 10583-5229
%
\long\def\COMMENT#1!E{}
%
% MACROS BEGIN HERE
\newwrite\inpr
\message{Is this the second pass? (y or n)}
\read16 to\answer
\if n\answer\immediate\openout\inpr=\jobname.pgn%
\def\wrx{\write\inpr}%
\def\plbl*#1*{\wrx{\noexpand\let\csname prec#1\endcsname=\folio}}
\def\pref*#1*{XX}
\fi
\if y\answer\closeout\inpr
\input \jobname.pgn
\def\plbl*#1*{}
\def\pref*#1*{\csname prec#1\endcsname}
\fi
% MACROS END HERE

\COMMENT

  We use the macros as follow. Suppose you want to refer to a page
where you say something about Pythagoras.  Put at the place to
which you want to refer
\plbl*pyth* Where you want to refer to this page, put
\pref*pyth* Here, in the place of pyth, one may use any sequence
of small and capital letters. Since the  sequence will end up as
part of a TEX control sequence, digits are unfortunately not
allowed. (If that is very burdensome, we suggest encoding digits
as capitals, A for 1 etc.)  In the second pass, the macros insert
a page number where there is a \pref.
 
  The macro \plbl (pagelabel), as defined when the answer to the
question, Is this the second pass, was n, writes the page number
into the file filename.pgn. To be precise, it creates a new
control sequence, consisting of \prec followed by the letters
identifying the label, which would result in \precpyth in the
example we gave, and sets it equal to the page number. In the
meanwhile, the \pref (page reference) macro is defined to print XX.
  For the second pass, we input the file of labels and the page
numbers they signify which we wrote in the first pass. The
pagenumber recording macro
\plbl is redefined as vacuous, and the page reference macro \pref
is set to insert the page number.

!E 


This is a test of the page reference macro pair,
$\backslash$plbl (pagelabel) and $\backslash$pref (pagereference)
control sequences. There is a pagelabel command, with no effect on
the tpyeset output, just before the period at the end of this
sentence\plbl*aaa*.

Reference to the page label on the next page: p.\pref*bb*;
reference to the pgae label on this page: p.\pref*aaa*.
\vfill
\eject Here is a second pagelabel, just before the
period\plbl*bb*. A reference to the first page label:
p.\pref*aaa*, and a reference to the second page page label:
p.\pref*bb*.

\end