<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%  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&lt;counter&gt; -- 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}
</pre></body></html>