summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ltxmisc/fncylab.sty
blob: d91fe4c83f3f9d5952c5c855d16abbb38fdbdd40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
%  FNCYLAB.STY v1.0
%  Copyright 2000,2003 Robin Fairbairns (robin.fairbairns@cl.cam.ac.uk)
%
%   This program can redistributed and/or modified under the terms
%   of the LaTeX Project Public License; either version 1.2 of the
%   license, or (at your option) any later version.
%
%   See http://www.latex-project.org/lppl.txt for the latest version
%   of the license.
%
% This package provides support for arbitrary structuring of the way
% label references look.  The \labelformat command takes two
% arguments:
%  #1   the counter that will define the label (e.g., section, figure,
%       enumi, etc.)
%  #2   the definition of how the label will be formatted: in this
%       argument, #1 (*not* ##1) substitutes the `raw' value of the
%       thing which is the source of the label.
%
% The package makes use of a built-in LaTeX facility (which actually
% needs a bit of patching before it's usable); this allows the precise
% layout of the references to labels generated from any LaTeX counter
% to be altered.  Note that the way in which the counter itself is
% represented in references depends on \the<counter> -- it's the same
% as the way the counter gets printed.
%
% example
% \labelformat{section}{section #1}
% ...
% \section{The Blah Field}\label{blah}
% ...
% ... As we saw above in~\ref{blah} ...
%
% will typeset as
% ... As we saw above in section 3 ...
%
% For references at the start of a sentence, the package defines a
% command \Ref, which is used as follows:
% ... \Ref{blah} shows us that ...
%
% which will typeset as
% ... Section 3 shows us that ...
%
% A demonstration of \labelformat, using the enumerate package, may be
% found after \endinput

% this check and redefinition is suggested in the latex source
% (ltxref.dtx)
\CheckCommand*\refstepcounter[1]{\stepcounter{#1}%
    \protected@edef\@currentlabel
       {\csname p@#1\endcsname\csname the#1\endcsname}%
}
\renewcommand*\refstepcounter[1]{\stepcounter{#1}%
  \protected@edef\@currentlabel
    {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}%
}

\def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1}

\DeclareRobustCommand\Ref[1]{\protected@edef\@tempa{\ref{#1}}%
   \expandafter\MakeUppercase\@tempa
}

\endinput

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% small sample file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass{article}
%
% a brief demonstration of the use of fncylab
%
\usepackage{fncylab,enumerate}
\begin{document}
%
% outer level lists (such as enumerate) use counter enumi for their
% list tags.
\begin{enumerate}[(i)]
\item first item, defining a non-fancy label \label{first}
%
% that label was defined to look otherwise than it was printed for the
% item:
\item second item (see also item~\ref{first})
%
% redefine label formats for this list's labels:
\labelformat{enumi}{(#1)}
%
% and label the another item in a different way:
\item third item, defining a fancy label \label{third}
%
% redefine label formats for this list's labels again:
\labelformat{enumi}{item~(#1)}
%
% we now see that the label has for item three has been defined
% differently, and that for item four differently again.  note the
% reference starting a new sentence.
\item fourth item, defining a fancy label in a different format (see
  also item~\ref{third}).  \Ref{fourth} shows how a sentence may start
  with reference to a fancy label; note that it's the \emph{label}
  that's fancy, so the second change to the label format only affects
  the labels defined after it.  \label{fourth}
\end{enumerate}
\end{document}