summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-11 23:57:02 +0000
committerKarl Berry <karl@freefriends.org>2006-01-11 23:57:02 +0000
commitffa9540a4a1b8e87b0e2370e3ec707989696e3b1 (patch)
tree8ea6721e8a53ac298e987fbd2bcd992b2ee4ad48
parente6d8f281838bc08716be98e144177106349156b3 (diff)
trunk/Master/texmf-dist/source/latex/refstyle
git-svn-id: svn://tug.org/texlive/trunk@486 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/source/latex/refstyle/refstyle.dtx1906
-rw-r--r--Master/texmf-dist/source/latex/refstyle/refstyle.ins70
2 files changed, 1976 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/refstyle/refstyle.dtx b/Master/texmf-dist/source/latex/refstyle/refstyle.dtx
new file mode 100644
index 00000000000..5a539c3d058
--- /dev/null
+++ b/Master/texmf-dist/source/latex/refstyle/refstyle.dtx
@@ -0,0 +1,1906 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2003 by Danie Els <dnjels@sun.ac.za>
+% --------------------------------------------------
+%
+% This file may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.2
+% of this license or (at your option) any later version.
+% The latest version of this license is in:
+%
+% http://www.latex-project.org/lppl.txt
+%
+% and version 1.2 or later is part of all distributions of LaTeX
+% version 1999/12/01 or later.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\RequirePackage{ifpdf}
+\ifpdf
+ \documentclass[a4paper,pdftex]{ltxdoc}
+\else
+ \documentclass[a4paper,dvips]{ltxdoc}
+\fi
+\usepackage{amsmath}
+\usepackage{amsfonts}
+ \DeclareMathSymbol{\square} {\mathord}{AMSa}{"03}
+ \DeclareMathSymbol{\blacksquare}{\mathord}{AMSa}{"04}
+\usepackage{calc}
+\usepackage{xspace}
+\usepackage{framed}
+\usepackage{rotating}
+\usepackage[rounded]{syntax}
+\usepackage{varioref}
+\usepackage{refstyle}
+\usepackage{color}
+\usepackage{hyperref}
+\hypersetup{breaklinks=true,
+ a4paper=true,
+ colorlinks=true,
+ linkcolor=blue,
+ citecolor=blue,
+ pdftitle={refstyle},
+ pdfauthor={Danie Els}}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\setlength\hfuzz{15pt}
+\hbadness=7000
+\begin{document}
+ \DocInput{refstyle.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{507}
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+% \changes{v0.0}{2002/12/01}{Initial version}
+% \changes{v0.1}{2003/04/01}{First stable version}
+%
+% \DoNotIndex{
+% \@backslashchar, \@carcube, \@ehc, \@empty, \@firstoftwo,
+% \@ifnextchar, \@ifpackageloaded, \@ifstar, \@ifundefined, \@nil,
+% \@qend, \@qrelax, \@secondoftwo, \@tempa, \@undefined,
+% \AtEndOfPackage, \begingroup, \csname, \CurrentOption,
+% \DeclareOption, \def, \edef, \else, \endcsname, \endgroup,
+% \expandafter, \fi, \gdef, \iffalse, \ifx, \InputIfFileExists,
+% \let, \long, \lowercase, \MakeLowercase, \mbox, \MessageBreak,
+% \NeedsTeXFormat, \newcommand, \newif, \noexpand, \PackageError, \PackageInfo,
+% \PassOptionsToPackage, \RS@pkgname, \ProcessOptions, \protect,
+% \providecommand, \ProvidesPackage, \relax, \renewcommand,
+% \RequirePackage, \reserved@a, \reserved@b, \RS@tmpa,
+% \RS@tmpb, \S, \setkeys, \space, \string, \textsc, \textup,
+% \unrestored@protected@xdef, \unskip, \uppercase,
+% \zap@space}
+%
+%^^A=== macrocode env changes =============================
+% \setlength{\MacroIndent}{1.5em}
+%
+%^^A=== Framed.sty setup ==================================
+% \FrameSep = 1\fboxsep
+% \definecolor{shadecolor}{gray}{0.9}
+% \newenvironment{RSframed}{\shaded}{\endshaded}
+%
+%^^A==== Scratches ========================================
+% \newlength{\tdima}
+% \newsavebox{\tboxa}
+%
+%^^A==== Spacing ==========================================
+% \newlength{\myskip}
+% \setlength{\myskip}{\topsep}
+% \addtolength{\myskip}{\parskip}
+% \addtolength{\myskip}{\partopsep}
+% \newcommand*{\blankline}{\par\addvspace{\myskip}}
+% \newlength{\mytab}
+% \setlength{\mytab}{2\parindent}
+% \newcommand{\tab}{\hspace*{\mytab}}
+%
+%^^A==== Indented environments ============================
+% \newenvironment{IndentPara}[1][1]
+% {\list{}{\setlength{\leftmargin}{#1\mytab}^^A
+% \setlength{\labelwidth}{0pt}^^A
+% \setlength{\labelsep}{0pt}^^A
+% \setlength{\itemindent}{\parindent}^^A
+% \setlength{\listparindent}{\parindent}^^A
+% }\item[]}^^A
+% {\endlist}
+% \newenvironment{IndentParaX}[1][1]
+% {\list{}{\setlength{\leftmargin}{#1\mytab}^^A
+% \setlength{\topsep}{0pt}^^A
+% \setlength{\partopsep}{0pt}^^A
+% \setlength{\labelwidth}{0pt}^^A
+% \setlength{\labelsep}{0pt}^^A
+% \setlength{\itemindent}{\parindent}^^A
+% \setlength{\listparindent}{\parindent}^^A
+% }\item[]}^^A
+% {\endlist}
+% \newcommand\bNP{\begin{IndentParaX}}
+% \newcommand\eNP{\end{IndentParaX}}
+% \newenvironment{Ipara}[1][\small]^^A
+% {\begin{IndentPara}\noindent#1\ignorespaces}^^A
+% {\end{IndentPara}}
+% \newenvironment{Itabb}[1][\small]^^A
+% {\begin{IndentPara}#1\ignorespaces\begin{tabbing}\ignorespaces}^^A
+% {\end{tabbing}\end{IndentPara}}
+%
+%^^A==== Ruled & colored minipage =========================
+% \newenvironment{fminipage}[1][\linewidth]
+% {\setlength{\tdima}{#1-2\fboxsep-2\fboxrule}^^A
+% \begin{lrbox}{\tboxa}\begin{minipage}{\tdima}}^^A
+% {\end{minipage}\end{lrbox}\noindent\fbox{\usebox{\tboxa}}}
+% \newenvironment{cminipage}[1][\linewidth]
+% {\setlength{\tdima}{#1-2\fboxsep-2\fboxrule}^^A
+% \begin{lrbox}{\tboxa}\begin{minipage}{\tdima}}^^A
+% {\end{minipage}\end{lrbox}^^A
+% \noindent\colorbox{shadecolor}{\usebox{\tboxa}}}
+%
+%^^A==== Additional documenting commands ==================
+% \def\lcbrack{\symbol{`\{}}
+% \def\rcbrack{\symbol{`\}}}
+% \makeatletter
+% \def\meta@font@select{\normalfont\slshape}
+% \makeatother
+% \DeclareRobustCommand{\cmeta}[1]{^^A<- \<xxx>
+% \texttt{\bslash}\meta{#1}}
+% \DeclareRobustCommand{\cmarg}[1]{^^A<- {\<xxx>}
+% \texttt{\lcbrack}\cmeta{#1}\texttt{\rcbrack}}
+% \DeclareRobustCommand{\coarg}[1]{^^A<- [\<xxx>]
+% \texttt{[}\cmeta{#1}\texttt{]}}
+% \DeclareRobustCommand{\argcmd}[2]{^^A<- \<xxx>yyy
+% \cmeta{#1}\texttt{#2}}
+% \newcommand{\rmeta}[3][]{^^A
+% \texttt{\lcbrack#1}\meta{#2}\texttt{#3\rcbrack}}
+% \newcommand{\refmeta}[3][]{\cmd{\brref}\rmeta[#1]{#2}{#3}}
+%
+% \newcommand*{\file}[1]{\texttt{#1}}
+% \newcommand*{\pkg}[1]{\textsf{#1}}
+% \newcommand*{\env}[1]{\texttt{#1}}
+% \newcommand*{\opt}[1]{\texorpdfstring{\normalfont\texttt{\slshape#1}}{#1}}
+% \newcommand*{\RS}{\pkg{refstyle}\xspace}
+% \newcommand*{\rtp}{type}
+% \newcommand*{\Rtp}{Type}
+% \newcommand*{\okeylst}{\oarg{key\_lst}}
+% \newcommand*{\mkeylst}{\marg{key\_lst}}
+%
+%^^A==== Special eq tag command =================================
+% \def\spestag#1{\stepcounter{equation}^^A
+% \gdef\tagextra##1{^^A
+% \makebox[0pt][l]{\small\quad^^A
+% \cmd{\eqlabel}\texttt{\lcbrack##1\rcbrack}}^^A
+% \gdef\tagextra####1{}}^^A
+% \tag{\theequation\tagextra{#1}}\eqlabel{#1}}
+%
+%^^A==== other stuff =================================
+%
+% \newcommand*{\ArTab}{\>\quad$\rightarrow$\quad}
+%
+%^^A==== Titling ==========================================
+% \GetFileInfo{refstyle.sty}
+% \title{\vskip -2em
+% The \RS\ package\thanks{This file has version number
+% \fileversion, last revised
+% \filedate.}}
+% \author{Danie Els\thanks{^^A
+% Any help with proof reading of this document will be appreciated.}\\[1ex]
+% \small Department of Mechanical Engineering\\
+% \small University of Stellenbosch, South Africa.\\
+% \normalsize e-mail: \texttt{\href{mailto:dnjels@sun.ac.za}%
+% {dnjels@sun.ac.za}}}
+% \date{\filedate}
+% \maketitle
+% \begin{center}
+% \textbf{Overview of the \RS\ package}
+% \end{center}
+% \noindent
+% When writing complex documents, often a large number of commands
+% for different type of references are defined, for example:
+% \begin{Ipara}
+% |\newcommand*{\eqref}[1]{eqn~(\ref{#1})}|\\
+% |\newcommand*{\Eqref}[1]{Equation~(\ref{#1})}|
+% \end{Ipara}
+% The \RS package was developed to automate this process. The
+% package provides a user interface to define sets of reference
+% and label commands for each referable object such as an equation
+% or a table, etc. When you declare, for example, a set of
+% reference commands to an equation:
+% \begin{Ipara}
+% \cmd{\newref}|{eq}|\mkeylst\
+% \end{Ipara}
+% \noindent
+% a series of commands of the format \cmd{\eq...} and \cmd{\Eq...}
+% are produced. The configuration options are set with a list of
+% key-values. Prefixes, inserts and other options for all the
+% different perturbations such as capitalized first letters,
+% singular and plural from, etc.\ can be defined. The
+% configuration can be changed temporarily with an optional list
+% of key-values when the commands are used. A direct interface to
+% the \pkg{varioref} package is also provided.
+% This enables compact reference formats:
+% \begin{Itabb}
+% \hspace{14em}\=\kill
+% |\eqref{e1} ...| \ArTab\eqref{e1} ...\\
+% |\Eqref[vref]{e1} ...| \ArTab\Eqref[vref]{e1} ...\\
+% |\eqref[s]{e1} and ...| \ArTab\eqref[s]{e1} and ...\\
+% |\eqref[name=eq.~]{e1} ...| \ArTab\eqref[name=eq.~]{e1} ...
+% \end{Itabb}
+% A range or a list of references can also be referred to in a
+% consistent way.
+% \begin{Itabb}
+% \hspace{14em}\=\kill
+% |\eqref{e1,e2,e3} ...| \ArTab\eqref{e1,e2,e3} ...\\
+% |\eqrangeref[vref]{e1}{e3} ...| \ArTab\eqrangeref[vref]{e1}{e3} ...
+% \end{Itabb}
+%
+% Templates for the different reference types and different
+% languages can be loaded with a configuring file.
+%
+% The package is aimed at large projects, enabling a consistent
+% way of producing references throughout a project. Enough
+% flexibility is provided to make local changes to a single
+% reference. For large projects such as a series of books or a
+% multi volume thesis, written as freestanding documents, a
+% facility is provided to interface to the \pkg{xr} package for
+% external document references.
+%
+% \clearpage
+%
+% \tableofcontents
+% \clearpage
+%
+%
+% \section{Loading the \RS Package}
+%
+% The \RS package is loaded in the preamble of the document:
+% \begin{enumerate}
+% \item[(a)]
+% With a default configuration file \file{refstyle.cfg}.
+% \begin{Ipara}
+% |\usepackage{varioref}[2001/09/04]%|~
+% ${\leftarrow}$ To use the \opt{vref} option\\
+% |\usepackage{refstyle}|
+% \end{Ipara}
+% The default config file provided with this package contains
+% interfaces to \pkg{babel} for language changes.
+% A sample configuration file, \file{reftmpl.cfg}, is provided in
+% \secref{templates}. It can be generated by running
+% \file{refstyle.dtx} through \pkg{docstrip} with the
+% \opt{<tmpl>} option. Modify \file{reftmpl.cfg} according
+% to your requirements and place it in a directory where
+% \TeX\ can find it.
+%
+% \item[(b)]
+% Or with your own configuration file for a specific project:
+% \begin{Itabb}
+% |\usepackage[noconfig]{refstyle}|\\
+% |\input{thisproject.ref}|
+% \end{Itabb}
+%
+% \item[(c)]
+% Or without any configuration file, but by declaring your own
+% reference commands in the preamble.
+% \begin{Itabb}
+% \cmd{\usepackage}|[noconfig]{refstyle}|\\
+% \qquad\cmd{\newref}\marg{reftype$_{\,1}$}\mkeylst \\
+% \qquad\cmd{\newref}\marg{reftype$_{\,2}$}\mkeylst\\
+% \tab$\vdots$
+% \end{Itabb}
+%
+% \end{enumerate}
+%
+%
+% \subsection{Companion packages}
+%
+% The \RS packages is intended for large projects. It is therefore
+% important that it works together with, or has direct interfaces
+% to the following packages:
+% \begin{description}
+% \item[\pkg{varioref}:\footnotemark]
+% \footnotetext{\pkg{varioref} v1.3c, 2001/09/04 or later,
+% because the starred versions of the commands
+% are used.}
+% Produce sophisticated page and page range references.
+%
+% \item[\pkg{hyperref}:\footnotemark]
+% \footnotetext{\pkg{hyperref} v6.72r, 2002/05/27 or later,
+% where a bug for interference with
+% \pkg{varioref} was fixed.}
+% To establish hyper links between the references and the
+% labels.
+%
+% \item[\pkg{xr}:]
+% To establish references to external documents.
+%
+% \item[\pkg{showkeys}:]
+% To show all the labels and references. This is very useful
+% to find labels in large documents.
+% \end{description}
+%
+% \pagebreak
+% \section{User Interface}
+%
+% The \RS package has one configuring command, \DescribeMacro{\newref}
+% \cmd{\newref}, that internally creates a series of label and
+% reference commands:
+% \blankline
+%
+% \begin{cminipage}[\linewidth]
+% \newcommand*{\crsi}{\smash{\rule[0pt]{.4pt}{1.25em}\rule[.5ex]{1.5em}{.4pt}}}^^A
+% \newcommand*{\crsl}{\smash{\rule[.5ex]{.4pt}{1.5em}\rule[.5ex]{1.5em}{.4pt}}}^^A
+% \begin{Itabb}
+% \hspace*{2em}\=\hspace{2em}\=\kill
+% \cmd{\newref}\marg{\rtp}\mkeylst\tab\mbox{}\\[.75ex]
+% \>\crsi \>\argcmd{{\rtp}}{key}\\[.75ex]
+% \>\crsl \>\argcmd{{\rtp}}{label}\\[.75ex]
+% \>\crsl \>\argcmd{{\rtp}}{ref}\\[.75ex]
+% \>\crsl \>\argcmd{{\Rtp}}{ref}\\[.75ex]
+% \>\crsl \>\argcmd{{\rtp}}{rangeref}\\[.75ex]
+% \>\crsl \>\argcmd{{\Rtp}}{rangeref}\\[.75ex]
+% \>\crsl \>\argcmd{{\rtp}}{pageref}
+% \end{Itabb}
+% \end{cminipage}
+% \blankline
+%
+% \noindent
+% All the \cmeta{\rtp}... commands, excluding \argcmd{{\rtp}}{key},
+% are robust.
+% All the options for the referencing commands are set with a
+% key-value list. \Tabref[vref=far]{refopt} gives a full list of all the
+% key-values and defaults.
+%
+% The \RS package do not redefine any internal \LaTeX\ commands and
+% depends only on the \cmd{\label}, \cmd{\ref}, \cmd{\pageref} and
+% the \pkg{varioref} commands.
+% The internally defined commands do not overwrite any
+% existing command with the same name, and an error results if a command
+% already exists. The exception is commands declared with a previous
+% \cmd{\newref} call, can be redefined by calling \cmd{\newref} again
+% with a new set of parameter.
+% If the \pkg{amsmath} package is loaded, and you define
+% \cmd{\newref}|{eq}| for references to equations, you need to
+% undefine \cmd{\eqref} before issuing \cmd{\newref} by
+% \begin{Ipara}
+% \cmd{\let}\cmd{\eqref}|=|\cmd{\relax}
+% \end{Ipara}
+%
+%
+% \section{Command Descriptions}
+%
+% The structure of the label and reference commands is given by the
+% syntax diagrams that follows. Examples are included for references
+% to equations, defined according to the template in
+% \secref{EqTempl} with the
+% \cmd{\newref}|{eq}|\mkeylst. See also \secref{keyvals} for
+% explanations of the key-values.
+%
+% \subsection{The reference key}
+%
+% \begin{cminipage}[\linewidth]
+% \begin{syntdiag}
+% \tok{\argcmd{\rtp}{key}}
+% \end{syntdiag}
+% \end{cminipage}
+% \blankline
+% \noindent
+% The \argcmd{\rtp}{key} command returns the prefix added to the
+% argument of the label and the reference commands, for example:
+%
+% \begin{Itabb}
+% \hspace{10em}\=hspace{5em}\=\kill
+% \cmd{\newref}\marg{\rtp}|{}|
+% \>\>\argcmd{\rtp}{key} $\rightarrow$ \meta{type\,:\,}\\
+% \cmd{\newref}\marg{\rtp}|{key=xxx-}|
+% \>\>\argcmd{\rtp}{key} $\rightarrow$ |xxx-|
+% \end{Itabb}
+%
+% \noindent
+% The \argcmd{\rtp}{key} command is not a general command, but was
+% provided only as a link to the standard \LaTeX{} \cmd{\ref} and
+% \cmd{\pageref} commands:
+%
+% \begin{Itabb}
+% \hspace{10em}\=hspace{5em}\=\kill
+% \cmd{\label}|{|\argcmd{\rtp}{key}| abc}|
+% \>\>~ $\rightarrow$ \cmd{\label}\rmeta{type\,:\,}{abc}\\
+% \cmd{\ref}|{|\argcmd{\rtp}{key}| abc}|
+% \>\>~ $\rightarrow$ \cmd{\ref}\rmeta{type\,:\,}{abc}
+% \end{Itabb}
+% \blankline
+% \noindent
+% \textbf{\slshape Examples:} equations
+% with \cmd{\newref}|{eq}|\mkeylst:
+%
+% \begin{Itabb}
+% \hspace*{18em}\=\kill
+% |\eqkey| \> \eqkey \\
+% |in eq.~\ref{\eqkey e1} ...| \>in eq.~\ref{\eqkey e1} ... \\
+% |on page \pageref{\eqkey e1} ...|\>on page \pageref{\eqkey e1} ... \\
+% |\vpageref*{\eqkey e1} ... | \>\vpageref*{\eqkey e1} ...
+% \end{Itabb}
+%
+% \subsection{Reference label}
+%
+% \begin{cminipage}[\linewidth]
+% \begin{syntdiag}
+% \tok{\argcmd{\rtp}{label}}
+% \begin{stack}\\ \tok{\okeylst} \end{stack}
+% \tok{"{"<lbl>"}"}
+% \end{syntdiag}
+% \end{cminipage}
+% \blankline
+%
+% \noindent
+% The command \argcmd{\rtp}{label} prefix the reference
+% string in the \cmd{\label} with the string \meta{type\,:\,}, or its
+% redefinition with the \opt{key} option.
+%
+% \begin{Itabb}
+% \hspace{10em}\=hspace{5em}\=\kill
+% \argcmd{\rtp}{label}|{abc}|
+% \>\>~ $\rightarrow$ \cmd{\label}\rmeta{type\,:\,}{abc}\\
+% \argcmd{\rtp}{label}\texttt{[\opt{key}=xxx:]}|{abc}|
+% \>\>~ $\rightarrow$ \cmd{\label}|{xxx:abc}|
+% \end{Itabb}
+% \blankline
+%
+% \noindent
+% \textbf{\slshape Examples:}
+%
+% \begingroup
+% \begin{Ipara}
+% Let $z = x+\mathrm{i} y$ and $\alpha = \beta + \mathrm{i}
+% \gamma$, with $\mathrm{i}^2 = -1$, then
+% \begin{align}
+% &\mathrm{e}^z = \mathrm{e}^x \left(\cos y + \mathrm{i} \sin y \right)
+% \spestag{e1}\\
+% &z^\alpha = \mathrm{e}^{\alpha \ln z}
+% \spestag{e2}\\
+% \intertext{\Eqref{e1,e2} lead to the following interesting results:}
+% &\mathrm{e}^{\mathrm{i} \pi} + 1 = 0 \spestag{e3}\\
+% &\mathrm{i}^\mathrm{i} = \mathrm{e}^{-\pi/2}\spestag{e4}
+% \end{align}
+% \end{Ipara}
+% \endgroup
+%
+%
+% \subsection{Reference commands}
+%
+% \begin{cminipage}[1.05\textwidth]
+% \begin{syntdiag}
+% \tok{\argcmd{\rtp}{ref}}
+% \begin{stack}\\ \tok{$\ast$} \end{stack}
+% \begin{stack}\\ \tok{\okeylst} \end{stack}
+% \begin{stack} \tok{"{"<lbl>"}"} \\
+% \tok{"{"<lbl>$_1$,<lbl>$_2$"}" }\\
+% \tok{"{"<lbl>$_1$,$\cdots$, <lbl>$_n$"}" }
+% \end{stack}
+% \end{syntdiag}
+% \end{cminipage}
+% \smallskip
+%
+% \begin{cminipage}[1.05\textwidth]
+% \begin{syntdiag}
+% \tok{\argcmd{\Rtp}{ref}}
+% \begin{stack}\\ \tok{$\ast$} \end{stack}
+% \begin{stack}\\ \tok{\okeylst} \end{stack}
+% \begin{stack} \tok{"{"<lbl>"}"} \\
+% \tok{"{"<lbl>$_1$,<lbl>$_2$"}" }\\
+% \tok{"{"<lbl>$_1$,$\cdots$, <lbl>$_n$"}" }
+% \end{stack}
+% \end{syntdiag}
+% \end{cminipage}
+% \blankline
+% \noindent
+% The |*| optional form of the \argcmd{\rtp}{ref} and
+% \argcmd{\Rtp}{ref} commands eliminates the
+% name prefix. The |[s]| optional key-value argument is for the
+% plural form of the name prefix.
+% \blankline
+%
+% \pagebreak[2]
+% \noindent
+% \textbf{\slshape Examples:}
+% \begin{Itabb}
+% \hspace*{18em}\=\kill
+% |in \eqref{e1} ...| \>in \eqref{e1} ... \\
+% |in \eqref[s]{e1}--\eqref*{e4} ...|\>in \eqref[s]{e1}--\eqref*{e4} ...\\
+% |in \eqref[name=eq.~]{e2} ...| \>in \eqref[name=eq.~]{e2} ...
+% \end{Itabb}
+% \pagebreak[2]
+% \noindent
+% The reference to the page can be included with the \opt{vref} or \opt{vref=far}
+% options that activates the \pkg{varioref} reference.
+% \begin{Itabb}
+% \hspace*{18em}\=\kill
+% |in \eqref[vref]{e1} ...| \>in \eqref[vref]{e1} ...\\
+% |in \eqref[vref=far]{e1} ...| \>in \eqref[vref=far]{e1} ...
+% \end{Itabb}
+% A list of references can be used:
+% \begin{Itabb}
+% \hspace*{18em}\=\kill
+% |in \eqref{e1,e2} ...| \>in \eqref{e1,e2} ... \\
+% |in \eqref{e1,e2,e3} ...| \>in \eqref{e1,e2,e3} ...
+% \end{Itabb}
+% The \argcmd{\Rtp}{ref} command is identical to the
+% \argcmd{\rtp}{ref} command except that it uses the \opt{Name} and
+% \opt{Names} key-value options.
+% \begin{Itabb}
+% \hspace*{18em}\=\kill
+% |\Eqref{e1} is ...| \>\Eqref{e1} is ... \\
+% |\Eqref{e1,e2} are ...| \>\Eqref{e1,e2} are ... \\
+% |\Eqref[lsttxt={\ or~}]{e1,e2,e3}| \>\Eqref[lsttxt={\ or~}]{e1,e2,e3}
+% \end{Itabb}
+% \noindent
+% References to external documents can be added with the \opt{xr}
+% option. Please read the documentation of the \pkg{xr} package.
+%
+% \begin{Itabb}
+% \hspace{10em}\=hspace{5em}\=\kill
+% \cmd{\eqref}|[|\opt{xr}|=A-]{xyz}| \> \>$\rightarrow$~
+% |equation~\ref{A-eq:xyz}|
+% \end{Itabb}
+%
+%
+% \subsection{Range reference commands}
+%
+% \begin{cminipage}[\linewidth]
+% \begin{syntdiag}
+% \tok{\argcmd{\rtp}{rangeref}}
+% \begin{stack}\\ \tok{$\ast$} \end{stack}
+% \begin{stack}\\ \tok{\okeylst} \end{stack}
+% \tok{"{"<lbl>$_1$"}{"<lbl>$_2$"}"}
+% \end{syntdiag}
+% \end{cminipage}
+% \smallskip
+%
+% \begin{cminipage}[\linewidth]
+% \begin{syntdiag}
+% \tok{\argcmd{\Rtp}{rangeref}}
+% \begin{stack}\\ \tok{$\ast$} \end{stack}
+% \begin{stack}\\ \tok{\okeylst} \end{stack}
+% \tok{"{"<lbl>$_1$"}{"<lbl>$_2$"}"}
+% \end{syntdiag}
+% \end{cminipage}
+% \blankline
+%
+% \noindent
+% The \argcmd{\rtp}{rangeref} and \argcmd{\Rtp}{rangeref} commands
+% return a range of references and take two arguments. The |*|
+% optional form again eliminates the name prefix.
+% \blankline
+%
+% \noindent
+% \textbf{\slshape Examples:}
+% \begin{Itabb}
+% \hspace*{19em}\=\kill
+% |in \eqrangeref{e1}{e4} ...| \>in \eqrangeref{e1}{e4} ... \\
+% |... and \eqrangeref*{e1}{e4} ...| \>... and \eqrangeref*{e1}{e4} ... \\
+% |\Eqrangeref{e1}{e4} are ...| \>\Eqrangeref{e1}{e4} are ... \\
+% |\Eqrangeref[vref,rngtxt=--]{e1}{e4}| \>\Eqrangeref[rngtxt=--,vref]{e1}{e4}
+% \end{Itabb}
+%
+%
+% \subsection{Page reference command}\seclabel{PRefCmds}
+%
+% \begin{cminipage}
+% \begin{syntdiag}
+% \tok{\argcmd{\rtp}{pageref}}
+% \begin{stack}\\ \tok{\okeylst} \end{stack}
+% \tok{"{"<lbl>"}"}
+% \end{syntdiag}
+% \end{cminipage}
+% \blankline
+% \noindent
+% The \argcmd{\rtp}{pageref} commands returns the page number of a
+% reference.
+% \blankline
+%
+% \noindent
+% \textbf{\slshape Examples:}
+% \begin{Itabb}
+% \hspace*{18em}\=\kill
+% |it is on page \eqpageref{e1} ...| \>it is on page \eqpageref{e1} ...\\
+% |it is \eqpageref[vref]{e1} ...| \>it is \eqpageref[vref]{e1} ...
+% \end{Itabb}
+%
+%
+%^^A=================================================================
+% \begin{table}
+% \newcommand*{\Q}{\ensuremath{\blacksquare}}^^A
+% \newcommand*{\X}{\ensuremath{\square}}^^A
+% \setlength{\fboxsep}{1em}^^A
+% \centering
+% \caption[The available options and key-value parameters]^^A
+% {The available options and key-value parameters for
+% the label and reference commands of the \RS package.}
+% \tablabel{refopt}
+% \blankline
+% \begin{cminipage}[.9\textwidth]
+% \renewcommand{\thempfootnote}{\fnsymbol{mpfootnote}}
+% \renewcommand{\footnoterule}{}
+% \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}llccccccc@{}}
+% & & \multicolumn{7}{c}{Commands\footnote{^^A
+% The commands are obtained by calling the configuring command
+% \cmd{\newref} and setting the default key-values. The
+% active key-values can be changed temporarily inside the
+% commands.}} \\
+% \cline{3-9}
+% Parameter & Default &
+% \begin{turn}{90}\argcmd{{\rtp}}{key}~ \end{turn}&
+% \begin{turn}{90}\argcmd{{\rtp}}{label}~ \end{turn}&
+% \begin{turn}{90}\argcmd{{\rtp}}{ref}~ \end{turn}&
+% \begin{turn}{90}\argcmd{{\Rtp}}{ref}~ \end{turn}&
+% \begin{turn}{90}\argcmd{{\rtp}}{rangeref}~ \end{turn}&
+% \begin{turn}{90}\argcmd{{\Rtp}}{rangeref}~ \end{turn}&
+% \begin{turn}{90}\argcmd{{\rtp}}{pageref}~ \end{turn}\\
+% \hline
+% \noalign{\smallskip}
+% ~$\ast$ & &\X &\X &\Q &\Q &\Q &\Q &\X\\
+% \okeylst & &\X &\Q &\Q &\Q &\Q &\Q &\Q\\[1ex]
+% \opt{key} &|={|\meta{\rtp:}|},| &\X &\Q &\Q &\Q &\Q &\Q &\Q\\
+% \opt{s} & |={true}|\footnote{^^A
+% Options defaults to \opt{true} but is initialized
+% as \opt{false}. The \argcmd{{\rtp}}{ref}\texttt{[s]}\marg{lbl}
+% command results in the plural: \opt{names}.
+% The same principle is also valid for the \opt{vref}
+% option.\fnlabel{b}}|,|
+% &\X &\X &\Q &\Q &\X &\X &\X\\
+% \opt{vref} &|={true}|\fnref*{b}|,|
+% &\X &\X &\Q &\Q &\Q &\Q &\Q\\
+% \opt{xr} &|={},| &\X &\X &\Q &\Q &\Q &\Q &\Q\\[1ex]
+% \opt{name} &|={},| &\X &\X &\Q &\X &\X &\X &\X\\
+% \opt{names}\footnote{^^A
+% Option depends on the selection of the \texttt{s=true/false}
+% optional key-value for singular or plural.\fnlabel{c}}
+% &|={},| &\X &\X &\Q &\X &\Q &\X &\X\\
+% \opt{Name} &|={},| &\X &\X &\X &\Q &\X &\X &\X\\
+% \opt{Names}\fnref*{c}
+% &|={},| &\X &\X &\X &\Q &\X &\Q &\X\\
+% \opt{lsttxt} &|={\space and~},| &\X &\X &\Q &\Q &\X &\X &\X\\
+% \opt{rngtxt} &|={\space to~},| &\X &\X &\X &\X &\Q &\Q &\X\\[1ex]
+% \opt{refcmd} &|=\ref{#1},| &\X &\X &\Q &\Q &\Q &\Q &\Q\\
+%
+% \hline
+% \noalign{\smallskip}
+%
+% \footnotesize \Q\ -- \makebox[0pt][l]{\footnotesize Available}\\
+% \footnotesize \X\ -- \makebox[0pt][l]{Not available}
+% \end{tabular*}
+% \end{cminipage}
+% \end{table}
+%^^A=================================================================
+%
+%
+%
+%
+% \section{\pkg{Keyval} Optional Arguments}\seclabel{keyvals}
+%
+% Al the options for the referencing commands are set with a key-value
+% list. \Tabref[vref]{refopt} gives a full list of all the key-values and
+% defaults. The options can also be changed locally with the
+% \okeylst\ optional arguments.
+%
+%
+% \subsection{Identifier: \opt{key}}
+%
+% The \opt{key} key-value is the prefix to the reference label
+% of the \cmd{\label}, \cmd{\ref}, and \cmd{\pageref} commands.
+% The default is \opt{key=}\meta{type\,:\,}.
+% For reference to tables defined with the template
+% in \secref{tabtemp}:
+%
+% \begin{Itabb}
+% \tab\=\hspace{3.5cm}\=\hspace{2em}\=\kill
+% \cmd{\newref}|{tab}{...}|\\[1ex]
+% \>|\tablabel{abc}|
+% \>~ $\rightarrow$ |\label{tab:abc}|\\
+% \>|\tabref{abc}|
+% \>~ $\rightarrow$ |table~\ref{tab:abc}|\\[1ex]
+
+% \cmd{\newref}|{tab}{key=xxx-,...}|\\[1ex]
+% \>|\tablabel{abc}|
+% \>~ $\rightarrow$ |\label{xxx-abc}|\\
+% \>|\tabref{abc}|
+% \>~ $\rightarrow$ |table~\ref{xxx-abc}|
+% \end{Itabb}
+% For existing documents containing labels such as |\label{tab:xx}|,
+% you can define \opt{key}|={}| and use the existing labels with
+% \pkg{refstyle}, e.g.: |\tabref{tab:xx}|.
+%
+%
+% \subsection{Plural form: \opt{s}}
+%
+% The \opt{s} conditional option (\texttt{true/false}) switches the
+% singular/plural form of the reference on and off. The default is
+% \opt{s}\texttt{=true}, but it is initialized to \texttt{false}.
+% \begin{Itabb}
+% \tab\=\hspace{3.5cm}\=\hspace{2em}\=\kill
+% |\tabref{abc}|
+% \>\>~ $\rightarrow$ |table~\ref{tab:abc}|\\
+% |\tabref[s]{abc}|
+% \>\>~ $\rightarrow$ |tables~\ref{tab:abc}|
+% \end{Itabb}
+%
+%
+% \subsection{Extended reference: \opt{vref}}
+%
+% The \opt{vref} conditional option (\texttt{true/far/false}) switches the
+% \pkg{varioref} page referencing on and off. The default is
+% \opt{vref}\texttt{=true}, but it is initialized to \texttt{false}.
+%
+% \begin{Itabb}
+% \tab\=\hspace{3.5cm}\=\hspace{2em}\=\kill
+% |\tabref{abc}|
+% \>\>~ $\rightarrow$ |table~\ref{tab:abc}|\\
+% |\tabref[vref]{abc}|
+% \>\>~ $\rightarrow$ |table~\ref{tab:abc}|
+% |\vpageref[\unskip]{tab:abc}|\\
+% |\tabref[vref=far]{abc}|^^A
+% \>\>~ $\rightarrow$ |table~\ref{tab:abc}|
+% |\reftextfaraway{tab:abc}|
+% \end{Itabb}
+%
+%
+% \subsection{External interfaces: \opt{xr}}
+%
+% The \opt{xr} option is for references to external documents.
+% It inserts a prefix in the reference label, compatible with the
+% \pkg{xr} package. The default is \opt{xr}|={}|.
+%
+% External document can be defined in the preamble with the
+% \pkg{xr} package:
+% \begin{Ipara}
+% \cmd{\usepackage}|{xr}|\\
+% \cmd{\externaldocument}\oarg{xr\_key}\marg{filename}
+% \end{Ipara}
+%
+% \noindent
+% If, for example, an external document defined with
+% \meta{xr\_key}\texttt{=\{A-\}}, uses an identical setup (the same
+% \file{refstyle.cfg}), then it can be referenced with
+%
+% \begin{Itabb}
+% \tab\=\hspace{3.5cm}\=\hspace{2em}\=\kill
+% |\tabref[xr=A-]{abc}|
+% \>\>~ $\rightarrow$ |table~\ref{A-tab:abc}|
+% \end{Itabb}
+% \noindent or otherwise
+% \begin{Itabb}
+% \tab\=\hspace{3.5cm}\=\hspace{2em}\=\kill
+% |\tabref[xr=A-,key=]{abc}|
+% \>\>~ $\rightarrow$ |table~\ref{A-abc}|
+% \end{Itabb}
+%
+
+%
+% \subsection{Language parameters: \opt{name}, \opt{names},
+% \opt{Name}, \opt{Names}, \opt{rngtxt}, \opt{lsttxt}}
+% \seclabel{langopts}
+%
+% This key-values contain the text prefixes and insertions.
+% Every house style or user has his or her own preference for naming the reference types,
+% therefore are there no defaults provided.
+%
+% \begin{Itabb}
+% \hspace*{1.5cm}\=\hspace{7cm}\=\kill
+% \opt{name} \> ---~Inside sentence reference prefix (singular)
+% \> default=|{}|\\
+% \opt{names}\> ---~Inside sentence reference prefix (plural)
+% \> default=|{}|\\
+% \opt{Name} \> ---~First word reference prefix (singular)
+% \> default=|{}|\\
+% \opt{Names}\> ---~First word reference prefix (plural)
+% \> default=|{}|\\
+% \opt{rngtxt}\> ---~Range of references
+% \> default=|{\ to~}|\\
+% \opt{lsttxt}\> ---~List of references
+% \> default=|{\ and~}|
+% \end{Itabb}
+% \noindent
+% Good typographic style manuals recommend the minimum use of
+% capital letters and punctuation that breaks the flow of a sentence
+% or paragraph. For abbreviations, Bringhurst\cite{Bring1996}
+% recommends the Oxford house style: Use a period only when the word
+% stops prematurely. The period is omitted if the abbreviation
+% begins with the first letter and end with the last. As an example
+% for equations, use eq.~(1) or eqn~(1).
+% A good guideline is not to abbreviate any reference type names.
+% If a sentence starts with a
+% reference then the type name must always be written in full.
+% A typical example for references to a table is:
+% \begin{Ipara}
+% \opt{name}| ={table~}, |\opt{names}| ={tables~},|\\
+% \opt{Name}| ={Table~}, |\opt{Names}| ={Tables~},|\\
+% \opt{rngtxt}|={\ to~}, |\opt{lsttxt}|={\ and~},|
+% \end{Ipara}
+% Note the hardspace after the text. It is needed to keep the text
+% and the reference together on the same line.
+%
+% The \RS\ configuration file can be setup to interface with \pkg{babel}
+% for different languages or for automatic language changes inside a
+% document. The language specific key-values can be added to the
+% \pkg{babel} hook |\extras|\meta{language}. The command
+% \DescribeMacro{\DeclareLangOpt}\cmd{\DeclareLangOpt}\footnote{^^A
+% Only for use in \texttt{refstyle.cfg} the default config file}
+% is provided to supply a \meta{language} option to the package
+% and to add the option contents to |\extras|\meta{language}. The
+% default config file contains the following lines for equations:
+% \begin{Ipara}
+% |\newcommand\RSenglish{% |\\
+% | \def\RSeqtxt{equation~}% |\\
+% | \def\RSeqstxt{equations~}%|\\
+% | \def\RSEqtxt{Equation~}% |\\
+% | \def\RSEqstxt{Equations~}%|\\
+% | : |\\
+% | } |\\
+% |\DeclareLangOpt{english}{\RSenglish}|
+% \end{Ipara}
+% The key-value options for language specific options
+% are then set as:
+% \begin{Ipara}
+% |\newref{eq}{% |\\
+% | name = \RSeqtxt, |\\
+% | names = \RSeqstxt,|\\
+% | Name = \RSEqtxt, |\\
+% | Names = \RSEqstxt,|\\
+% | : |\\
+% | } |
+% \end{Ipara}
+%
+% \noindent\LaTeX{}/\pkg{babel} provides some language specific
+% names that can be utilized.
+%
+% \begin{Ipara}
+% |\chaptername \appendixname|\\
+% |\figurename \tablename|\\
+% |\partname \pagename|
+% \end{Ipara}
+%
+% To setup a multilingual document with \pkg{babel},
+% \emph{always} make the language options global so that other
+% language compliant packages can detect it.
+% A typical setup for an Afrikaans/English document would be:
+% {\makeatletter\def\meta@font@select{\normalfont\ttfamily\slshape}
+% \begin{Ipara}
+% |\documentclass[UKenglish,afrikaans,|\meta{options}|]{|\meta{LaTeX\_class}|}|\\
+% |\usepackage[T1]{fontenc}%..|\texttt{\slshape hyphenation of words with accents}\\
+% |\usepackage{babel}%........|\texttt{\slshape language def's}\\
+% |\usepackage{varioref}%.....|\texttt{\slshape for \opt{vref} option}\\
+% |\usepackage{refstyle}|
+% \end{Ipara}}
+%
+%
+% \subsection{Reference formatting command: \opt{refcmd}}
+%
+% The \opt{refcmd} key-value holds the contents of the internal
+% command that formats the reference. The |#1| parameter
+% passed to the command is the full reference label.
+% For example:
+% \begin{Itabb}
+% \hspace{10em}\=hspace{5em}\=\kill
+% \opt{refcmd}|=(\ref{#1})| \> $\rightarrow$~
+% |(\ref{|\meta{label}|})|
+% \end{Itabb}
+%
+% External commands can be employed. For example, to make references
+% to equations identical to the \AmS\ \cmd{\eqref} command:
+% \begin{Itabb}
+% \opt{refcmd}|={\textup{\tagform@{\ref{#1}}}}%|~~It needs \file{amsmath.sty}
+% \end{Itabb}
+%
+% The \opt{refcmd} can be used in conjuntion with the |\ifRSstar|,
+% |\ifRSnameon|, |\ifRSplural| and |\ifRScapname| internal
+% conditional variables to format the reference. As an example for a
+% reference to a footnote, where a duplicate footnote mark is needed,
+% can the \opt{refcmd} be configured so that the starred form of the
+% reference command produce a superscripted duplicate mark:
+% \begin{Itabb}
+% |\newcommand{\RSfnmark}[1]{%|\\
+% | \begingroup |\\
+% | \unrestored@protected@xdef\@thefnmark{#1}%|\\
+% | \endgroup |\\
+% | \@footnotemark} |\\[1ex]
+% \opt{refcmd}|={\ifRSstar\RSfnmark{\ref{#1}}\else(\ref{#1})\fi}|
+% \end{Itabb}
+% \noindent The second footnote mark, \fnref*[name]{b}, in
+% \tabref[vref]{refopt}, was obtained in this way with the reference
+% |\fnref*{b}|. See \secref{ChapTempl} for another
+% example for references to chapters and appendices.
+%
+% The \pkg{nameref} package can easily be incorporated if you need elaborate
+% references which include the section or chapter name:
+% \begin{Ipara}
+% |\Secref[vref, refcmd={\S\ref{#1}, `\nameref{#1}'}]{PRefCmds}|
+% \end{Ipara}
+% gives
+% \begin{Ipara}
+% \Secref[vref, refcmd={\S\ref{#1}, `\nameref{#1}'}]{PRefCmds}
+% \end{Ipara}
+%
+% \clearpage
+% \section{Default configuration file}
+%
+% The default configuration file, \file{refstyle.cfg}, makes the
+% following declarations:
+% \begin{Ipara}
+% |\newref{part}{...}| \quad$\rightarrow$ Parts\\
+% |\newref{chap}{...}| \quad$\rightarrow$ Chapters and Appendices\\
+% |\newref{sec}{...} | \quad$\rightarrow$ Sections\\
+% |\newref{eq}{...} | \quad$\rightarrow$ Equations\\
+% |\newref{fig}{...} | \quad$\rightarrow$ Figures\\
+% |\newref{tab}{...} | \quad$\rightarrow$ Tables\\
+% |\newref{fn}{...} | \quad$\rightarrow$ Footnotes
+% \end{Ipara}
+% If there is a need for more reference types, this standard
+% list can be expanded.
+%
+% At this stage the packages also contains language definitions for
+% \texttt{afrikaans} and \texttt{english}. Other language definitions
+% will be included if sent to me.
+%
+% \section{Example Templates for the \RS Package}\seclabel{templates}
+%
+% The user can also define his or her own templates and put it
+% in a configuration file to ensure uniformity
+% of reference formats in your documents.
+%
+% In this section a number of reference templates are given as
+% examples. A sample configuration file can be generated by running
+% \file{refstyle.dtx} through \pkg{docstrip} with the \opt{<tmpl>}
+% option. Modify \file{reftmpl.cfg} according to your requirements
+% and place it in a directory where \TeX\ can find it.
+%
+% \subsection{Document divisions}
+% \subsubsection{Parts}
+%
+% References to parts are usually straight forward, except that the
+% document division ``Part'' must be distinguished from the normal
+% usage of the word ``part'' in a sentence. A personal preference
+% is to use small caps.
+%
+% \begin{RSframed}
+% \begin{macrocode}
+%<*tmpl>
+%%--- TEMPLATE FOR PARTS -------------------------
+% \end{macrocode}
+% \begin{macrocode}
+ \newref{part}{%
+ name = {Part~},
+ names = {Parts~},
+ Name = {Part~},
+ Names = {Parts~},
+ rngtxt = {\space to~},
+ lsttxt = {\space and~}}
+% \end{macrocode}
+% \end{RSframed}
+%
+%
+%
+% \subsubsection{Chapters and Appendices}\seclabel{ChapTempl}
+%
+% A major problem with a reference to a chapter is that at the time
+% when the reference label, |\label|\marg{chap-label}, is created,
+% it is unknown whether it would eventually ends up in the main
+% matter or the appendix part of a book or report.
+%
+% A simple solution is to use the prefix to the \meta{chapter}
+% counter, |\p@chapter|, to write the definition of |\@chapapp| to
+% the auxiliary file (|.aux|) together with information of the
+% label. The command |\@chapapp| expands to either |\chaptername| or
+% |\appendixname| depending on whether the reference label is
+% defined in the main matter or after the |\appendix| was called.
+% (Note that |\@chapapp| is not defined in the \AmS\ book class.)
+%
+% \begin{Ipara}
+% |\renewcommand*{\p@chapter}{\string\chname{\@chapapp}}|\\
+% |\newcommand*{\chname}[1]{}%<-make it harmless |\\
+% |\newcommand*{\chapref}[1]{{\renewcommand*{\chname}[1]{##1~}\ref{#1}}}|
+% \end{Ipara}
+%
+% \noindent The reference to a chapter, |\chapref|\marg{chap-label},
+% will then be prefixed with |\chaptername| or |\appendixname| and
+% it does not matter where it was defined or where it was called.
+%
+% To utilize the full functionality of the \RS package for
+% references to chapters and appendices, a complex form of
+% \cmd{\newref} needs to be implemented.
+% The following is an example
+% of a template for a book or report classes.
+%
+%
+% \begin{RSframed}
+% \begin{macrocode}
+%%--- TEMPLATE FOR CHAPTERS & APPENDIXES --------
+% \end{macrocode}
+%
+% Add \cmd{\@chapapp} to \cmd{\p@chapter} for writeout to auxiliary file.
+% If an AMS book class is loaded, then \cmd{\chaptername} must
+% be used.
+%
+% \begin{macrocode}
+ \makeatletter
+ \providecommand*{\p@chapter}{}
+ \renewcommand*{\p@chapter}{\string\chpname{\@chapapp}}
+ \makeatother
+ \newcommand*{\chpname}[1]{}
+% \end{macrocode}
+%
+% Define the \cmd{\RSchpname} to typeset all the different
+% perturbations of chapter and appendix names.
+% Use the conditionals to switch between the
+% different options.
+%
+% \begin{macrocode}
+\newcommand*{\RSchpname}[1]{%
+ \ifRSnameon
+ \edef\RStmpa{#1}%
+ \edef\RStmpb{\appendixname}%
+ \ifx\RStmpa\RStmpb\relax%
+ \ifRSplural \ifRScapname Appendices~\else appendices~\fi
+ \else \ifRScapname Appendix~\else appendix~\fi
+ \fi
+ \else
+ \ifRSplural \ifRScapname Chapters~\else chapters~\fi
+ \else \ifRScapname Chapter~\else chapter~\fi
+ \fi
+ \fi
+ \fi}
+% \end{macrocode}
+% \begin{macrocode}
+ \newref{chap}{%
+ refcmd = {\let\chpname=\RSchpname\ref{#1}},
+ rngtxt = {\space to~},
+ lsttxt = {\space and~}}
+% \end{macrocode}
+% \end{RSframed}
+%
+%
+% \subsubsection{Sections and paragraphs}\seclabel{secTempl}
+%
+% A template for references to sections is given below. References
+% to paragraphs are similar and is left as an exercise to the users.
+%
+% \begin{RSframed}
+% \begin{macrocode}
+%%--- TEMPLATE FOR SECTIONS ---------------------
+% \end{macrocode}
+% \begin{macrocode}
+ \newref{sec}{%
+ name = {section~},
+ names = {sections~},
+ Name = {Section~},
+ Names = {Sections~},
+ refcmd = {\S\ref{#1}},
+ rngtxt = {\space to~},
+ lsttxt = {\space and~}}
+% \end{macrocode}
+% \end{RSframed}
+%
+% \subsection{Equations}\seclabel{EqTempl}
+%
+% The equation number in references to equations are traditionally
+% written in an upright text, irrespective of the surrounding text.
+%
+% \begin{RSframed}
+% \begin{macrocode}
+%%--- TEMPLATE FOR EQUATIONS --------------------
+% \end{macrocode}
+% Undefine \cmd{\eqref} if the \pkg{amsmath.sty} is loaded.
+% If it is loaded afterwards, you need additional definitions.
+% \begin{macrocode}
+ \let\eqref\relax
+% \end{macrocode}
+% \begin{macrocode}
+ \newref{eq}{%
+ name = {equation~},
+ names = {equations~},
+ Name = {Equation~},
+ Names = {Equations~},
+ refcmd = \textup{(\ref{#1})},
+ rngtxt = {\space to~},
+ lsttxt = {\space and~}}%
+% \end{macrocode}
+% \end{RSframed}
+%
+%
+% \subsection{Figures and Tables}\seclabel{tabtemp}
+%
+% \begin{RSframed}
+% \begin{macrocode}
+%%--- TEMPLATE FOR FIGURES ----------------------
+% \end{macrocode}
+% \begin{macrocode}
+ \newref{fig}{%
+ name = {figure~},
+ names = {figures~},
+ Name = {Figure~},
+ Names = {Figures~},
+ rngtxt = {\space to~},
+ lsttxt = {\space and~}}
+% \end{macrocode}
+% \end{RSframed}
+%
+% \begin{RSframed}
+% \begin{macrocode}
+%%--- TEMPLATE FOR TABLES -----------------------
+% \end{macrocode}
+% \begin{macrocode}
+ \newref{tab}{%
+ name = {table~},
+ names = {tables~},
+ Name = {Table~},
+ Names = {Tables~},
+ rngtxt = {\space to~},
+ lsttxt = {\space and~}}
+% \end{macrocode}
+% \end{RSframed}
+%
+% \pagebreak[2]
+% \subsection{Footnotes}\seclabel{fnTempl}
+%
+% A reference to a footnote differs from other references in that
+% it is only defined inside the footnote definition itself:
+% \begin{Ipara}
+% |\footnote{This is a footnote ... \label{fn:xx}}|
+% \end{Ipara}
+% It can then be referred to with |\ref{fn:xx}|.
+% A useful application of the \RS package is for references to
+% footnotes, were you need a duplicate footnote mark that refers to
+% a previously defined footnote. You can use the stared form of the reference
+% command to format the reference as a footnote mark, while the
+% reference commands without a star behave as normal. The second
+% footnote mark, \fnref*{b}, in \tabref[vref]{refopt}, was obtained with
+% the reference: |\fnref*{b}| while |\fnref[vref]{b}| gives: \fnref[vref]{b}.
+%
+% \begin{RSframed}
+% \begin{macrocode}
+%%--- TEMPLATE FOR FOOTNOTES --------------------
+% \end{macrocode}
+% Define the \cmd{\RSfnmark} to reproduce the footnote mark.
+% Use the |\ifRSstar| conditional to switch between a superscripted
+% and a normal reference.
+% \begin{macrocode}
+ \makeatletter
+ \newcommand{\RSfnmark}[1]{%
+ \begingroup
+ \unrestored@protected@xdef\@thefnmark{#1}%
+ \endgroup
+ \@footnotemark}
+ \makeatother
+% \end{macrocode}
+% \begin{macrocode}
+ \newref{fn}{%
+ name = {footnote~},
+ names = {footnotes~},
+ Name = {Footnote~},
+ Names = {Footnotes~},
+ refcmd = {\ifRSstar\RSfnmark{\ref{#1}}\else(\ref{#1})\fi},
+ rngtxt = {\space to~},
+ lsttxt = {\space and~}}
+% \end{macrocode}
+% \end{RSframed}
+%
+% \subsection{Enumerated lists}
+%
+% A reference to an item in an enumerated list can be obtained
+% by placing the labelling command after the \cmd{\item} command
+% inside the list. The second level numbering of the \cmd{\ref}
+% label in the standard \LaTeX{} is: 2a, 2b, etc.
+%
+% If you want to change the reference labels to 2(a), 2(b),
+% etc., without effecting the display in the \env{enumerate}
+% environment, you can make the following redefinition:
+% \begin{Ipara}
+% |\makeatletter|\\
+% |\renewcommand{\p@enumii}{\expandafter\p@@enumii}|\\
+% |\newcommand{\p@@enumii}[1]{\theenumi(#1)}|\\
+% |\makeatother|
+% \end{Ipara}
+% The contents of the \cmd{\@currentlable} is then
+% \begin{Ipara}
+% |{\expandafter\p@@enumii\theenumii}| ~$\rightarrow$~
+% |{\theenumi(\theenumii)}|
+% \end{Ipara}
+%
+% Writing a template for enumerated lists is left to the user.
+%
+%
+% \subsection{Theorems, lemmas, etc.}
+%
+% There exists many perturbations to the theorem environment such
+% as, Theorem, Lemma, Exercise, etc., and it is left to the user as
+% an exercise to construct his or her own templates.
+%
+%
+% \begin{macrocode}
+%</tmpl>
+% \end{macrocode}
+%
+%
+%
+% \begin{thebibliography}{99}
+% \bibitem{Bring1996}
+% {Bringhurst, R.} (1996), \emph{The elements of typographic style},
+% Hartley \& Marks Publishers, Point Roberts, WA, USA and Vancouver,
+% BC, Canada, second edn.
+% \end{thebibliography}
+%
+% \StopEventually{\PrintChanges\PrintIndex}
+% \clearpage
+%
+% \section{Implementation: \pkg{refstyle.sty}}
+%
+% \subsection{Identification}
+% \begin{macrocode}
+%<*package>
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\ProvidesPackage{refstyle}
+ [2003/04/23 v0.1 Reference formatting (DNJ Els)]
+\newcommand*{\RS@pkgname}{refstyle}
+% \end{macrocode}
+%
+%
+% \subsection{External packages}
+%
+% Load all the external packages.
+% \begin{macrocode}
+\RequirePackage{keyval}
+% \end{macrocode}
+%
+% \noindent A small bug-fix for \pkg{showkeys}. Will be removed
+% after release of new version.
+%
+% \begin{macrocode}
+\@ifundefined{vref@space}{\let\vref@space\space}{}
+% \end{macrocode}
+%
+% \subsection{Utility commands}
+%
+% \begin{macro}{\RS@namelet}
+% \begin{macro}{\RS@nameuse}
+% \begin{macro}{\RS@namedef}
+% \begin{macro}{\RS@robustnamedef}
+% \noindent
+% The following is a list of commands that take a variable \marg{name}
+% as argument. This enables on-the-fly definitions of user commands.
+% \begin{Itabb}
+% Usage:~\=\cmd{\RS@robustnamedef}\marg{name}~\=\kill
+% Usage:
+% \>\cmd{\RS@namelet}\marg{name}
+% \> $\rightarrow$ \cmd{\let}\cmeta{name}\\
+% \>\cmd{\RS@nameuse}\marg{name}
+% \> $\rightarrow$ \cmeta{name}\\
+% \>\cmd{\RS@namedef}\marg{name}
+% \> $\rightarrow$ \cmd{\def}\cmeta{name}\\
+% \>\cmd{\RS@robustnamedef}\marg{name}
+% \> $\rightarrow$
+% \cmd{\def}\cmeta{name}|{\protect|\cmeta{name\textvisiblespace}|}|^^A
+% \cmd{\def}\cmeta{name\textvisiblespace}
+% \end{Itabb}
+% \begin{macrocode}
+\newcommand*{\RS@namelet}[1]{\expandafter\let\csname #1\endcsname}
+\newcommand*{\RS@nameuse}[1]{\csname #1\endcsname}
+\newcommand*{\RS@namedef}[1]{\expandafter\def\csname #1\endcsname}
+\newcommand*{\RS@robustnamedef}[1]{%
+ \expandafter\edef\csname #1\endcsname{%
+ \noexpand\protect\RS@nameuse{#1 }}%
+ \RS@namedef{#1 }}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\RS@ifundefined}
+% This is an improved definition\footnote{Posted by Markus Kohm
+% on c.t.t. 2002/11/11} for the \LaTeX{} kernel command
+% \cmd{\@ifundefined} that do not leave an undefined command
+% defined as \cmd{\relax} after the test.
+%
+% The usage is:
+% \cmd{\RS@ifundefined}\marg{name}\marg{true}\marg{false} executes
+% the contents of \meta{true} if \cmeta{name} is not defined and
+% \meta{false} if defined.
+% \begin{macrocode}
+\def\RS@ifundefined#1{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname#1\endcsname\relax
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@removedef}
+% The command removes the definition of a command, including
+% robust definitions.
+% \begin{macrocode}
+\newcommand*{\RS@removedef}[1]{%
+ \RS@namelet{#1}\@undefined%
+ \RS@ifundefined{#1 }{}{\RS@namelet{#1 }\@undefined}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@testednamedef}
+% \begin{macro}{\RS@testedrobustnamedef}
+% These command are identical to \cmd{\RS@namedef} and
+% \cmd{\RS@robustnamedef}, but only define the \cmeta{name}
+% command if it is legal. Otherwise an error message
+% is written to the log file and the program is terminated.
+% \begin{macrocode}
+\newcommand*{\RS@testednamedef}[1]{%
+ \RS@ifnamedefinable{#1}\RS@namedef{#1}}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*{\RS@testedrobustnamedef}[1]{%
+ \RS@ifnamedefinable{#1}\RS@robustnamedef{#1}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\RS@ifnamedefinable}
+% A modified version of the \LaTeX{} kernel command
+% (from ltdefns.dtx).
+% \begin{macrocode}
+\long\def\RS@ifnamedefinable #1{%
+ \edef\reserved@a{#1}%
+ \RS@ifundefined\reserved@a
+ {\edef\reserved@b{\expandafter\@carcube \reserved@a xxx\@nil}%
+ \ifx \reserved@b\@qend \RS@notdefinable\else
+ \ifx \reserved@a\@qrelax \RS@notdefinable\else
+ \PackageInfo{\RS@pkgname}{\@backslashchar\reserved@a\space created}%
+ \fi
+ \fi}%
+ \RS@notdefinable}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@notdefinable}
+% The error message when an illegal definition is attempted.
+% \begin{macrocode}
+\gdef\RS@notdefinable{%
+ \PackageError{\RS@pkgname}{%
+ Command \@backslashchar\reserved@a\space
+ already defined.\MessageBreak
+ Or name \@backslashchar\@qend... illegal.\MessageBreak
+ It can not be redefined by the \@backslashchar newref%
+ }{%
+ If \@backslashchar\reserved@a\space is not important\MessageBreak
+ then \protect\let\@backslashchar\reserved@a%
+ =\protect\relax,\MessageBreak
+ else use a different \@backslashchar newref.}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@setbool}
+% The command\footnote{Taken from the \pkg{ifthen} package.}
+% \cmd{\RS@setbool}\marg{conditional}\marg{true/false}
+% sets the \meta{conditional} to |true| or |false|.
+% \begin{Itabb}
+% Usage:~\=
+% \cmd{\RS@setbool}|{RSplural}{false}|\quad\=$\rightarrow$\quad
+% |\RSpluralfalse|\\
+% \>\cmd{\RS@setbool}|{RSplural}{true}|\quad\>$\rightarrow$\quad
+% |\RSpluraltrue|
+% \end{Itabb}
+%
+% \begin{macrocode}
+\newcommand*{\RS@setbool}[2]{%
+ \lowercase{\def\@tempa{#2}}%
+ \@ifundefined{@tempswa\@tempa}%
+ {\PackageError{\RS@pkgname}%
+ {You can only set the option to `true' or `false'}\@ehc}%
+ {\csname#1\@tempa\endcsname}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{First character case changes}
+%
+% \begin{macro}{\RS@firstcap}
+% This macro\footnote{Posted by Dan Luecking on c.t.t.} change the
+% first character of a string to uppercase and returns the result
+% in \cmd{\RS@cap}.
+% \begin{Ipara}
+% Usage:~|\RS@fistcap xxxx\@nil| then |\RS@cap| $\rightarrow$ |Xxxx|
+% \end{Ipara}
+% \begin{macrocode}
+\def\RS@firstcap#1#2\@nil{%
+ \iffalse{\fi
+ \uppercase{\edef\RS@cap{\iffalse}\fi#1}#2}}%
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \subsection{Reference building commands}
+%
+%
+% \begin{macro}{\ifRSstar}
+% \begin{macro}{\ifRSnameon}
+% \begin{macro}{\ifRScapname}
+% \begin{macro}{\ifRSplural}
+% The |\if| conditional values that are set by the reference commands.
+% These values can be accessed by user defined key-values.
+% \begin{macrocode}
+\newif\ifRSstar\RSstarfalse
+\newif\ifRSnameon\RSnameontrue
+\newif\ifRScapname\RScapnamefalse
+\newif\ifRSplural\RSpluralfalse
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\newref}
+% The main user interface for template setup. It take the |#1| or
+% \meta{key} parameter and make it lowercase before passing it on to
+% \cmd{\RS@newref}.
+%
+% \begin{macrocode}
+\newcommand*{\newref}[1]{%
+ \lowercase{\def\RS@tempa{#1}}%
+ \expandafter\RS@newref\expandafter{\RS@tempa}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@newref}
+% This command configures a new template.
+% \begin{macrocode}
+\newcommand*{\RS@newref}[2]{%
+% \end{macrocode}
+% \bNP[1.5]\noindent Clears an existing template before defining a new one.\eNP
+% \begin{macrocode}
+ \RS@clearref{#1}%
+% \end{macrocode}
+% \bNP[1.5]\noindent Create |\ifRS@|\meta{key}|vref| conditional \eNP
+% \begin{macrocode}
+% \expandafter\newif\csname ifRS@#1vref\endcsname%
+% \end{macrocode}
+% \bNP[1.5]\noindent Creates a series of key-values for every template
+% that stores the setup for the specific template.\eNP
+% \begin{macrocode}
+ \define@key{RS@#1}{key}[#1:]{\RS@namedef{RS@#1@key}{##1}}%
+ \define@key{RS@#1}{s}[true]{\RS@setbool{RSplural}{##1}}%
+ \define@key{RS@#1}{name}[]{\RS@namedef{RS@#1@name}{##1}}%
+ \define@key{RS@#1}{names}[]{\RS@namedef{RS@#1@names}{##1}}%
+ \define@key{RS@#1}{Name}[]{\RS@namedef{RS@#1@Name}{##1}}%
+ \define@key{RS@#1}{Names}[]{\RS@namedef{RS@#1@Names}{##1}}%
+ \define@key{RS@#1}{rngtxt}[\space to~]{\RS@namedef{RS@#1@rngtxt}{##1}}%
+ \define@key{RS@#1}{lsttxt}[\space and~]{\RS@namedef{RS@#1@lsttxt}{##1}}%
+ \define@key{RS@#1}{refcmd}[\ref{####1}]{\RS@namedef{RS@#1@rcmd}####1{##1}}%
+ \define@key{RS@#1}{xr}[]{\RS@namedef{RS@#1@xr}{##1}}%
+ \define@key{RS@#1}{vref}[true]{\RS@namedef{RS@#1vref}{##1}}%
+% \end{macrocode}
+% \bNP[1.5]\noindent Set default key-value parameters.\eNP
+% \begin{macrocode}
+ \setkeys{RS@#1}{key,
+ s=false,
+ name,names,Name,Names,
+ rngtxt,lsttxt,
+ refcmd,
+ xr,
+ vref=false}%
+% \end{macrocode}
+% \bNP[1.5]Set key-values according to user definitions.\eNP
+% \begin{macrocode}
+ \setkeys{RS@#1}{#2}%
+% \end{macrocode}
+% \bNP[1.5]Build the reference commands.\eNP
+% \begin{macrocode}
+ \RS@buildref{#1}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@clearref}
+% Clear a reference template for redefinition. It check
+% if the template already exists and clear it if it does.
+%
+% \begin{macrocode}
+\newcommand*{\RS@clearref}[1]{%
+ \RS@ifundefined{RS@#1@template}
+ {\RS@namedef{RS@#1@template}{#1}%
+ \PackageInfo{\RS@pkgname}%
+ {New reference template \protect\newref{#1}}{}}
+ {\PackageInfo{\RS@pkgname}%
+ {Reference template \protect\newref{#1} redefined}{}
+ \RS@firstcap#1\@nil
+ \RS@removedef{#1key}%
+ \RS@removedef{#1label}%
+ \RS@removedef{#1ref}%
+ \RS@removedef{\RS@cap ref}%
+ \RS@removedef{#1rangeref}%
+ \RS@removedef{\RS@cap rangeref}%
+ \RS@removedef{#1pageref}%
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@buildref}
+% Build the reference commands. See \tabref{refopt} for the list of
+% commands. The \cmd{\RS@buildref}\marg{key} build commands to
+% call \cmd{\RS@cmd}\marg{cmd}\marg{key}, for example:
+% \begin{Ipara}
+% \cmeta{key}|ref| \quad$\rightarrow$\quad
+% |{\RScapnamefalse\RS@cmd{ref}|\marg{key}|}|
+% \end{Ipara}
+% \begin{macrocode}
+\newcommand*{\RS@buildref}[1]{%
+ \RS@firstcap#1\@nil
+ \RS@testednamedef{#1key}{\RS@nameuse{RS@#1@key}}
+ \RS@testedrobustnamedef{#1label}{\RS@cmd{label}{#1}}
+ \RS@testedrobustnamedef{#1ref}{\RScapnamefalse\RS@cmd{ref}{#1}}
+ \RS@testedrobustnamedef{\RS@cap ref}{\RScapnametrue\RS@cmd{ref}{#1}}
+ \RS@testedrobustnamedef{#1rangeref}{\RScapnamefalse\RS@cmd{rangeref}{#1}}
+ \RS@testedrobustnamedef{\RS@cap rangeref}{\RScapnametrue\RS@cmd{rangeref}{#1}}
+ \RS@testedrobustnamedef{#1pageref}{\RScapnamefalse\RS@cmd{pageref}{#1}}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@cmd}
+% \begin{macro}{\RS@@cmd}
+% The command \cmd{\RS@cmd}\marg{cmd}\marg{key} calls the final
+% reference formatting commands.
+% It checks for the starred form and set the conditionals
+% |\ifRSstar| and |\ifRSnameon| accordingly.
+% It also extracts the optional key-value list.
+% \begin{Itabb}
+% \hspace*{4.5cm}\=\kill
+% \cmd{\RS@cmd}|{label}|\marg{key} \>$\rightarrow$\quad
+% |\RS@label|\marg{key}\okeylst\\
+% \cmd{\RS@cmd}|{ref}|\marg{key} \>$\rightarrow$\quad
+% |\RS@ref|\marg{key}\okeylst\\
+% \cmd{\RS@cmd}|{rangeref}|\marg{key} \>$\rightarrow$\quad
+% |\RS@rangeref|\marg{key}\okeylst\\
+% \cmd{\RS@cmd}|{pageref}|\marg{key} \>$\rightarrow$\quad
+% |\RS@pageref|\marg{key}\okeylst
+% \end{Itabb}
+% \begin{macrocode}
+\newcommand*{\RS@cmd}[2]{%
+ \@ifstar{\RSstartrue\RSnameonfalse\RS@@cmd{#1}{#2}}%
+ {\RSstarfalse\RSnameontrue\RS@@cmd{#1}{#2}}}
+% \end{macrocode}
+% \begin{macrocode}
+\newcommand*{\RS@@cmd}[2]{%
+ \@ifnextchar[%
+ {\RS@nameuse{RS@#1}{#2}}%
+ {\RS@nameuse{RS@#1}{#2}[]}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \subsection{Reference formatting commands}
+%
+% \begin{macro}{\RS@ref}
+% \begin{macro}{\RS@@ref}
+% \begin{macro}{\RS@@@ref}
+% The command \cmd{\RS@ref}\marg{key}\okeylst\marg{label\_lst}
+% typeset the references to the comma-separated reference
+% label list according to the configuration for \meta{key}.
+%
+% First of all, remove all spaces for the reference label list.
+% \begin{macrocode}
+\def\RS@ref#1[#2]#3{%
+ \begingroup
+ \setkeys{RS@#1}{#2}%
+ \edef\RS@tmpa{\zap@space#3 \@empty}%
+ \edef\RS@tmpa{\noexpand\RS@@ref{#1} \RS@tmpa,\relax\noexpand\@eolst}%
+ \RS@tmpa%
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+% Check if there is a single or multiple references in the
+% reference label list. If a single reference label then use the
+% form set by the \opt{s} key-value. If multiple reference labels
+% the use the plural form of the name prefix.\footnote{
+% The list of reference commands came from the \pkg{typedref} package.}
+%
+% \begin{macrocode}
+\def\RS@@ref#1 #2,#3\@eolst{%
+ \ifx\relax#3\relax
+ \RS@makename{#1}%
+ \RS@makeref{#1}{#2}%
+ \RS@makevpageref{#1}{#2}%
+ \else
+ \RSpluraltrue%
+ \RS@makename{#1}%
+ \RS@makeref{#1}{#2}%
+ \RS@makevpageref{#1}{#2}%
+ \RSnameonfalse%
+ \RS@@@ref{#1} #3\@eolst%
+ \fi}
+% \end{macrocode}
+% \end{macro}
+% For more than one reference in the reference list, typeset the
+% rest of the references.
+% \begin{macrocode}
+\def\RS@@@ref#1 #2,#3\@eolst{%
+ \ifx\relax#3\relax
+ \RS@nameuse{RS@#1@lsttxt}%
+ \RS@makeref{#1}{#2}%
+ \RS@makevpageref{#1}{#2}%
+ \else
+ \unskip,\space%
+ \RS@makeref{#1}{#2}%
+ \RS@makevpageref{#1}{#2}%
+ \RS@@@ref{#1} #3\@eolst%
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@rangeref}
+% The command \cmd{\RS@rangeref}\marg{key}\okeylst\marg{lbl1}\marg{lbl2}
+% typeset the references as a range.
+% \begin{macrocode}
+\def\RS@rangeref#1[#2]#3#4{%
+ \begingroup
+ \setkeys{RS@#1}{#2}%
+ \RSpluraltrue%
+ \RS@makename{#1}%
+ \RS@makeref{#1}{#3}%
+ \RS@nameuse{RS@#1@rngtxt}%
+ \RSnameonfalse%
+ \RS@makeref{#1}{#4}%
+ \RS@makevpagerefrange{#1}{#3}{#4}%
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@pageref}
+% The command \cmd{\RS@pageref}\marg{key}\okeylst\marg{lbl} type
+% the page where \marg{lbl} was defined.
+% \begin{macrocode}
+\def\RS@pageref#1[#2]#3{%
+ \begingroup%
+ \setkeys{RS@#1}{#2}%
+ \RS@ifvref{#1}%
+ {\mbox{}\vpageref*{\RS@lbl{#1}{#3}}}%
+ {\reftextfaraway{\RS@lbl{#1}{#3}}}%
+ {\pageref{\RS@lbl{#1}{#3}}}%
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@label}
+% The command \cmd{\RS@label}\marg{key}\okeylst\marg{lbl} set a
+% label according to the current configuration of the \meta{key}
+% reference type.
+% \begin{macrocode}
+\def\RS@label#1[#2]#3{%
+ \begingroup%
+ \setkeys{RS@#1}{#2}%
+ \label{\RS@nameuse{RS@#1@key}#3}%
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\newcommand*{\RS@true}{true}
+\newcommand*{\RS@false}{false}
+\newcommand*{\RS@far}{far}
+% \end{macrocode}
+%
+% \begin{macro}{\RS@ifvref}
+% The command \cmd{\RS@ifvref}\marg{key}\marg{true}\marg{faraway}\marg{false}
+% executes the contents of \meta{true} if the \opt{vref} option for
+% the \meta{key} reference type is true and \meta{false} otherwise.
+% \begin{macrocode}
+\newcommand{\RS@ifvref}[4]{%
+ \edef\RS@tempa{\RS@nameuse{RS@#1vref}}%
+ \ifx\RS@tempa\RS@true\relax
+ #2%
+ \else\ifx\RS@tempa\RS@far\relax
+ #3%
+ \else\ifx\RS@tempa\RS@false\relax
+ #4%
+ \else
+ \PackageError{\RS@pkgname}%
+ {You can only set the vref option to `true', `far' or `false'}\@ehc
+ \fi\fi\fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@makename}
+% The command \cmd{\RS@makename}\marg{key} build the prefix
+% to the reference commands.
+% \begin{macrocode}
+\newcommand{\RS@makename}[1]{%
+ \ifRSstar\else\ifRSnameon
+ \ifRSplural
+ \ifRScapname
+ \RS@nameuse{RS@#1@Names}%
+ \else
+ \RS@nameuse{RS@#1@names}%
+ \fi
+ \else
+ \ifRScapname
+ \RS@nameuse{RS@#1@Name}%
+ \else
+ \RS@nameuse{RS@#1@name}%
+ \fi
+ \fi
+ \fi\fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@lbl}
+% This command builds the full label string for the \cmd{\ref}
+% command.
+% \begin{Ipara}
+% \cmd{\RS@lbl}\marg{key}\marg{label} \quad$\rightarrow$\quad
+% |{|\meta{xr_key}\meta{key}\meta{label}|}|
+% \end{Ipara}
+% \begin{macrocode}
+\newcommand*{\RS@lbl}[2]{%
+ \RS@nameuse{RS@#1@xr}\RS@nameuse{RS@#1@key}#2%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@makeref}
+% The command \cmd{\RS@makeref}\marg{key}\marg{label} formats
+% the \cmd{\ref} output
+% \begin{Ipara}
+% \cmd{\RS@makeref}\marg{key}\marg{label} \quad$\rightarrow$\quad
+% \cmeta{rcmd}|{\ref{|\meta{xr_key}\meta{key}\meta{label}|}}|
+% \end{Ipara}
+% \begin{macrocode}
+\newcommand{\RS@makeref}[2]{%
+ \RS@nameuse{RS@#1@rcmd}{\RS@lbl{#1}{#2}}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@makevpageref}
+% The command \cmd{\RS@makevpageref}\marg{key}\marg{label} adds the
+% \pkg{varioref} page reference if the \opt{vref} option is true.
+% \begin{macrocode}
+\newcommand{\RS@makevpageref}[2]{%
+ \RS@ifvref{#1}%
+ {\vpageref[\unskip]{\RS@lbl{#1}{#2}}}%
+ { \reftextfaraway{\RS@lbl{#1}{#2}}}%
+ {}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\RS@makevpagerefrange}
+% The command \cmd{\RS@makevpagerefrange}\marg{key}\marg{lbl1}\marg{lbl1}
+% adds the \pkg{varioref} page range reference if the \opt{vref}
+% option is true.
+% \begin{macrocode}
+\newcommand{\RS@makevpagerefrange}[3]{%
+ \RS@ifvref{#1}%
+ {\space\vpagerefrange[\unskip]{\RS@lbl{#1}{#2}}{\RS@lbl{#1}{#3}}}%
+ {\space\vpagerefrange[\unskip]{\RS@lbl{#1}{#2}}{\RS@lbl{#1}{#3}}}%
+ {}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{\pkg{varioref} command predefinitions}
+%
+% \begin{macrocode}
+\AtBeginDocument{%
+ \providecommand{\vpageref}{%
+ \PackageError{\RS@pkgname}%
+ {The vref option used, but varioref.sty not loaded.}%
+ {Load varioref.sty}}
+ \providecommand{\reftextfaraway}{%
+ \PackageError{\RS@pkgname}%
+ {The vref=far option used, but varioref.sty not loaded.}%
+ {Load varioref.sty}}
+ \providecommand{\vpagerefrange}{%
+ \PackageError{\RS@pkgname}%
+ {The vref option used, but varioref.sty not loaded.}%
+ {Load varioref.sty}}
+ }
+% \end{macrocode}
+%
+%
+% \subsection{Support for language options inclusions in config file}
+%
+% \begin{macro}{\RS@addto}
+% Command from the \pkg{varioref} package is used to add
+% language definitions to the |\extras|\meta{language} token
+% for \pkg{babel}.
+% \begin{macrocode}
+\def\RS@addto#1#2{%
+ #2%
+ \@temptokena{#2}%
+ \ifx#1\relax
+ \let#1\@empty
+ \fi
+ \ifx#1\undefined
+ \edef#1{\the\@temptokena}%
+ \else
+ \toks@\expandafter{#1}%
+ \edef#1{\the\toks@\the\@temptokena}%
+ \fi
+ \@temptokena{}\toks@\@temptokena}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\DeclareLangOpt}
+% Command to declare a language option and add
+% language definitions to the |\extras|\meta{language} token
+% for \pkg{babel}.
+% \begin{macrocode}
+\def\DeclareLangOpt#1#2{%
+ \edef\RS@tempa{\expandafter\@gobble\string#2}%
+ \RS@ifundefined{\RS@tempa}%
+ {\PackageError{\RS@pkgname}%
+ {Unknown definitions \@backslashchar\RS@tempa\MessageBreak
+ for language option `#1'}{}}%
+ {\DeclareOption{#1}{\expandafter\RS@addto\csname extras#1\endcsname #2}}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \subsection{Package Options}
+%
+% \begin{macro}{\RS@cfgfile}
+% Define the config file name.
+% \begin{macrocode}
+\newcommand*{\RS@cfgfile}{refstyle.cfg}
+% \end{macrocode}
+% \end{macro}
+%
+% We need to peek into the options list before the
+% options are processed to find out if the config
+% file is to be loaded or not. The config file can
+% contain options and must be loaded before
+% \cmd{\ProcessOptions}. Make \opt{noconfig} not used
+% afterwards.
+% \begin{macrocode}
+\@ifpackagewith{\@currname}{noconfig}
+ {\PackageInfo{\RS@pkgname}{No config file loaded}}%
+ {\InputIfFileExists{\RS@cfgfile}%
+ {\PackageInfo{\RS@pkgname}{Config file \RS@cfgfile\space used}}%
+ {\PackageInfo{\RS@pkgname}{Config file \RS@cfgfile\space not found}}%
+ }
+% \end{macrocode}
+% \begin{macrocode}
+\DeclareOption{noconfig}{\OptionNotUsed}
+% \end{macrocode}
+%
+% Process the options, including options in config file.
+% \begin{macrocode}
+\ProcessOptions*\relax
+% \end{macrocode}
+%
+% The end of this package.
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+%
+% \Finale
+\endinput
diff --git a/Master/texmf-dist/source/latex/refstyle/refstyle.ins b/Master/texmf-dist/source/latex/refstyle/refstyle.ins
new file mode 100644
index 00000000000..bd997c8881a
--- /dev/null
+++ b/Master/texmf-dist/source/latex/refstyle/refstyle.ins
@@ -0,0 +1,70 @@
+%%
+%% Copyright (C) 2003 by Danie Els <dnjels@sun.ac.za>
+%%
+%% This file may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.2 of this license
+%% or (at your option) any later version. The latest version of this
+%% license is in:
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.2 or later is part of all distributions of LaTeX version
+%% 1999/12/01 or later.
+%%
+
+\input docstrip.tex
+\keepsilent
+
+%\usedir{tex/latex/refstyle}
+
+\preamble
+
+This is a generated file.
+
+Copyright (C) 2003 by Danie Els <dnjels@sun.ac.za>
+
+This file may be distributed and/or modified under the conditions of
+the LaTeX Project Public License, either version 1.2 of this license
+or (at your option) any later version. The latest version of this
+license is in:
+
+ http://www.latex-project.org/lppl.txt
+
+and version 1.2 or later is part of all distributions of LaTeX version
+1999/12/01 or later.
+
+\endpreamble
+
+\generate{\file{refstyle.sty}{\from{refstyle.dtx}{package}}}
+
+\preamble
+
+This is a generated file.
+
+This is an example of a template configuration file
+for the refstyle package. The user may redefine it
+to suit his or her own needs.
+
+\endpreamble
+
+
+\generate{\file{reftmpl.cfg}{\from{refstyle.dtx}{tmpl}}}
+
+\Msg{***************************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move the following}
+\Msg{* file into a directory searched by TeX:}
+\Msg{*}
+\Msg{* \space\space refstyle.sty}
+\Msg{* \space\space refstyle.cfg}
+\Msg{*}
+\Msg{* The following file is supplied as a template:}
+\Msg{* \space\space reftmpl.cfg}
+\Msg{*}
+\Msg{* To produce the documentation run the file refstyle.dtx}
+\Msg{* through LaTeX.}
+\Msg{*}
+\Msg{* Happy TeXing}
+\Msg{***********************************************************}
+
+\endbatchfile