| 1 |
\documentclass[pagesize=auto, parskip=half, headings=normal]{scrartcl} |
| 2 |
|
| 3 |
\usepackage{fixltx2e} |
| 4 |
\usepackage{etex} |
| 5 |
\usepackage{lmodern} |
| 6 |
\usepackage[T1]{fontenc} |
| 7 |
\usepackage{textcomp} |
| 8 |
\usepackage{hologo} |
| 9 |
\usepackage{microtype} |
| 10 |
\usepackage{hyperref} |
| 11 |
|
| 12 |
\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} |
| 13 |
\newcommand*{\pkg}[1]{\textsf{#1}} |
| 14 |
\newcommand*{\cls}[1]{\textsf{#1}} |
| 15 |
\newcommand*{\cs}[1]{\texttt{\textbackslash#1}} |
| 16 |
\makeatletter |
| 17 |
\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}} |
| 18 |
\makeatother |
| 19 |
\newcommand*{\opt}[1]{\texttt{#1}} |
| 20 |
\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle} |
| 21 |
\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}} |
| 22 |
|
| 23 |
\addtokomafont{title}{\rmfamily} |
| 24 |
|
| 25 |
\title{The \pkg{smartref} package\thanks{This manual corresponds to \pkg{smartref.sty}~v1.9, dated~2002/02/28.}} |
| 26 |
\author{Giuseppe Bilotta\thanks{\mail{[email protected]}}} |
| 27 |
\date{2002/02/28} |
| 28 |
|
| 29 |
|
| 30 |
\begin{document} |
| 31 |
|
| 32 |
\maketitle |
| 33 |
|
| 34 |
The purpose of this package is to extend the capability of the |
| 35 |
the \cmd{\ref} command; precisely, whenever a label is set, this |
| 36 |
package records, along with the label, the values of some other |
| 37 |
counters (which, can be selected by the user); then, the value of |
| 38 |
these counters can be recalled, with a command similar to |
| 39 |
\cmd{\pageref}; moreover, this package adds a command (\cmd{\s\meta{name}ref}) for |
| 40 |
each counter added, that displays something only if the value of |
| 41 |
the \meta{name} counter is changed from when the label is set. For |
| 42 |
example, let's say that we are using the \cls{amsbook} class, and we |
| 43 |
are numbering theorems within sections; when we want to refer to |
| 44 |
a theorem in another section, same chapter, we just say |
| 45 |
`\verb|as in theorem \ref{zorn}|'; but if we want to refer to a theorem in |
| 46 |
another chapter, we have to set a label for that chapter and then |
| 47 |
say `\verb|as in theorem \ref{zorn}, in chapter \ref{chapterofzorn}|'; |
| 48 |
if we, later on, move the referenced theorem (or the referencing |
| 49 |
line) in some other chapter, we might need to update the |
| 50 |
references; with this package, there's no need for that: you say, |
| 51 |
at the beginning of the document: |
| 52 |
% |
| 53 |
\begin{verbatim} |
| 54 |
\addtoreflist{chapter} |
| 55 |
\end{verbatim} |
| 56 |
% |
| 57 |
and then, every \cmd{\label} is recorded alongside with the chapter in |
| 58 |
which it occurred. When we refer to the theorem, we might now say |
| 59 |
% |
| 60 |
\begin{verbatim} |
| 61 |
theorem \ref{zorn}, chapter \chapterref{zorn} |
| 62 |
\end{verbatim} |
| 63 |
% |
| 64 |
if we are sure it will always be in another chapter, or |
| 65 |
% |
| 66 |
\begin{verbatim} |
| 67 |
theorem \ref{zorn}\schapterref{zorn} |
| 68 |
\end{verbatim} |
| 69 |
% |
| 70 |
where the second command prints nothing if the chapter is the same |
| 71 |
as the current, or prints `\verb|, chap. \chapterref{zorn}|' if the chapter |
| 72 |
has changed. Since this command sequence is supposed to be used with |
| 73 |
quite a frequency, it is not-so-short-handed by \cmd{\srefchapterref} |
| 74 |
(\cmd{\sref\meta{name}ref}, in general). |
| 75 |
|
| 76 |
Here's a complete list of the commands made available by this |
| 77 |
package. |
| 78 |
% |
| 79 |
\begin{quote} |
| 80 |
\cmd{\addtoreflist}\marg{name} |
| 81 |
\end{quote} |
| 82 |
% |
| 83 |
This is the first command called: it says that the \meta{name} counter |
| 84 |
is to be recorded alongside with all the (following) labels; |
| 85 |
please use it \emph{before} defining any label, because the result is |
| 86 |
unknown if the SmartReference list changes during use (nothing |
| 87 |
special should happen, anyhow; it should work correctly). |
| 88 |
|
| 89 |
The previous command defines a few commands, whose name depends |
| 90 |
on the counter chosen. The commands are: |
| 91 |
% |
| 92 |
\begin{quote} |
| 93 |
\cmd{\sget\meta{name}val}\texttt{\{}\cs{\meta{variable}}\texttt{\}}\marg{foo} |
| 94 |
\end{quote} |
| 95 |
% |
| 96 |
This command gets the value of counter \meta{name} recorded with label |
| 97 |
\meta{foo}, and puts this value in the chosen \cs{\meta{variable}}. |
| 98 |
|
| 99 |
\begin{quote} |
| 100 |
\cs{\meta{name}ref}\marg{foo} |
| 101 |
\end{quote} |
| 102 |
% |
| 103 |
This command prints the value of the counter \meta{name} recorded with |
| 104 |
label \meta{foo}. |
| 105 |
|
| 106 |
\begin{quote} |
| 107 |
\cs{if\meta{name}changed} |
| 108 |
\end{quote} |
| 109 |
% |
| 110 |
`If' construct for the next two commands: |
| 111 |
% |
| 112 |
\begin{quote} |
| 113 |
\cmd{\is\meta{name}changed}\marg{foo} |
| 114 |
\end{quote} |
| 115 |
% |
| 116 |
Checks whether the \meta{name} counter is changed from value recorded |
| 117 |
with \meta{foo}, and sets \cs{\meta{name}changed} accordingly |
| 118 |
|
| 119 |
\begin{quote} |
| 120 |
\cmd{\s\meta{name}ref}\marg{foo} |
| 121 |
\end{quote} |
| 122 |
% |
| 123 |
This command prints nothing if the value of \meta{name} is not |
| 124 |
different, but prints |
| 125 |
% |
| 126 |
\begin{quote} |
| 127 |
\ttfamily |
| 128 |
, \cmd{\short\meta{name}name} \cs{\meta{name}ref}\marg{foo} |
| 129 |
\end{quote} |
| 130 |
% |
| 131 |
if the |
| 132 |
value did change; the \cmd{\short\meta{name}name} should be defined by the |
| 133 |
user. It queries by using the previous command. |
| 134 |
|
| 135 |
\begin{quote} |
| 136 |
\cmd{\sref\meta{name}ref}\marg{foo} |
| 137 |
\end{quote} |
| 138 |
% |
| 139 |
Equivalent of `\cmd{\ref}\marg{foo}\cmd{\s\meta{name}ref}\marg{foo}'. |
| 140 |
|
| 141 |
\pagebreak[2] |
| 142 |
|
| 143 |
The only options accepted, as for now, are \opt{chapter} and \opt{part}; |
| 144 |
\opt{chapter} does the following: |
| 145 |
% |
| 146 |
\begin{itemize} |
| 147 |
\item adds the \texttt{chapter} counter to the smart list |
| 148 |
\item defines \cmd{\shortchaptername} to be `Cap.' if \pkg{babel} is loaded with |
| 149 |
option \opt{italian}, `Chap.' otherwise |
| 150 |
\item defines \cmd{\smartref} to be \cmd{\srefchapterref} |
| 151 |
\end{itemize} |
| 152 |
|
| 153 |
\opt{part} does the following: |
| 154 |
% |
| 155 |
\begin{itemize} |
| 156 |
\item adds the \texttt{part} counter to the smart list |
| 157 |
\item defines \cmd{\shortpartname} to be `Parte' if \pkg{babel} is loaded with |
| 158 |
option \opt{italian}, `Part' otherwise |
| 159 |
\item defines \cmd{\smartref} to be \cmd{\srefpartref} if previously undefined, |
| 160 |
or adds \cmd{\spartref} to previous definition of \cmd{\smartref} (saved in |
| 161 |
\cmd{\nopart@smartref}) otherwise (this is mainly to be used after the |
| 162 |
option \opt{chapter}). |
| 163 |
\end{itemize} |
| 164 |
|
| 165 |
As of version~1.6, the package comes with a small style file: |
| 166 |
% |
| 167 |
\begin{quote} |
| 168 |
\texttt{byname.sty}; |
| 169 |
\end{quote} |
| 170 |
% |
| 171 |
it can be used alone, or within \pkg{smartref}, when the option |
| 172 |
\opt{byname} is used; it adds the command |
| 173 |
% |
| 174 |
\begin{quote} |
| 175 |
\cmd{\byname}\marg{label} |
| 176 |
\end{quote} |
| 177 |
% |
| 178 |
that can be used when referencing to a section (subsection, etc) by |
| 179 |
name instead of number. As of version~1.8, the same style file also |
| 180 |
provides the command \cmd{\byshortname} that does the same as \cmd{\byname}, |
| 181 |
except that it uses the ``short'' name (the one provided in square |
| 182 |
brackets). |
| 183 |
|
| 184 |
Note that the references create by \pkg{smartref} and \pkg{byname} are \emph{not} |
| 185 |
hyperlink, when \pkg{hyperref} is active. Maybe in the future \dots |
| 186 |
|
| 187 |
(You can still have ``named'' links with \pkg{hyperref} using the \pkg{nameref} |
| 188 |
style file provided with \pkg{hyperref} itself). |
| 189 |
|
| 190 |
\medskip\centerline{$***$}\medskip |
| 191 |
|
| 192 |
Please send me any bugs, comments, suggestions, hacks, etc etc |
| 193 |
etc \dots |
| 194 |
|
| 195 |
Giuseppe Bilotta |
| 196 |
|
| 197 |
Email: \mail{[email protected]} |
| 198 |
|
| 199 |
Heartily thanks to James Kilfiger (\mail{[email protected]}) whose |
| 200 |
consulence has been essential (let me say vital) to the birth of |
| 201 |
this small package in its first revision (v0.1); it was him who |
| 202 |
gave me the idea to hack the \cmd{\label} command, and then encouraged |
| 203 |
me to put the newborn code in a package (and telling me how to do |
| 204 |
it!); it was also him that pointed out a potential bug in |
| 205 |
documents where chapters don't start on a page on their own |
| 206 |
(seems that the bug is not present, anyway \dots). |
| 207 |
|
| 208 |
\medskip\centerline{$***$} |
| 209 |
|
| 210 |
|
| 211 |
\section*{TODOs:} |
| 212 |
|
| 213 |
\begin{itemize} |
| 214 |
\item \pkg{Babel}: instead of \cmd{\chaptername} (for example), this package uses |
| 215 |
\cmd{\short\-chapter\-name}, and this is not yet changed by \pkg{Babel}; you can |
| 216 |
set it up to your short form of chapter. Please send me the short |
| 217 |
names, so that I can implement them. |
| 218 |
|
| 219 |
\item Maybe put an option (\opt{long}) to make \cmd{\short\meta{name}name} an alias for |
| 220 |
\cs{\meta{name}name} |
| 221 |
|
| 222 |
\item Options: If the option is not recognized, check if it's a counter, |
| 223 |
and add it; otherwise, do nothing |
| 224 |
|
| 225 |
\item Smartrefs: check for counters that get reset by other counters |
| 226 |
(section in chapter, etc); maybe link to the \cmd{\@addtoreset} |
| 227 |
internal command \dots |
| 228 |
|
| 229 |
\item \pkg{ByName}: refine, and add commands to do both references with a single |
| 230 |
command |
| 231 |
\end{itemize} |
| 232 |
|
| 233 |
\medskip\centerline{$***$} |
| 234 |
|
| 235 |
|
| 236 |
\section*{History:} |
| 237 |
|
| 238 |
\begin{labeling}{v1.9} |
| 239 |
\item[v0.1] First release (only did chapter and part). |
| 240 |
\item[v1.0] First customizable release. |
| 241 |
\item[v1.1] Made it work with \pkg{HyperRef}. |
| 242 |
\item[v1.5] Added \pkg{nameref.sty}: reference by name. |
| 243 |
\item[v1.6] Changed name to \pkg{byname.sty}, because of name conflict with style |
| 244 |
file from the \pkg{HyperRef} bundle. |
| 245 |
\item[v1.8] Fixed bugs in \pkg{smartref}, changed behaviour for unknown options, |
| 246 |
fixed bug in \pkg{byname} that actually prevented it from functioning |
| 247 |
properly. |
| 248 |
\item[v1.9] Fixed limitation with \hologo{AmSLaTeX}: would not handle \cmd{\labels} within |
| 249 |
equation because \hologo{AmSLaTeX} redefines the \cmd{\label} command for |
| 250 |
equations.\\ |
| 251 |
Made \cmd{\smartref} robust. |
| 252 |
\end{labeling} |
| 253 |
|
| 254 |
\end{document} |