| 1 |
\documentclass[a4paper]{article} |
| 2 |
\usepackage[a4paper]{geometry} |
| 3 |
\usepackage{miscdoc} |
| 4 |
\usepackage[scaled=0.85]{luximono} |
| 5 |
\begin{document} |
| 6 |
\title{The \Package{titleref} package} |
| 7 |
\author{Donald Arseneau\thanks{Documentation file assembled by Robin |
| 8 |
Fairbairns}} |
| 9 |
\date{5th April 2005, version 3.1} |
| 10 |
\maketitle |
| 11 |
|
| 12 |
The package provides a command \cs{titleref} to cross-reference the |
| 13 |
titles of sections (etc.). The \cs{label} command is changed to |
| 14 |
remember the title for such a reference. You can use \cs{titleref} |
| 15 |
just as you use \cs{ref} and \cs{pageref}. |
| 16 |
|
| 17 |
Titles for numbered sectioning units and for floats with captions are |
| 18 |
the same as the respective \textsc{toc}, \textsc{lof}, or \textsc{lot} |
| 19 |
entry (even when no \textsc{toc}, or whatever, is printed). When a |
| 20 |
short title is provided (\cmdinvoke{section}[short]{long}, etc.\@) it |
| 21 |
will be used for the \cs{titleref}. This is especially useful for |
| 22 |
figure captions. Unnumbered sections take their title reference from |
| 23 |
the printed title. Beware!~--- This turns the title into a moving |
| 24 |
argument when it normally is not, and will cause weird errors if there |
| 25 |
are `fragile' commands present. |
| 26 |
|
| 27 |
Enumerated lists do not have titles and simply inherit the title of |
| 28 |
their section. |
| 29 |
|
| 30 |
The format of the title reference is controlled by the command |
| 31 |
\cs{theTitleReference}, which can be redefined with \cs{renewcommand}. |
| 32 |
It takes two parameters: the number and the title. The number is |
| 33 |
just the regular \cs{ref} and it is WRONG in unnumbered sections. |
| 34 |
Beware! The default definition is the unadorned title. You could |
| 35 |
do, for example, |
| 36 |
\cmdinvoke{renewcommand}{\cs{theTitleReference}}[2]{\#1\cs{\ }\cs{emph}{\#2}} |
| 37 |
|
| 38 |
The title of the current section is also available without \cs{label}: |
| 39 |
use the command \cs{currenttitle} to generate a \cs{titleref} to the |
| 40 |
current section. If you have redefined \cs{theTitleReference} to |
| 41 |
print the number with the title, be aware that the two may not |
| 42 |
correspond: in a numbered list the number will show the current item |
| 43 |
but the title will show the current section, while in an unnumbered |
| 44 |
section the number will show some previous section number. |
| 45 |
|
| 46 |
\section*{Options: \option[usetoc] and \option[nostar]} |
| 47 |
|
| 48 |
In the default operation, the titles are recorded by a command |
| 49 |
inserted into the various sectioning commands (\cs{@sect}, |
| 50 |
\cs{@ssect}, \cs{@chapter}, \cs{@schapter}, \cs{@part}, \cs{@spart}, |
| 51 |
and \cs{@caption}). If this creates conflicts with some other |
| 52 |
package, you can use an entirely different method by specifying |
| 53 |
\cmdinvoke{usepackage}[usetoc]{titleref}. As the name implies, this |
| 54 |
option records the titles from the table-of-contents entry without |
| 55 |
redefining the sectioning commands. (This method was used in older |
| 56 |
versions of the package.) |
| 57 |
|
| 58 |
Since there are no \textsc{toc} entries for the `star' versions of |
| 59 |
sectioning commands, they are still redefined. The additional option |
| 60 |
\option[nostar] (\cmdinvoke{usepackage}[usetoc,nostar]{titleref}) |
| 61 |
prevents the redefinitions, but then "\cs{section*}" will not generate |
| 62 |
a title reference. If you try to refer to the title of an unnumbered |
| 63 |
section while \option[nostar] is in effect, you will get the title of |
| 64 |
the previous section. |
| 65 |
|
| 66 |
Under the \option[usetoc] option, the current title will always be |
| 67 |
overridden by an \cs{addcontentsline} command before the \cs{label}, |
| 68 |
even for starred section commands under the \option[nostar] option. |
| 69 |
|
| 70 |
The big problem with the \option[usetoc] method is that \cs{titleref} |
| 71 |
will not refer to a \cs{label} which was given in the title or caption |
| 72 |
itself; the label must be placed after the sectioning command or the |
| 73 |
caption. If you make a title-reference to a label given in a title, |
| 74 |
you will get a warning message. |
| 75 |
|
| 76 |
\section*{Compatibility} |
| 77 |
|
| 78 |
The package was early in the field with this functionality, but it now |
| 79 |
has competitors. The package \emph{will not} work with other packages |
| 80 |
that manipulate the labelling mechanism, such as \Package{hyperref}; |
| 81 |
for that title references with \Package{hyperref} you must use the |
| 82 |
\Package{nameref} package in place of \Package{titleref}. |
| 83 |
|
| 84 |
The \Package{zref} package also diddles with the \cs{label}--\cs{ref} |
| 85 |
mechanism, and will equally not work with \Package{titleref}. |
| 86 |
\Package{zref} itself doesn't provide a title reference facility: you |
| 87 |
need to use \Package{hyperref} and \Package{nameref} for that. |
| 88 |
|
| 89 |
\end{document} |