Debian Codegraph @

texmf-dist/source/latex/amscls/upref.dtx

raw
1 % \def\filename{upref.dtx}
2 % \def\fileversion{2.04}
3 % \def\filedate{2007/03/14}
4 %
5 % \iffalse meta-comment
6 %
7 % American Mathematical Society
8 % Technical Support
9 % Publications Technical Group
10 % 201 Charles Street
11 % Providence, RI 02904
12 % USA
13 % tel: (401) 455-4080
14 % (800) 321-4267 (USA and Canada only)
15 % fax: (401) 331-3842
16 % email: [email protected]
17 %
18 % Copyright 1996, 2010 American Mathematical Society.
19 %
20 % This work may be distributed and/or modified under the
21 % conditions of the LaTeX Project Public License, either version 1.3c
22 % of this license or (at your option) any later version.
23 % The latest version of this license is in
24 % http://www.latex-project.org/lppl.txt
25 % and version 1.3c or later is part of all distributions of LaTeX
26 % version 2005/12/01 or later.
27 %
28 % This work has the LPPL maintenance status `maintained'.
29 %
30 % The Current Maintainer of this work is the American Mathematical
31 % Society.
32 %
33 % \fi
34 %
35 %\iffalse
36 %<*driver>
37 \documentclass{amsdtx}
38 \begin{document}
39 \title{The \pkg{upref} package}
40 \author{American Mathematical Society\\ Michael Downes\\
41 updated by Barbara Beeton}
42 \date{Version \fileversion, \filedate}
43 \DocInput{upref.dtx}
44 \end{document}
45 %</driver>
46 %\fi
47 %
48 % \maketitle
49 %
50 % \MakeShortVerb\|
51 %
52 % \section{Introduction}
53 %
54 % This package changes the \cn{ref} command so that it never applies
55 % a slanted font shape to its argument, regardless of context. This
56 % was the default behavior in \cls{amsart} version 1.1. Starting with
57 % \cls{amsart} version 1.2, upright references must be obtained via
58 % |\usepackage{upref}|.
59 %
60 % \StopEventually{}
61 %
62 % \section{Implementation}
63 % Give package name, date, version.
64 % \begin{macrocode}
65 \NeedsTeXFormat{LaTeX2e}[1995/06/01]
66 \ProvidesPackage{upref}[2007/03/14 v2.04]
67 % \end{macrocode}
68 %
69 % \begin{macro}{\@noref}
70 % Give a warning if a cited reference isn't defined.
71 % \begin{macrocode}
72 \newcommand{\@noref}[1]{%
73 \G@refundefinedtrue
74 \nfss@text{\reset@font\bfseries ??}%
75 \@latex@warning{Reference `#1' on page \thepage\space undefined}%
76 }
77 % \end{macrocode}
78 % \end{macro}
79 %
80 % \begin{macro}{\@setref}
81 % If the current fontshape is italic or slanted, we want to switch to
82 % upright/roman for printing the number of a \cn{ref}. This requires
83 % changing the \cs{@setref} command.
84 %
85 % Since \cs{@setref} is modified by the \pkg{hyperref} package, delay
86 % the definition until \cs{AtBeginDocument}. Then check whether
87 % \pkg{hyperref} is loaded. If it is, we have to redefine some
88 % control sequences that \pkg{hyperref} defined in order to get
89 % upright references even in a \pkg{hyperref} environment.
90 % [tjk,bnb, 2004/07/29]
91 %
92 % Get around a restriction in an internal AMS package (shaderef) by
93 % equating its command \cs{printref} to \cn{textup}; this applies
94 % consistently regardless of other circumstances that have unwanted
95 % effects. [dmj,bnb, 2005/05/17]
96 % \begin{macrocode}
97 \AtBeginDocument{%
98 \providecommand\printref{\textup}%
99 \@ifpackageloaded{hyperref}{%
100 % \end{macrocode}
101 % We overload \cs{Hy@setref@link} as this is where the upright
102 % references get clobbered. Used in overloaded \cs{@setref}.
103 % \cs{sw@slant} is usually applied by \cn{textup}, but the specials
104 % inserted by the hyperlink get in the way of testing for whether
105 % an italic correction is necessary; restore the test.
106 % [dmj,bnb, 2005/09/22]
107 %
108 % If the link happens to be at the beginning of a paragraph,
109 % \cs{sw@slant} will produce an error, since neither \unpenalty
110 % nor a check for italic correction is valid in vertical mode.
111 % For reasons not apparent, this may also occur in some other
112 % situations, e.g., following a proof heading containing a cross
113 % reference (jams561el). Add \cn{leavevmode} to compensate.
114 % [dmj,bnb, 2007/02/14]
115 % \begin{macrocode}
116 \def\Hy@setref@link#1#2#3#4#5#6\@nil#7{%
117 \begingroup
118 \leavevmode
119 \sw@slant
120 \toks0{\hyper@@link{#5}{#4}}%
121 \toks1\@xp{#7{\printref{#1}\hbox{}}{#2}{#3}{#4}{#5}}%
122 \edef\x{\endgroup\the\toks0{\the\toks1}}\x
123 }%
124 % \end{macrocode}
125 % We should not have to overload \cs{@setref}, but there is
126 % a chance that an author is using an old version of hyperref
127 % which does not use \cs{Hy@setref@link} in \cs{@setref}.
128 % \begin{macrocode}
129 \def\@setref#1#2#3{%
130 \ifx#1\relax
131 \@xp\protect\@noref{#3}%
132 \else
133 \@xp\Hy@setref@link#1\@empty\@empty\@nil{#2}%
134 \fi
135 }%
136 }{%
137 \def\@setref#1#2#3{\ifx#1\relax
138 \protect\@noref{#3}%
139 \else
140 \protect\printref{\@xp#2#1\hbox{}}%
141 \fi
142 }%
143 }%
144 }
145 % \end{macrocode}
146 % \end{macro}
147 %
148 % \begin{macro}{\@upn}
149 % The function \cs{\@upn} is used to force theorem numbers and
150 % similar elements to be upright in sloped or italic contexts.
151 % If a suitable italic font with upright numbers and punctuation is
152 % available, this function should be redefined to be a no-op.
153 % \begin{macrocode}
154 \providecommand\@upn{\textup}
155 % \end{macrocode}
156 % \end{macro}
157 %
158 % The usual \cs{endinput} to ensure that random garbage at the end of
159 % the file doesn't get copied by \fn{docstrip}.
160 % \begin{macrocode}
161 \endinput
162 % \end{macrocode}
163 %
164 % \CheckSum{66}
165 % \Finale