summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fncylab/fncylab.sty
blob: 17c086da164c493df7ae3e05598ca29c78a6ccea (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
%  FNCYLAB.STY v1.1
%  Copyright 2000,2003 Robin Fairbairns (robin.fairbairns@cl.cam.ac.uk)
%  Copyright 2019 LaTeX Team
%
%   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 ...

% as 2019 the modification (and \labelformat and \Ref) has been added
% to the LaTeX kernel, so there is nothing to do for this package any more
% unless it is run using an older kernel.

\ifx\labelformat\@undefined   % if defined we assume a newer kernel

% 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
}
\else
\PackageWarningNoLine{fncylab}{%
fncylab is not required with releases after 2019.\MessageBreak
All its functionality is now in the LaTeX kernel}

\fi

\endinput