File: fncylab.sty

package info (click to toggle)
tetex-src 2.0.2a-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 71,124 kB
  • ctags: 1,576
  • sloc: makefile: 1,764; sh: 1,181; perl: 925; lisp: 342; python: 251; sed: 138; ansic: 138; xml: 96; yacc: 52
file content (83 lines) | stat: -rw-r--r-- 2,745 bytes parent folder | download
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
%  FNCYLAB.STY v0.1
%  Copyright 2000 Robin Fairbairns (rf10@cam.ac.uk)
%
%   This program can redistributed and/or modified under the terms
%   of the LaTeX Project Public License Distributed from CTAN
%   archives in directory macros/latex/base/lppl.txt; either
%   version 1 of the License, or (at your option) any later version.
%
% 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 ...
%
% A complete demonstration, 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}

\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 \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, and do another item
% labelled that way:
\labelformat{enumi}{(#1)}
%
% and label the last item
\item third item \label{third}
%
% we now see that the label has been defined differently:
\item fourth item (see also item~\ref{third})
\end{enumerate}
\end{document}