summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/labels.sty
blob: 2b2f4e5022981b4b8715ae594c8b3ae11c88ae32 (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
%%% ======================================================================
%%%  @LaTeX-style{
%%%     filename        = "labels.sty",
%%%     version         = "1.0",
%%%     date            = "17 July 1992",
%%%     time            = "13:39:24.74 +0100",
%%%     author          = "Norman Gray",
%%%     address         = "Department of Physics
%%%                        Open University
%%%                        Milton Keynes
%%%                        MK7 6AA, UK",
%%%     e-mail          = "N.O.Gray@open.ac.uk (Internet)",
%%%     telephone       = "+44 908 652279",
%%%     FAX             = "+44 908 653744",
%%%     archived        = "Aston, SHSU",
%%%     keywords        = "Labels, cross-referencing",
%%%     abstract        = "If this style file is included amongst the
%%%                        \documentstyle options, all uses of the \label
%%%                        command within the LaTeX file will have the label
%%%                        name printed in the margin (except when used in
%%%                        a \caption, when it appears in the text).",
%%%     codetable       = "ISO/Ascii",
%%%     checksum        = "60488 80 330 3319",
%%%     docstring       = "Display label names in margin
%%%                        
%%%                        The checksum field above contains a CRC-16
%%%                        checksum as the first value, followed by the
%%%                        equivalent of the standard UNIX wc (word 
%%%                        count) utility output of lines, words, and
%%%                        characters.  This is produced by Robert 
%%%                        Solovay's checksum utility."
%%% }
%%% ======================================================================

\let\@@eqnnum=\@eqnnum
\def\@eqnnum{\@@eqnnum
% + |\@eqnnum| will produce a note, sticking into the margin beside
% the equation number, which has the equation's label and number.
% |\labeln@me| is initialised to |\relax|, redefined within the
% |\label| macro, and reset to |\relax| here.  If it's already equal
% to |\relax| here, the equation number hasn't been labelled, and so
% `???' is put in the margin. \-
\if\labeln@me\relax
  \margintext{???}%
\else
  \margintext{\labeln@me}\global\def\labeln@me{\relax}%
\fi}

\let\@@makecaption\@makecaption
\let\@label\label
\def\@gobblethree#1#2#3{}
\def\prlabelname#1{% expansion is label name #1 with all catcodes `other'
\expandafter\expandafter\expandafter\@gobblethree
    \expandafter\string\csname r@#1\endcsname}
    % use \r@#1, rather then just \#1 to avoid defining new control sequence

\long\def\@makecaption#1#2{{\def\label##1{{\nintt\{\prlabelname{##1}\}\space
    }\@label{##1}}\@@makecaption{#1}{#2}}}
\def\label#1{\@bsphack\@label{#1}%
\ifmmode
  \xdef\labeln@me{\prlabelname{#1}}%  label name produced with equation number
\else
{\setbox0=\vbox to 0pt{\vss\hbox to \hsize{\hfill
    \margintext{\prlabelname{#1}}}}\dp0=0pt%
\ifvmode
  \nointerlineskip\box0\nobreak	    % fix this box to next one
\else
  \vadjust{\box0\nobreak}%
\fi}%
\fi
\@esphack}

%\if@twoside
%  \def\margintext#1{\ifodd\c@page\rlap{\nintt\quad\{#1\}}\else
%    \llap{\nintt\{#1\}\quad\hskip\textwidth}\fi}
%\else
%  \def\margintext#1{\rlap{\nintt\quad\{#1\}}}
%\fi
\def\margintext#1{\rlap{\sevit\quad\{#1\}}}
\global\def\labeln@me{\relax}