| 1 |
# refenums - ReferenceableEnumElements |
| 2 |
|
| 3 |
Define named items and provide back-references with that name |
| 4 |
|
| 5 |
This package provides commands to define enumerable items with a number and a long name, which can be referenced referenced later with the name or just the short form. |
| 6 |
For instance, "Milestone M1: Specification created" can be defined and later on be referenced with `M1` or `M1 ("Specification created")`. |
| 7 |
The text in the references is derived from the definition and also rendered as hyperlink to the definition. |
| 8 |
Thus, a change of the definition also leads to a change of all references to the text. |
| 9 |
This ensures consistency in the text. |
| 10 |
|
| 11 |
## Usage |
| 12 |
|
| 13 |
``` |
| 14 |
\usepackage{refenums} |
| 15 |
``` |
| 16 |
|
| 17 |
Load the package after all packages (hyperref, cleveref, ...). |
| 18 |
For best results, use the `nameinlink` option at cleveref. |
| 19 |
The option `capitalise` is also useful if you use cleveref's `\cref` command, therefore we recommend loading `cleveref` before `refenums` with follwing line: |
| 20 |
`\usepackage[capitalise,nameinlink]{cleveref}` |
| 21 |
|
| 22 |
|
| 23 |
### Define the "Referenceable Enum Environment" |
| 24 |
|
| 25 |
Decide for `<EnumId>`. |
| 26 |
E.g., `req`. |
| 27 |
|
| 28 |
#### Initialize |
| 29 |
`\setupRefEnums{<EnumId>}{<PrintName>}` |
| 30 |
|
| 31 |
In case `<PrintName>` is set to `ONLYSHORT`, only the short name is used. |
| 32 |
|
| 33 |
Optional parameter: Separator between `<EnumId>` and number. |
| 34 |
|
| 35 |
#### (Optional) Define shorthand macro to define the macros for referencing |
| 36 |
|
| 37 |
`\newcommand{\def<EnumId>}[2]{\defRefEnum{<EnumId>}{#1}{#2}}` |
| 38 |
|
| 39 |
|
| 40 |
### Usage in the text |
| 41 |
|
| 42 |
#### Define a single enum |
| 43 |
* `\defRefEnum{<EnumId>}{<FullName>}{<LabelId>}` (always supported) |
| 44 |
* `\def<EnumId>{<FullName>}{<LabelId>}` (when the shorthand command is defined) |
| 45 |
|
| 46 |
#### Define a single enum using the inline format |
| 47 |
`\defineReferenceableEnumElementInline{<EnumId>}{<FullName>}{<LabelId>}`. |
| 48 |
Using this, a enumeration similar to the ones of the `inparaenum` environment is possible. |
| 49 |
`inparaenum` is offered by the [paralist package]. |
| 50 |
|
| 51 |
#### Referencing |
| 52 |
|
| 53 |
* `\refEnumFull{<EnumId>}{<LabelId>}` = `<EnumId>-<Counter> ("<FullName>")`, e.g. `R-1 ("Quality")` |
| 54 |
* `\refEnumFullP{<EnumId>}{<LabelId>}` is the long form for `\refEnumFull'. |
| 55 |
* `\refEnumFullT{<EnumId>}{<LabelId>}` = `<EnumId>-<Counter>: "<FullName>"`, e.g. `R-1: "Quality"` |
| 56 |
* `\refEnum{<EnumId>}{<LabelId>}` = `<EnumId>-<Counter>`, e.g. `R-1` |
| 57 |
* References to the label |
| 58 |
* `\nameref{enum:<EnumId>:<LabelId>}` = `<FullName>` |
| 59 |
* `\ref{enum:<EnumId>:<LabelId>}` = `<Counter>`, e.g. `1` |
| 60 |
|
| 61 |
|
| 62 |
## Example |
| 63 |
|
| 64 |
**Initialize**: `\setupRefEnums{R}{Requirement}` |
| 65 |
|
| 66 |
**Define a single enum**: `\defRefEnum{R}{Quality}{qual}`. |
| 67 |
When you want to put the element in a section, use the optional parameter: |
| 68 |
`\defRefEnum[section]{R}{Quality}{qual}` |
| 69 |
|
| 70 |
**Referencing**: |
| 71 |
|
| 72 |
* Reference only Name + Number: `\refEnum{R}{qual}` |
| 73 |
* Full reference with the print name in brackets: `\refEnumFull{R}{qual}` |
| 74 |
* Full reference with the print name appended after ":": `\refEnumFullT{R}{qual}` |
| 75 |
|
| 76 |
**See also** [demo.tex](demo.tex). |
| 77 |
|
| 78 |
|
| 79 |
## Tuning |
| 80 |
|
| 81 |
When defining a referenceable element, this element is enclosed using `\refenumenclosing` for normal enums and `\refenumenclosinginline` for inline enums. |
| 82 |
These commands can be redefined after package usage. |
| 83 |
|
| 84 |
## TODO |
| 85 |
|
| 86 |
* The decision to put the enum in a section should be taken at `\setupRefEnums` not at `\defRefEnum`. |
| 87 |
* Enable automatically generating `\def<EnumId>` at `\setupRefEnums` via a package parameter. |
| 88 |
|
| 89 |
|
| 90 |
## Source code |
| 91 |
|
| 92 |
The latest source code is available at https://github.com/koppor/refenums |
| 93 |
|
| 94 |
## Files |
| 95 |
|
| 96 |
* [refenums.sty](refenums.sty): the package |
| 97 |
* [demo.tex](demo.tex): small demonstration |
| 98 |
|
| 99 |
[paralist]: www.ctan.org/pkg/paralist |