diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/smartref |
Initial commit
Diffstat (limited to 'macros/latex/contrib/smartref')
-rw-r--r-- | macros/latex/contrib/smartref/README | 195 | ||||
-rw-r--r-- | macros/latex/contrib/smartref/byname.sty | 65 | ||||
-rw-r--r-- | macros/latex/contrib/smartref/smartref-doc.pdf | bin | 0 -> 314676 bytes | |||
-rw-r--r-- | macros/latex/contrib/smartref/smartref-doc.tex | 254 | ||||
-rw-r--r-- | macros/latex/contrib/smartref/smartref.sty | 207 |
5 files changed, 721 insertions, 0 deletions
diff --git a/macros/latex/contrib/smartref/README b/macros/latex/contrib/smartref/README new file mode 100644 index 0000000000..08c0714fbc --- /dev/null +++ b/macros/latex/contrib/smartref/README @@ -0,0 +1,195 @@ +Smartref package ReadMe + +===================================================================== + +This package is distributed under the terms of the LaTeX Project +Public License + +===================================================================== + +This is the readme for the LaTeX Package ``smartref'', version 1.82 + +The purpose of this package is to extend the capability of the +the \ref command; precisely, whenever a label is set, this +package records, along with the label, the values of some other +counters (which, can be selected by the user); then, the value of +these counters can be recalled, with a command similar to +\pageref; moreover, this package adds a command (\s<name>ref) for +each counter added, that displays something only if the value of +the <name> counter is changed from when the label is set. For +example, let's say that we are using the `amsbook' class, and we +are numbering theorems within sections; when we want to refer to +a theorem in another section, same chapter, we just say `as in +theorem \ref{zorn}'; but if we want to refer to a theorem in +another chapter, we have to set a label for that chapter and then +say `as in theorem \ref{zorn}, in chapter \ref{chapterofzorn}'; +if we, later on, move the referenced theorem (or the referencing +line) in some other chapter, we might need to update the +references; with this package, there's no need for that: you say, +at the beginning of the document: + + \addtoreflist{chapter} + +and then, every \label is recorded alongside with the chapter in +which it occurred. When we refer to the theorem, we might now say + + theorem \ref{zorn}, chapter \chapterref{zorn} + +if we are sure it will always be in another chapter, or + + theorem \ref{zorn}\schapterref{zorn} + +where the second command prints nothing if the chapter is the same +as the current, or prints `, chap. \chapterref{zorn}' if the chapter +has changed. Since this command sequence is supposed to be used with +quite a frequency, it is not-so-short-handed by \srefchapterref +(\sref<name>ref, in general). + +Here's a complete list of the commands made available by this +package. + +\addtoreflist{<name>} + +This is the first command called: it says that the <name> counter +is to be recorded alongside with all the (following) labels; +please use it BEFORE defining any label, because the result is +unknown if the SmartReference list changes during use (nothing +special should happen, anyhow; it should work correctly). + +The previous command defines a few commands, whose name depends +on the counter chosen. The commands are: + +\sget<name>val{\variable}{foo} + +This command gets the value of counter <name> recorded with label +`foo', and puts this value in the chosen \variable. + +\<name>ref{foo} + +This command prints the value of the counter <name> recorded with +label `foo'. + +\if<name>changed + +`If' construct for the next two commands: + +\is<name>changed{foo} + +Checks whether the <name> counter is changed from value recorded +with `foo', and sets \<name>changed accordingly + +\s<name>ref{foo} + +This command prints nothing if the value of <name> is not +different, but prints `, \short<name>name \<name>ref{foo}' if the +value did change; the \short<name>name should be defined by the +user. It queries by using the previous command. + +\sref<name>ref{foo} + +Equivalent of `\ref{foo}\s<name>ref{foo}'. + + +The only options accepted, as for now, are `chapter' and `part'; + +`chapter' does the following: + +- adds the `chapter' counter to the smart list + +- defines \shortchaptername to be `Cap.' if babel is loaded with +option `italian', `Chap.' otherwise + +- defines \smartref to be \srefchapterref + +`part' does the following: + +- adds the `part' counter to the smart list + +- defines \shortpartname to be `Parte' if babel is loaded with +option `italian', `Part' otherwise + +- defines \smartref to be \srefpartref if previously undefined, +or adds \spartref to previous definition of \smartref (saved in +\nopart@smartref) otherwise (this is mainly to be used after the +option `chapter'). + +As of version 1.6, the package comes with a small style file: + +byname.sty; + +it can be used alone, or within smartref, when the option +`byname' is used; it adds the command + +\byname{<label>} + +that can be used when referencing to a section (subsection, etc) by +name instead of number. As of version 1.8, the same style file also +provides the command \byshortname that does the same as \byname, +except that it uses the "short" name (the one provided in square +brackets). + +Note that the references create by smartref and byname are *not* +hyperlink, when hyperref is active. Maybe in the future ... + +(You can still have "named" links with hyperref using the nameref +style file provided with hyperref itself). + +===================================================================== + +Please send me any bugs, comments, suggestions, hacks, etc etc +etc ... + +Giuseppe Bilotta + +Email: bourbaki@bigfoot.com + +Heartily thanks to James Kilfiger (mapdn@csv.warwick.ac.uk) whose +consulence has been essential (let me say vital) to the birth of +this small package in its first revision (v0.1); it was him who +gave me the idea to hack the \label command, and then encouraged +me to put the newborn code in a package (and telling me how to do +it!); it was also him that pointed out a potential bug in +documents where chapters don't start on a page on their own +(seems that the bug is not present, anyway ...). + +===================================================================== + +TODOs: + +BABEL: instead of \chaptername (for example), this package uses +\shortchaptername, and this is not yet changed by Babel; you can +set it up to your short form of chapter. Please send me the short +names, so that I can implement them. + +Maybe put an option (`long') to make \short<name>name an alias for +\<name>name + +Options: If the option is not recognized, check if it's a counter, +and add it; otherwise, do nothing + +Smartrefs: check for counters that get reset by other counters +(section in chapter, etc); maybe link to the \@addtoreset +internal command ... + +ByName: refine, and add commands to do both references with a single +command + +===================================================================== + +History: + +v0.1 First release (only did chapter and part). +v1.0 First customizable release. +v1.1 Made it work with HyperRef. +v1.5 Added nameref.sty: reference by name. +v1.6 Changed name to byname.sty, because of name conflict with style + file from the HyperRef bundle. +v1.8 Fixed bugs in smartref, changed behaviour for unknown options, + fixed bug in byname that actually prevented it from functioning + properly. +v1.9 Fixed limitation with AMS-LaTeX: would not handle \labels within + equation because AMS-LaTeX redefines the \label command for + equations. + Made \smartref robust. + + diff --git a/macros/latex/contrib/smartref/byname.sty b/macros/latex/contrib/smartref/byname.sty new file mode 100644 index 0000000000..648be4939d --- /dev/null +++ b/macros/latex/contrib/smartref/byname.sty @@ -0,0 +1,65 @@ +\def\fileversion{v1.1} +\def\filedate{2001/07/12} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Giuseppe Bilotta +% +% Phone +39-095-338103 +% +% Email: bourbaki@bigfoot.com +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This package is distributed under the terms +% of the LaTeX Project Public License +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Please read the readme.txt file for details +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{byname}[\filedate\space\fileversion\space Increase +reference capability (reference by name)] +% +\newcommand*{\byn@melabel}[2]{% + \def\@currnamelabel{{#1}{#2}}} + +\let\bns@vesect=\@sect + +\def\@sect#1#2#3#4#5#6[#7]#8{% + \bns@vesect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8}% + \byn@melabel{#7}{#8}} + +\let\bns@vechap=\@chapter +\def\@chapter[#1]#2{% + \bns@vechap[#1]{#2}% + \byn@melabel{#1}{#2}} + +% Hack label: also write the NameRef data ... +\def\newnamelabel{\@newl@bel {name}} +%save previous \label +\AtBeginDocument{\let\nr@ldlabel=\label +\renewcommand*{\label}[1]{\nr@ldlabel{#1}% + \@bsphack% + \protected@write\@auxout{}% + {\string\newnamelabel{#1}{\@currnamelabel}}% + \@esphack}} +% Reference by name +% +\@ifpackageloaded{hyperref}{% + \newcommand*{\byname}[1]{% + \expandafter\real@setref\csname name@#1\endcsname\@secondoftwo{#1}% + } + \newcommand*{\byshortname}[1]{% + \expandafter\real@setref\csname name@#1\endcsname\@firstoftwo{#1}% + } + }{ + \newcommand*{\byname}[1]{% + \expandafter\@setref\csname name@#1\endcsname\@secondoftwo{#1}% + } + \newcommand*{\byshortname}[1]{% + \expandafter\@setref\csname name@#1\endcsname\@firstoftwo{#1}% + } + } +\endinput diff --git a/macros/latex/contrib/smartref/smartref-doc.pdf b/macros/latex/contrib/smartref/smartref-doc.pdf Binary files differnew file mode 100644 index 0000000000..32bef39374 --- /dev/null +++ b/macros/latex/contrib/smartref/smartref-doc.pdf diff --git a/macros/latex/contrib/smartref/smartref-doc.tex b/macros/latex/contrib/smartref/smartref-doc.tex new file mode 100644 index 0000000000..20973999a9 --- /dev/null +++ b/macros/latex/contrib/smartref/smartref-doc.tex @@ -0,0 +1,254 @@ +\documentclass[pagesize=auto, parskip=half, headings=normal]{scrartcl} + +\usepackage{fixltx2e} +\usepackage{etex} +\usepackage{lmodern} +\usepackage[T1]{fontenc} +\usepackage{textcomp} +\usepackage{hologo} +\usepackage{microtype} +\usepackage{hyperref} + +\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} +\newcommand*{\pkg}[1]{\textsf{#1}} +\newcommand*{\cls}[1]{\textsf{#1}} +\newcommand*{\cs}[1]{\texttt{\textbackslash#1}} +\makeatletter +\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}} +\makeatother +\newcommand*{\opt}[1]{\texttt{#1}} +\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle} +\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}} + +\addtokomafont{title}{\rmfamily} + +\title{The \pkg{smartref} package\thanks{This manual corresponds to \pkg{smartref.sty}~v1.9, dated~2002/02/28.}} +\author{Giuseppe Bilotta\thanks{\mail{bourbaki@bigfoot.com}}} +\date{2002/02/28} + + +\begin{document} + +\maketitle + +The purpose of this package is to extend the capability of the +the \cmd{\ref} command; precisely, whenever a label is set, this +package records, along with the label, the values of some other +counters (which, can be selected by the user); then, the value of +these counters can be recalled, with a command similar to +\cmd{\pageref}; moreover, this package adds a command (\cmd{\s\meta{name}ref}) for +each counter added, that displays something only if the value of +the \meta{name} counter is changed from when the label is set. For +example, let's say that we are using the \cls{amsbook} class, and we +are numbering theorems within sections; when we want to refer to +a theorem in another section, same chapter, we just say +`\verb|as in theorem \ref{zorn}|'; but if we want to refer to a theorem in +another chapter, we have to set a label for that chapter and then +say `\verb|as in theorem \ref{zorn}, in chapter \ref{chapterofzorn}|'; +if we, later on, move the referenced theorem (or the referencing +line) in some other chapter, we might need to update the +references; with this package, there's no need for that: you say, +at the beginning of the document: +% +\begin{verbatim} + \addtoreflist{chapter} +\end{verbatim} +% +and then, every \cmd{\label} is recorded alongside with the chapter in +which it occurred. When we refer to the theorem, we might now say +% +\begin{verbatim} + theorem \ref{zorn}, chapter \chapterref{zorn} +\end{verbatim} +% +if we are sure it will always be in another chapter, or +% +\begin{verbatim} + theorem \ref{zorn}\schapterref{zorn} +\end{verbatim} +% +where the second command prints nothing if the chapter is the same +as the current, or prints `\verb|, chap. \chapterref{zorn}|' if the chapter +has changed. Since this command sequence is supposed to be used with +quite a frequency, it is not-so-short-handed by \cmd{\srefchapterref} +(\cmd{\sref\meta{name}ref}, in general). + +Here's a complete list of the commands made available by this +package. +% +\begin{quote} + \cmd{\addtoreflist}\marg{name} +\end{quote} +% +This is the first command called: it says that the \meta{name} counter +is to be recorded alongside with all the (following) labels; +please use it \emph{before} defining any label, because the result is +unknown if the SmartReference list changes during use (nothing +special should happen, anyhow; it should work correctly). + +The previous command defines a few commands, whose name depends +on the counter chosen. The commands are: +% +\begin{quote} + \cmd{\sget\meta{name}val}\texttt{\{}\cs{\meta{variable}}\texttt{\}}\marg{foo} +\end{quote} +% +This command gets the value of counter \meta{name} recorded with label +\meta{foo}, and puts this value in the chosen \cs{\meta{variable}}. + +\begin{quote} + \cs{\meta{name}ref}\marg{foo} +\end{quote} +% +This command prints the value of the counter \meta{name} recorded with +label \meta{foo}. + +\begin{quote} + \cs{if\meta{name}changed} +\end{quote} +% +`If' construct for the next two commands: +% +\begin{quote} + \cmd{\is\meta{name}changed}\marg{foo} +\end{quote} +% +Checks whether the \meta{name} counter is changed from value recorded +with \meta{foo}, and sets \cs{\meta{name}changed} accordingly + +\begin{quote} + \cmd{\s\meta{name}ref}\marg{foo} +\end{quote} +% +This command prints nothing if the value of \meta{name} is not +different, but prints +% +\begin{quote} + \ttfamily + , \cmd{\short\meta{name}name} \cs{\meta{name}ref}\marg{foo} +\end{quote} +% +if the +value did change; the \cmd{\short\meta{name}name} should be defined by the +user. It queries by using the previous command. + +\begin{quote} + \cmd{\sref\meta{name}ref}\marg{foo} +\end{quote} +% +Equivalent of `\cmd{\ref}\marg{foo}\cmd{\s\meta{name}ref}\marg{foo}'. + +\pagebreak[2] + +The only options accepted, as for now, are \opt{chapter} and \opt{part}; +\opt{chapter} does the following: +% +\begin{itemize} +\item adds the \texttt{chapter} counter to the smart list +\item defines \cmd{\shortchaptername} to be `Cap.' if \pkg{babel} is loaded with + option \opt{italian}, `Chap.' otherwise +\item defines \cmd{\smartref} to be \cmd{\srefchapterref} +\end{itemize} + +\opt{part} does the following: +% +\begin{itemize} +\item adds the \texttt{part} counter to the smart list +\item defines \cmd{\shortpartname} to be `Parte' if \pkg{babel} is loaded with + option \opt{italian}, `Part' otherwise +\item defines \cmd{\smartref} to be \cmd{\srefpartref} if previously undefined, + or adds \cmd{\spartref} to previous definition of \cmd{\smartref} (saved in + \cmd{\nopart@smartref}) otherwise (this is mainly to be used after the + option \opt{chapter}). +\end{itemize} + +As of version~1.6, the package comes with a small style file: +% +\begin{quote} + \texttt{byname.sty}; +\end{quote} +% +it can be used alone, or within \pkg{smartref}, when the option +\opt{byname} is used; it adds the command +% +\begin{quote} + \cmd{\byname}\marg{label} +\end{quote} +% +that can be used when referencing to a section (subsection, etc) by +name instead of number. As of version~1.8, the same style file also +provides the command \cmd{\byshortname} that does the same as \cmd{\byname}, +except that it uses the ``short'' name (the one provided in square +brackets). + +Note that the references create by \pkg{smartref} and \pkg{byname} are \emph{not} +hyperlink, when \pkg{hyperref} is active. Maybe in the future \dots + +(You can still have ``named'' links with \pkg{hyperref} using the \pkg{nameref} +style file provided with \pkg{hyperref} itself). + +\medskip\centerline{$***$}\medskip + +Please send me any bugs, comments, suggestions, hacks, etc etc +etc \dots + +Giuseppe Bilotta + +Email: \mail{bourbaki@bigfoot.com} + +Heartily thanks to James Kilfiger (\mail{mapdn@csv.warwick.ac.uk}) whose +consulence has been essential (let me say vital) to the birth of +this small package in its first revision (v0.1); it was him who +gave me the idea to hack the \cmd{\label} command, and then encouraged +me to put the newborn code in a package (and telling me how to do +it!); it was also him that pointed out a potential bug in +documents where chapters don't start on a page on their own +(seems that the bug is not present, anyway \dots). + +\medskip\centerline{$***$} + + +\section*{TODOs:} + +\begin{itemize} +\item \pkg{Babel}: instead of \cmd{\chaptername} (for example), this package uses + \cmd{\short\-chapter\-name}, and this is not yet changed by \pkg{Babel}; you can + set it up to your short form of chapter. Please send me the short + names, so that I can implement them. + +\item Maybe put an option (\opt{long}) to make \cmd{\short\meta{name}name} an alias for + \cs{\meta{name}name} + +\item Options: If the option is not recognized, check if it's a counter, + and add it; otherwise, do nothing + +\item Smartrefs: check for counters that get reset by other counters + (section in chapter, etc); maybe link to the \cmd{\@addtoreset} + internal command \dots + +\item \pkg{ByName}: refine, and add commands to do both references with a single + command +\end{itemize} + +\medskip\centerline{$***$} + + +\section*{History:} + +\begin{labeling}{v1.9} +\item[v0.1] First release (only did chapter and part). +\item[v1.0] First customizable release. +\item[v1.1] Made it work with \pkg{HyperRef}. +\item[v1.5] Added \pkg{nameref.sty}: reference by name. +\item[v1.6] Changed name to \pkg{byname.sty}, because of name conflict with style + file from the \pkg{HyperRef} bundle. +\item[v1.8] Fixed bugs in \pkg{smartref}, changed behaviour for unknown options, + fixed bug in \pkg{byname} that actually prevented it from functioning + properly. +\item[v1.9] Fixed limitation with \hologo{AmSLaTeX}: would not handle \cmd{\labels} within + equation because \hologo{AmSLaTeX} redefines the \cmd{\label} command for + equations.\\ + Made \cmd{\smartref} robust. +\end{labeling} + +\end{document} diff --git a/macros/latex/contrib/smartref/smartref.sty b/macros/latex/contrib/smartref/smartref.sty new file mode 100644 index 0000000000..c8455b9e53 --- /dev/null +++ b/macros/latex/contrib/smartref/smartref.sty @@ -0,0 +1,207 @@ +\def\fileversion{v1.9} +\def\filedate{2002/02/28} +% smartref.sty +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Giuseppe Bilotta +% +% Phone +39 095 338103 +% +% Email: bourbaki@bigfoot.com +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This package is distributed under the terms +% of the LaTeX Project Public License +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Please read the readme.txt file for details +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{smartref}[\filedate\space\fileversion\space Increase +reference capability (deep reference)] +% +\newcounter{@smartlistlen} +\newcounter{less@smartlist} +\setcounter{less@smartlist}{-2} +\newcommand*{\@increasesmartlist}{% + \addtocounter{@smartlistlen}{1}% + \addtocounter{less@smartlist}{1}} +\def\sm@rtreflist{{\@currentlabel}} +\@increasesmartlist +% +\newcommand*{\@getsmartreflist}[3]{% + \ifx#1% + \relax\protect\G@refundefinedtrue% + \@latex@warning {SmartReference `#2' on page % + \thepage \space undefined}% + \nfss@text{\reset@font \bfseries ??}% + \else% + \expandafter #2#1% + \fi} +\newcounter{@currsmartlistplace} +\newcommand*{\@getsmartref}[3]{%Paramaters are: #1: Where #2: Label, #3: place in list + \edef\@smartlistplace{#3}% + \setcounter{@currsmartlistplace}{0}% + \edef\@originalsmartlist{% + \expandafter\@getsmartreflist\csname sr@#2\endcsname{}{}}% + \edef\@currsmartlist{\@originalsmartlist}% + \loop% + \edef\@currsmartvalue{\expandafter\@car\@currsmartlist\@nil}% + \ifnum\the@currsmartlistplace=\theless@smartlist + \edef\@currsmartlist{\noexpand{\expandafter\@cdr\@currsmartlist\@nil\noexpand}}% + \else + \edef\@currsmartlist{\expandafter\@cdr\@currsmartlist\@nil}% + \fi + \ifnum\the@currsmartlistplace<\@smartlistplace% + \addtocounter{@currsmartlistplace}{1}% + \repeat + \edef#1{\@currsmartvalue}% +% \typeout{Got Smart Reference (place #3, value \@currsmartvalue)}% + } +% Hack label: also write the SmartRef data ... +\def\newsmartlabel{\@newl@bel {sr}} +%save previous \label +\AtBeginDocument{% + \let\sr@ldlabel=\label + \renewcommand*{\label}[1]{% + \sr@ldlabel{#1}% + \@bsphack% + \protected@write\@auxout{}% + {\string\newsmartlabel{#1}{\sm@rtreflist}}% + \@esphack}% +% This one is needed for those who use AMS-LaTeX, to ensure that +% smartref labelling system is used wih equations too (AMS-LaTeX +% uses its own labeling system for equations + \let\ltx@label=\label} +% Command to add new items to reflist: +% +\newtoks\sm@rtintern@ltok +\newcommand*{\addtoreflist}[1]{% Add item ... + \@ifundefined{c@#1}% Check if real counter; + {\@nocounterr{#1}}% If not, give error + {\@ifundefined{#1posinlist}{% If yes, check if already defined: + \sm@rtintern@ltok=\expandafter{\sm@rtreflist}% If not, define everything ... + \expandafter\edef\csname sm@rtreflist\endcsname{% + \the\sm@rtintern@ltok{\noexpand\csname the#1\endcsname}}% Add it ... +% Set position of counter in list: + \expandafter\edef\csname #1posinlist\endcsname{\the@smartlistlen}% + \@increasesmartlist% +% Define SmartCommands: +% Define command to get number of <name> for <label>; parameters: +% #1 is where the value goes, #2 is label name. + \typeout{Defining \csname sget#1val\endcsname ...} +% `smart get <name> value' +% Usage \sgetchapternum{\holder}{labelname} + \expandafter\def\csname sget#1val\endcsname##1##2{% + \@ifundefined{sr@##2}{% + \G@refundefinedtrue% + \@latex@warning{SmartReference `##2' on page \thepage \space undefined}% + \def##1{0}}% + {\expandafter\@getsmartref{##1}{##2}{\csname #1posinlist\endcsname}}% + }% +% Define command to check if number of <name> for <label> is different from current +% <name> value; parameters: +% #1 is label name. + \typeout{Defining \csname s#1ref\endcsname ...} +% `smart <name> \ref' +% Usage \schapterref{labelname} +% TODOs: +% - check for counters that get reset. + \expandafter\newif\csname if#1changed\endcsname % define if consctruct + \expandafter\def\csname is#1changed\endcsname##1{% checker for change + \csname sget#1val\endcsname{\sm@rtrefvalue}{##1}% + \edef\@currentrefvalue{\csname the#1\endcsname}% + \ifx\sm@rtrefvalue\@currentrefvalue% + \csname #1changedfalse\endcsname% + \else% + \csname #1changedtrue\endcsname% + \fi}% + \expandafter\def\csname s#1ref\endcsname##1{% + \csname is#1changed\endcsname{##1}% + \csname if#1changed\endcsname% + , \csname short#1name\endcsname~\csname #1ref\endcsname{##1}% +% , \csname short#1name\endcsname~\sm@rtrefvalue% + \else% + \relax% + \fi% + }% +% Define shorthand for \ref{labelname}\s<name>ref{labelname}; parameters: +% #1 is label name. + \typeout{Defining \csname sref#1ref\endcsname ...} +% Usage \srefchapterref{labelname} +% If HyperRef is used, let it use no-link refs +% TODO: define starred and unstarred version; maybe the same for the next. + \@ifpackageloaded{hyperref}{% + \expandafter\def\csname sref#1ref\endcsname##1{% + \@refstar{##1}\csname s#1ref\endcsname{##1}% + } + }{ + \expandafter\def\csname sref#1ref\endcsname##1{% + \ref{##1}\csname s#1ref\endcsname{##1}% + }% + }% +% Define equivalent of \pageref; parameters: +% #1 is label name. + \typeout{Defining \csname #1ref\endcsname ...} +% Usage \chapterref{labelname} + \expandafter\def\csname #1ref\endcsname##1{% + \csname sget#1val\endcsname{\sm@rtrefv@lue}{##1}% + \sm@rtrefv@lue% + }% + }{}% + }% + } +% +\DeclareOption{page}{% + \AtBeginDocument{% + \addtoreflist{page}% + \providecommand*\shortpagename{pag.}% + }} +\DeclareOption{chapter}{% + \AtBeginDocument{% + \addtoreflist{chapter}% + \@ifundefined{smartref}{% + \newcommand*{\smartref}[1]{% + \srefchapterref{#1}% + }% + }{% + \let\nochapter@smartref=\smartref% + \renewcommand*{\smartref}[1]{% + \nochapter@smartref{#1}\schapterref{#1}}% + } + %\DeclareRobustCommand{\smartref}% + \@ifpackagewith{babel}{italian}{% + \providecommand*\shortchaptername{Cap.}}{% + \providecommand*\shortchaptername{Chap.}} + \typeout{Short chapter name defined: \shortchaptername}% + }} +\DeclareOption{part}{% + \AtBeginDocument{% + \addtoreflist{part}% + \@ifundefined{smartref}{% + \newcommand*{\smartref}[1]{% + \srefpartref{#1}% + }% + }{% + \let\nopart@smartref=\smartref% + \renewcommand*{\smartref}[1]{% + \nopart@smartref{#1}\spartref{#1}}% + } + %\DeclareRobustCommand{\smartref}% + \@ifpackagewith{babel}{italian}{% + \providecommand*\shortpartname{Parte}}{% + \providecommand*\shortpartname{Part}}% + \typeout{Short part name defined: \shortpartname}% + }} +\DeclareOption*{% + \PackageWarning{smartref}% + {Option `\CurrentOption' unknown!\MessageBreak% + Adding `\CurrentOption' as a reflevel}% + \expandafter\addtoreflist\expandafter{\CurrentOption} + } +\DeclareOption{byname}{\AtEndOfPackage{\usepackage{byname}}} +\ProcessOptions\relax +\endinput |