Debian Codegraph @

texmf-dist/doc/latex/smartref/README

raw
1 Smartref package ReadMe
2
3 =====================================================================
4
5 This package is distributed under the terms of the LaTeX Project
6 Public License
7
8 =====================================================================
9
10 This is the readme for the LaTeX Package ``smartref'', version 1.82
11
12 The purpose of this package is to extend the capability of the
13 the \ref command; precisely, whenever a label is set, this
14 package records, along with the label, the values of some other
15 counters (which, can be selected by the user); then, the value of
16 these counters can be recalled, with a command similar to
17 \pageref; moreover, this package adds a command (\s<name>ref) for
18 each counter added, that displays something only if the value of
19 the <name> counter is changed from when the label is set. For
20 example, let's say that we are using the `amsbook' class, and we
21 are numbering theorems within sections; when we want to refer to
22 a theorem in another section, same chapter, we just say `as in
23 theorem \ref{zorn}'; but if we want to refer to a theorem in
24 another chapter, we have to set a label for that chapter and then
25 say `as in theorem \ref{zorn}, in chapter \ref{chapterofzorn}';
26 if we, later on, move the referenced theorem (or the referencing
27 line) in some other chapter, we might need to update the
28 references; with this package, there's no need for that: you say,
29 at the beginning of the document:
30
31 \addtoreflist{chapter}
32
33 and then, every \label is recorded alongside with the chapter in
34 which it occurred. When we refer to the theorem, we might now say
35
36 theorem \ref{zorn}, chapter \chapterref{zorn}
37
38 if we are sure it will always be in another chapter, or
39
40 theorem \ref{zorn}\schapterref{zorn}
41
42 where the second command prints nothing if the chapter is the same
43 as the current, or prints `, chap. \chapterref{zorn}' if the chapter
44 has changed. Since this command sequence is supposed to be used with
45 quite a frequency, it is not-so-short-handed by \srefchapterref
46 (\sref<name>ref, in general).
47
48 Here's a complete list of the commands made available by this
49 package.
50
51 \addtoreflist{<name>}
52
53 This is the first command called: it says that the <name> counter
54 is to be recorded alongside with all the (following) labels;
55 please use it BEFORE defining any label, because the result is
56 unknown if the SmartReference list changes during use (nothing
57 special should happen, anyhow; it should work correctly).
58
59 The previous command defines a few commands, whose name depends
60 on the counter chosen. The commands are:
61
62 \sget<name>val{\variable}{foo}
63
64 This command gets the value of counter <name> recorded with label
65 `foo', and puts this value in the chosen \variable.
66
67 \<name>ref{foo}
68
69 This command prints the value of the counter <name> recorded with
70 label `foo'.
71
72 \if<name>changed
73
74 `If' construct for the next two commands:
75
76 \is<name>changed{foo}
77
78 Checks whether the <name> counter is changed from value recorded
79 with `foo', and sets \<name>changed accordingly
80
81 \s<name>ref{foo}
82
83 This command prints nothing if the value of <name> is not
84 different, but prints `, \short<name>name \<name>ref{foo}' if the
85 value did change; the \short<name>name should be defined by the
86 user. It queries by using the previous command.
87
88 \sref<name>ref{foo}
89
90 Equivalent of `\ref{foo}\s<name>ref{foo}'.
91
92
93 The only options accepted, as for now, are `chapter' and `part';
94
95 `chapter' does the following:
96
97 - adds the `chapter' counter to the smart list
98
99 - defines \shortchaptername to be `Cap.' if babel is loaded with
100 option `italian', `Chap.' otherwise
101
102 - defines \smartref to be \srefchapterref
103
104 `part' does the following:
105
106 - adds the `part' counter to the smart list
107
108 - defines \shortpartname to be `Parte' if babel is loaded with
109 option `italian', `Part' otherwise
110
111 - defines \smartref to be \srefpartref if previously undefined,
112 or adds \spartref to previous definition of \smartref (saved in
113 \nopart@smartref) otherwise (this is mainly to be used after the
114 option `chapter').
115
116 As of version 1.6, the package comes with a small style file:
117
118 byname.sty;
119
120 it can be used alone, or within smartref, when the option
121 `byname' is used; it adds the command
122
123 \byname{<label>}
124
125 that can be used when referencing to a section (subsection, etc) by
126 name instead of number. As of version 1.8, the same style file also
127 provides the command \byshortname that does the same as \byname,
128 except that it uses the "short" name (the one provided in square
129 brackets).
130
131 Note that the references create by smartref and byname are *not*
132 hyperlink, when hyperref is active. Maybe in the future ...
133
134 (You can still have "named" links with hyperref using the nameref
135 style file provided with hyperref itself).
136
137 =====================================================================
138
139 Please send me any bugs, comments, suggestions, hacks, etc etc
140 etc ...
141
142 Giuseppe Bilotta
143
144 Email: [email protected]
145
146 Heartily thanks to James Kilfiger ([email protected]) whose
147 consulence has been essential (let me say vital) to the birth of
148 this small package in its first revision (v0.1); it was him who
149 gave me the idea to hack the \label command, and then encouraged
150 me to put the newborn code in a package (and telling me how to do
151 it!); it was also him that pointed out a potential bug in
152 documents where chapters don't start on a page on their own
153 (seems that the bug is not present, anyway ...).
154
155 =====================================================================
156
157 TODOs:
158
159 BABEL: instead of \chaptername (for example), this package uses
160 \shortchaptername, and this is not yet changed by Babel; you can
161 set it up to your short form of chapter. Please send me the short
162 names, so that I can implement them.
163
164 Maybe put an option (`long') to make \short<name>name an alias for
165 \<name>name
166
167 Options: If the option is not recognized, check if it's a counter,
168 and add it; otherwise, do nothing
169
170 Smartrefs: check for counters that get reset by other counters
171 (section in chapter, etc); maybe link to the \@addtoreset
172 internal command ...
173
174 ByName: refine, and add commands to do both references with a single
175 command
176
177 =====================================================================
178
179 History:
180
181 v0.1 First release (only did chapter and part).
182 v1.0 First customizable release.
183 v1.1 Made it work with HyperRef.
184 v1.5 Added nameref.sty: reference by name.
185 v1.6 Changed name to byname.sty, because of name conflict with style
186 file from the HyperRef bundle.
187 v1.8 Fixed bugs in smartref, changed behaviour for unknown options,
188 fixed bug in byname that actually prevented it from functioning
189 properly.
190 v1.9 Fixed limitation with AMS-LaTeX: would not handle \labels within
191 equation because AMS-LaTeX redefines the \label command for
192 equations.
193 Made \smartref robust.
194
195