summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/amscls/upref.dtx
blob: 843126b3b58c7c9138fd964180a711239c8219a4 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
%%% ====================================================================
%%%  @LaTeX-file{
%%%     filename        = "upref.dtx",
%%%     version         = "2.01",
%%%     date            = "2004/07/29",
%%%     time            = "16:37:01 EDT",
%%%     checksum        = "07926 151 617 5530",
%%%     author          = "American Mathematical Society",
%%%     copyright       = "Copyright 1996 American Mathematical Society,
%%%                        all rights reserved.  Copying of this file is
%%%                        authorized only if either:
%%%                        (1) you make absolutely no changes to your copy,
%%%                        including name; OR
%%%                        (2) if you do make changes, you first rename it
%%%                        to some other name.",
%%%     address         = "American Mathematical Society,
%%%                        Technical Support,
%%%                        Electronic Products and Services,
%%%                        P. O. Box 6248,
%%%                        Providence, RI 02940,
%%%                        USA",
%%%     telephone       = "401-455-4080 or (in the USA and Canada)
%%%                        800-321-4AMS (321-4267)",
%%%     FAX             = "401-331-3842",
%%%     email           = "tech-support@ams.org (Internet)",
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "latex, amslatex, ams-latex, cross references",
%%%     supported       = "yes",
%%%     abstract        = "This is a LaTeX package that provides printing
%%%                        of \cn{ref}s in an upright font even if the
%%%                        current context is italic or slanted.",
%%%     docstring       = "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.",
%%%  }
%%% ====================================================================
%
%\iffalse
%<*driver>
\documentclass{amsdtx}
\begin{document}
\title{The \pkg{upref} package}
\author{American Mathematical Society\\ Michael Downes\\
  updated by Barbara Beeton}
\date{Version \fileversion, \filedate}
\hDocInput{upref.dtx}
\end{document}
%</driver>
%\fi
%
% \maketitle
%
% \MakeShortVerb\|
%
% \section{Introduction}
%
%    This package changes the \cn{ref} command so that it never applies
%    a slanted font shape to its argument, regardless of context. This
%    was the default behavior in \cls{amsart} version 1.1. Starting with
%    \cls{amsart} version 1.2, upright references must be obtained via
%    |\usepackage{upref}|.
%
% \StopEventually{}
%
% \section{Implementation}
%    Give package name, date, version.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{upref}[2004/07/29 v2.01]
%    \end{macrocode}
%
%  \begin{macro}{\@noref}
%    Give a warning if a cited reference isn't defined.
%    \begin{macrocode}
\newcommand{\@noref}[1]{%
  \G@refundefinedtrue
  \nfss@text{\reset@font\bfseries ??}%
  \@latex@warning{Reference `#1' on page \thepage\space undefined}%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@setref}
%    If the current fontshape is italic or slanted, we want to switch to
%    upright/roman for printing the number of a \cn{ref}. This requires
%    changing the \cs{@setref} command.
%
%    Since \cs{@setref} is modified by the \pkg{hyperref} package, delay
%    the definition until \cs{AtBeginDocument}.  Then check whether
%    \pkg{hyperref} is loaded.  If it is, we have to redefine some
%    control sequences that \pkg{hyperref} defined in order to get
%    upright references even in a \pkg{hyperref} environment.
%    [tjk,bnb, 2004/07/29]
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{hyperref}{%
%    \end{macrocode}
%    We overload \cs{Hy@setref@link} as this is where the upright
%    references get clobbered.  Used in overloaded \cs{@setref}.
%    \begin{macrocode}
    \def\Hy@setref@link#1#2#3#4#5#6\@nil#7{%
      \begingroup
      \toks0{\hyper@@link{#5}{#4}}%
      \toks1\@xp{#7{\textup{#1}\hbox{}}{#2}{#3}{#4}{#5}}%
      \edef\x{\endgroup\the\toks0{\the\toks1}}\x
    }%
%    \end{macrocode}
%    We should not have to overload \cs{@setref}, but there is
%    a chance that an author is using an old version of hyperref
%    which does not use \cs{Hy@setref@link} in \cs{@setref}.
%    \begin{macrocode}
    \def\@setref#1#2#3{%
      \ifx#1\relax
        \@xp\protect\@noref{#3}%
      \else
        \@xp\Hy@setref@link#1\@empty\@empty\@nil{#2}%
      \fi
    }%
  }{%
    \def\@setref#1#2#3{\ifx#1\relax
        \protect\@noref{#3}%
      \else
        \protect\textup{\@xp#2#1\hbox{}}%
      \fi
    }%
  }%
}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\@upn}
%    The function \cs{\@upn} is used to force theorem numbers and
%    similar elements to be upright in sloped or italic contexts.
%    If a suitable italic font with upright numbers and punctuation is
%    available, this function should be redefined to be a no-op.
%    \begin{macrocode}
\providecommand\@upn{\textup}
%    \end{macrocode}
%  \end{macro}
%
%    The usual \cs{endinput} to ensure that random garbage at the end of
%    the file doesn't get copied by \fn{docstrip}.
%    \begin{macrocode}
\endinput
%    \end{macrocode}
%
% \CheckSum{61}
% \Finale