Debian Codegraph @

texmf-dist/doc/latex/wtref/wtref.tex

raw
1 %#!pdflatex
2 \documentclass[a4paper]{article}
3
4 \usepackage{enumitem}
5 \usepackage{shortvrb}
6
7 \MakeShortVerb{\|}
8 \newcommand{\PkgName}[1]{\textsf{#1}}
9 \newcommand{\ThisPkg}{\PkgName{WTRef}}
10 \newcommand{\Meta}[1]{$\langle$\mbox{}\textit{#1}\mbox{}$\rangle$}
11 \newenvironment{syntax}{\begin{quote}\small}{\end{quote}}
12 \newcommand{\eg}{e.g.,\,}
13 \newcommand{\ie}{i.e.,\,}
14
15 \title{The {\ThisPkg} Package (v1.0.0)}
16 \author{Takuto Asakura (wtsnjp)}
17
18 \begin{document}
19
20 \maketitle
21
22 \begin{abstract}
23 Package {\ThisPkg} is a small extension for {\LaTeXe}'s cross-referencing. It
24 enables you to divide namespace and scope. It also provides a few ways to
25 customise referencing formats. {\LaTeXe} on any kind of {\TeX} engine is
26 supported. The package requires Package \PkgName{xparse} and \PkgName{xkeyval}.
27 \end{abstract}
28
29 \section{System requirements}
30
31 {\ThisPkg} requires the following.
32 %
33 \begin{itemize}
34 \item {\TeX} engine: any engine
35 \item {\TeX} format: \LaTeXe
36 \item Document class: any class
37 \item Required packages: \PkgName{xparse} and \PkgName{xkeyval}
38 \end{itemize}
39
40 \section{Loading the package}
41
42 The package should be loaded in the usual {\LaTeXe} way. No package option is
43 available.
44 %
45 \begin{syntax}
46 |\usepackage{wtref}|
47 \end{syntax}
48
49 \section{Cross-reference commands}
50
51 \subsection{Declaring new cross-reference commands}
52
53 The |\newref| command creates a pair of cross-reference commands. This command
54 can be used in preamble only.
55 %
56 \begin{syntax}
57 |\newref[|\Meta{options}|]{|\Meta{ref types}|}|
58 \end{syntax}
59 %
60 Herein, \Meta{ref types} is a comma-separated list of \Meta{ref type}. All
61 characters consisting of \Meta{ref type} must be `letter' so that they can be
62 used for control sequences (recommended to use ASCII alphabets only) and may
63 not be empty. Notice that leading and trailing spaces and successive spaces
64 around commas are ignored.
65
66 The |\newref| command defines pairs of cross-referencing commands, |\|\Meta{ref
67 type}|label| and |\|\Meta{ref type}|ref| for each given \Meta{ref type}. In
68 this document, we call the former \emph{label commands} and the latter
69 \emph{reference commands}. Notice that the |\newref| command may overwrites
70 existing commands (with warning messages), so \Meta{ref name} should be decided
71 carefully.
72
73 In \Meta{options}, you can set the following parameters with key-value list:
74 %
75 \begin{description}[font=\normalfont]
76 \item[|namespace=|\Meta{string}] sets \Meta{namespace} to ``\Meta{string}:''.
77 In case neither |namespace| nor |nonamespace| is specified, or \Meta{string} of
78 |namespace| is empty, the \Meta{namespace} parts in labels are set to
79 ``\Meta{ref type}:''.
80 %
81 \item[|nonamespace|] sets \Meta{namespace} to empty. That is to say, the
82 namespace function for the package is disabled. You can give a value for the
83 |nonamespace| key without any error, but the value will be simply ignored.
84 %
85 \item[|scope=|\Meta{counter}] sets counter which used as scope. Though you can
86 specify arbitrary {\LaTeX} counter for \Meta{counter}, normally those which
87 have uniqueness in a document are useful. The \Meta{scope} parts in labels are
88 set to ``|\the|\Meta{counter}:''.
89 \end{description}
90 %
91 These optional settings apply to all pairs of cross-reference commands
92 corresponding to \Meta{ref type}s in specified \Meta{ref types}.
93
94 Identically, if any keys do not specified in \Meta{options}, \Meta{namespace}
95 is set to ``\Meta{ref type}'', and \Meta{scope} is set to empty. In other words,
96 while the namespace function is enabled by default, the scope function is not.
97
98 \subsection{Label commands}
99
100 Label commands are used for making new labels. The usage of them are the same
101 as the standard |\label| command of {\LaTeXe}, \eg
102 %
103 \begin{syntax}
104 |\exlabel{|\Meta{label}|}|
105 \end{syntax}
106
107 The label commands are equivalent to the following after a full-expansion:
108 %
109 \begin{syntax}
110 |\label{|\Meta{namespace}\Meta{scope}\Meta{label}|}|
111 \end{syntax}
112
113 \subsection{Reference commands}
114
115 Reference commands print contents of counters which labeled by label commands
116 in specified formats. The following is the syntax of an example reference
117 command |\exref|:
118 %
119 \begin{syntax}
120 |\exref[|\Meta{the scope}|]{|\Meta{label list}|}|
121 \end{syntax}
122
123 The option argument \Meta{the scope} can be omitted when the specified label
124 exists in the same scope. You can refer to labels outside a scope by specifying
125 the target scope explicitly, that is the output of proper |\the|\Meta{counter},
126 in the option argument. Notice that if the function of scope is inactive (\ie
127 in case |scope| key does not specified in \Meta{options} of |\newref|), this
128 argument is always unnecessary, and it will be ignored all the time.
129
130 In argument \Meta{label list}, you can specify multiple labels in a form of
131 comma-separated list. Note that leading and trailing spaces and successive
132 spaces around commas are ignored. In the case, pertinent counters should be
133 printed in comma-separate form by default. You can change this format
134 flexibly with the |\setrefstyle| command.
135
136 \section{Setting referencing style}
137
138 The output format of reference commands can be customised with the
139 |\setrefstyle| command. The syntax of the command is as follows:
140 %
141 \begin{syntax}
142 |\setrefstyle{|\Meta{ref types}|}{|\Meta{options}|}|
143 \end{syntax}
144
145 The |\setrefstyle| command can be used anywhere in {\LaTeX} documents, not
146 limited to preambles, and sets the reference format locally.
147
148 In \Meta{options}, you can set the following parameters with a key-value list:
149 %
150 \begin{description}[font=\normalfont]
151 \item[|refcmd=|\Meta{ref command}] sets the \Meta{ref command} to used for actual
152 referencing functionality. Herein, |#1| in the \Meta{command} may be replaced
153 into suitable label name. The default value is |\ref{#1}|. The \Meta{command}
154 may be used repeatedly for the number of labels in the given \Meta{label list}.
155 %
156 \item[|sep=|\Meta{separator}] sets the \Meta{separator}, which used between
157 each \Meta{ref command}, in case more than three labels are given for a
158 \Meta{label list}. Notice that last one separator is set by |last sep|. The
159 default value is |{,\space}|.
160 %
161 \item[|last sep|(|=|\Meta{last separator})] sets \Meta{last separator} to used
162 for the last separator between the \Meta{ref command}s, in case multiple labels
163 are given in \Meta{label list}. The part after |=| can be omitted. In that case,
164 |last sep| is set to identical value of |sep|, and this is the default
165 behavior.
166 %
167 \item[|prefix=|\Meta{prefix}]
168 sets \Meta{prefix} to be put in front of the first \Meta{ref command} when the
169 reference commands are used. The default value is |{}|.
170 %
171 \item[|suffix=|\Meta{suffix}] sets \Meta{suffix} to be put behind the last
172 \Meta{ref command} when reference commands are used. The default value is |{}|.
173 \end{description}
174 %
175 Values of the keys which do not set explicitly in the \Meta{options} are left
176 unchanged.
177
178 \end{document}
179 % vim: spell: