Debian Codegraph @

texmf-dist/source/latex/amsmath/amscd.dtx

raw
1 %
2 % \iffalse meta-comment
3 %
4 % Copyright (C) 1995, 1999 American Mathematical Society.
5 % Copyright (C) 2016-2025 LaTeX Project and American Mathematical Society.
6 %
7 % This work may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either version 1.3c
9 % of this license or (at your option) any later version.
10 % The latest version of this license is in
11 % https://www.latex-project.org/lppl.txt
12 % and version 1.3c or later is part of all distributions of LaTeX
13 % version 2005/12/01 or later.
14 %
15 % This work has the LPPL maintenance status `maintained'.
16 %
17 % The Current Maintainer of this work is the LaTeX Project.
18 %
19 % \fi
20 %
21 %\iffalse
22 %<*driver>
23 \documentclass{amsdtx}
24 \def\MaintainedByLaTeXTeam#1{%
25 \begin{center}%
26 \fbox{\fbox{\begin{tabular}{@{}l@{}}%
27 This file is maintained by the \LaTeX{} Project team.\\%
28 Bug reports can be opened (category \texttt{#1}) at\\%
29 \url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}}
30 \usepackage{amscd}
31 \GetFileInfo{amscd.sty}
32 % Dummy citation to avoid error in an example.
33 \bibcite{fre:cichon}{C}
34 \begin{document}
35 \title{The \pkg{amscd} package}
36 \author{Frank Mittelbach\and Rainer Sch\"opf\and Michael Downes}
37 \date{Version \fileversion, \filedate}
38 \DocInput{amscd.dtx}
39 \end{document}
40 %</driver>
41 %\fi
42 %
43 % \maketitle
44 % \MaintainedByLaTeXTeam{amslatex}
45 %
46 % \MakeShortVerb\|
47 % \newcommand{\operatorname}[1]{\mathop{\mathrm{#1}}}
48 % \newcommand{\per}{\operatorname{per}}
49 % \newcommand{\cov}{\operatorname{cov}}
50 % \newcommand{\non}{\operatorname{non}}
51 % \newcommand{\cf}{\operatorname{cf}}
52 % \newcommand{\add}{\operatorname{add}}
53 % \newcommand{\End}{\operatorname{End}}
54 %
55 % \section{Introduction}
56 %
57 % The \pkg{amscd} package provides a \env{CD} environment that
58 % emulates the commutative diagram capabilities of \amstex/ version
59 % 2.x. This means that only simple rectangular diagrams are
60 % supported, with no diagonal arrows or more exotic features. Many
61 % users will be better served by one of the more powerful diagram
62 % packages such as \pkg{diagram}, \pkg{xypic}, or \pkg{kuvio}.
63 %
64 % Example:
65 % \begin{equation}\begin{CD}
66 % S^{{\mathcal{W}}_\Lambda}\otimes T @>j>> T\\
67 % @VVV @VV{\End P}V\\
68 % (S\otimes T)/I @= (Z\otimes T)/J
69 % \end{CD}\end{equation}
70 % \begin{verbatim}
71 % \begin{equation}\begin{CD}
72 % S^{{\mathcal{W}}_\Lambda}\otimes T @>j>> T\\
73 % @VVV @VV{\End P}V\\
74 % (S\otimes T)/I @= (Z\otimes T)/J
75 % \end{CD}\end{equation}
76 % \end{verbatim}
77 % (assuming \cn{End} is defined as an `operator name'.
78 %
79 % Another example:
80 %
81 % We will make liberal use of Cichon's Diagram \cite{fre:cichon}:
82 % \begin{equation}
83 % \begin{CD}
84 % \cov(\mathcal{L}) @>>> \non(\mathcal{K}) @>>> \cf(\mathcal{K}) @>>>
85 % \cf(\mathcal{L})\\
86 % @VVV @AAA @AAA @VVV\\
87 % \add(\mathcal{L}) @>>> \add(\mathcal{K}) @>>> \cov(\mathcal{K}) @>>>
88 % \non(\mathcal{L})
89 % \end{CD}\end{equation}
90 % \begin{verbatim}
91 % \begin{equation}\begin{CD}
92 % \cov(\mathcal{L}) @>>> \non(\mathcal{K}) @>>> \cf(\mathcal{K}) @>>>
93 % \cf(\mathcal{L})\\
94 % @VVV @AAA @AAA @VVV\\
95 % \add(\mathcal{L}) @>>> \add(\mathcal{K}) @>>> \cov(\mathcal{K}) @>>>
96 % \non(\mathcal{L})
97 % \end{CD}\end{equation}
98 % \end{verbatim}
99 %
100 % \MaybeStop{}
101 %
102 % Standard package info.
103 % \begin{macrocode}
104 \NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
105 [1994/12/01]% LaTeX date must December 1994 or later
106 \ProvidesPackage{amscd}[2017/04/14 v2.1 AMS Commutative Diagrams]
107 % \end{macrocode}
108 % \begin{macrocode}
109 \RequirePackage{amsgen}
110 % \end{macrocode}
111 % Better not to redefine \verb|\math@cr| if it is already defined,
112 % because for CD use only we want to omit the part of the code
113 % related to \verb|\dspbrk@lvl| (see \fn{amsmath.sty}).
114 %
115 % [mjd,1999/11/04] These definitions have gone somewhat obsolete; but
116 % we had probably better leave them as they are for backward
117 % compatibility.
118 % \begin{macrocode}
119 \@ifundefined{math@cr}{%
120 \def\math@cr{{\ifnum0=`}\fi
121 \@ifstar{\global\@eqpen\@M\math@cr@}%
122 {\global\@eqpen\interdisplaylinepenalty \math@cr@}}
123 % \end{macrocode}
124 % The following section merely duplicates some code from the
125 % \pkg{amsmath} package, in case the \pkg{amscd} package is used by
126 % itself. For documentation of the code refer to \fn{amsmath.dtx}.
127 % \begin{macrocode}
128 \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}}
129 \def\math@cr@@[#1]{\ifnum0=`{\fi}\math@cr@@@
130 \noalign{\vskip#1\relax}}
131 \def\restore@math@cr{\def\math@cr@@@{\cr}}
132 }{}
133 \restore@math@cr
134 % \end{macrocode}
135 % [mjd,1999/11/04] These definitions too are somewhat obsolete;
136 % but we had probably better leave them as they are for backward
137 % compatibility.
138 % \begin{macrocode}
139 \@ifundefined{rightarrowfill@}{
140 \def\rightarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@
141 $#1\copy\z@\mkern-6mu\cleaders
142 \hbox{$#1\mkern-2mu\box\z@\mkern-2mu$}\hfill
143 \mkern-6mu\mathord\rightarrow$}
144 \def\leftarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@
145 $#1\mathord\leftarrow\mkern-6mu\cleaders
146 \hbox{$#1\mkern-2mu\copy\z@\mkern-2mu$}\hfill
147 \mkern-6mu\box\z@$}
148 \def\leftrightarrowfill@#1{\m@th\setboxz@h{$#1-$}\ht\z@\z@
149 $#1\mathord\leftarrow\mkern-6mu\cleaders
150 \hbox{$#1\mkern-2mu\box\z@\mkern-2mu$}\hfill
151 \mkern-6mu\mathord\rightarrow$}
152 }{}
153 % \end{macrocode}
154 %
155 % \begin{macrocode}
156 \def\atdef@#1{\expandafter\def\csname\space @\string#1\endcsname}
157 \@ifundefined{Iat}{%
158 \DeclareRobustCommand{\Iat}{\FN@\at@}
159 }{}
160 \begingroup \catcode`\@=\active
161 % \end{macrocode}
162 % Define math \qc{\@} to replicate its mathcode-dictated behavior.
163 % This is in case \qc{\@} occurs outside of \env{CD}.
164 % \begin{macrocode}
165 \csname if\string @compatibility\endcsname
166 \else \fam=\mathcode`\@
167 \xdef @{\mathchar\number\fam\space }
168 \fi
169 \gdef\CDat{\let @=\Iat}
170 \endgroup
171 \mathcode`\@="8000 % make @ pseudo-active in math
172 \def\at@{\let\next@\at@@
173 \ifcat\noexpand\next a\else
174 \ifcat\noexpand\next0\else
175 \ifcat\noexpand\next\relax\else
176 \let\next@\at@@@\fi\fi\fi\next@}
177 \def\at@@#1{\expandafter
178 \ifx\csname\space @\string#1\endcsname\relax
179 \DN@{\at@@@#1}%
180 \else
181 \DN@{\csname\space @\string#1\endcsname}%
182 \fi\next@}%
183 % \end{macrocode}
184 % The following items should be defined only if they are not
185 % already defined, either to leave the package name untouched (in
186 % the case of \cs{PackageError}) or to avoid redundant allocation
187 % of token or dimen registers.
188 % \begin{macrocode}
189 \@ifundefined{default@tag}{%
190 \def\default@tag{%
191 \def\tag{\PackageError{amscd}{\protect\tag\space not allowed
192 here}\@eha}}%
193 }{}%
194 \@ifundefined{at@@@}{%
195 \def\at@@@{\PackageError{amscd}{\Invalid@@ @}{\the\athelp@}\char64\relax}
196 }{}
197 \@ifundefined{athelp@}{\csname newhelp\endcsname\athelp@
198 {Only certain combinations beginning with @ make sense to me.^^J%
199 I'll assume you wanted @@ for a printed @.}}{}
200 \@ifundefined{minaw@}{\newdimen\minaw@}{}
201 \@ifundefined{bigaw@}{\newdimen\bigaw@}{}
202 % \end{macrocode}
203 %
204 % Assignment of a couple of dimensions, and initialization of
205 % \verb=\ampersand@=. We check to see if we need to define
206 % \verb=\minaw@= and \verb=\bigaw@=.
207 % \begin{macrocode}
208 \[email protected]
209 \newdimen\minCDarrowwidth
210 \minCDarrowwidth2.5pc
211 \newif\ifCD@
212 \let\ampersand@\relax
213 % \end{macrocode}
214 %
215 % Added \verb|\restore@math@cr\default@tag| to fix line numbering
216 % problems, 7-JUN-1991. Suggested by I.~Zakharevich.
217 % \begin{macrocode}
218 \newenvironment{CD}{%
219 \CDat
220 \bgroup\relax\iffalse{\fi\let\ampersand@&\iffalse}\fi
221 \CD@true\vcenter\bgroup\let\\\math@cr\restore@math@cr\default@tag
222 \tabskip\z@skip\baselineskip20\ex@
223 \lineskip3\ex@\lineskiplimit3\ex@\halign\bgroup
224 &\hfill$\m@th##$\hfill\crcr
225 }{%
226 \crcr\egroup\egroup\egroup
227 }
228 % \end{macrocode}
229 %
230 % \begin{macro}{\CD@check}
231 % This check is used by all macros that must not appear outside the
232 % \env{CD} environment. The first argument is the symbol to be used
233 % after \verb+@+, the second one the action to be performed.
234 %
235 % Once again we use the trick of defining a temporary control
236 % sequence \verb+\next@+ and calling it after the final \verb+\fi+.
237 % This is not absolutely necessary, but it ensures that the
238 % conditional text is processed in one and the same column
239 % of the enclosing alignment.
240 % \begin{macrocode}
241 \def\CD@check#1#2{\ifCD@\DN@{#2}\else
242 \DN@{\PackageError{amscd}{@\protect#1 not
243 allowed outside of the CD environment}\@eha}%
244 \fi\next@}
245 % \end{macrocode}
246 % \end{macro}
247 %
248 % \begin{macrocode}
249 \atdef@>#1>#2>{\ampersand@
250 \ifCD@ \global\bigaw@\minCDarrowwidth \else \global\bigaw@\minaw@ \fi
251 \setboxz@h{$\m@th\scriptstyle\;{#1}\;\;$}%
252 \ifdim\wdz@>\bigaw@\global\bigaw@\wdz@\fi
253 % \end{macrocode}
254 % If \verb|#2| is empty we can save some work.
255 % \begin{macrocode}
256 \@ifnotempty{#2}{\setbox\@ne\hbox{$\m@th\scriptstyle\;{#2}\;\;$}%
257 \ifdim\wd\@ne>\bigaw@\global\bigaw@\wd\@ne\fi}%
258 \ifCD@\enskip\fi
259 \mathrel{\mathop{\hbox to\bigaw@{\rightarrowfill@\displaystyle}}%
260 \limits^{#1}\@ifnotempty{#2}{_{#2}}}%
261 \ifCD@\enskip\fi \ampersand@}
262 %
263 \atdef@<#1<#2<{\ampersand@
264 \ifCD@ \global\bigaw@\minCDarrowwidth \else \global\bigaw@\minaw@ \fi
265 \setboxz@h{$\m@th\scriptstyle\;\;{#1}\;$}%
266 \ifdim\wdz@>\bigaw@ \global\bigaw@\wdz@ \fi
267 \@ifnotempty{#2}{\setbox\@ne\hbox{$\m@th\scriptstyle\;\;{#2}\;$}%
268 \ifdim\wd\@ne>\bigaw@ \global\bigaw@\wd\@ne \fi}%
269 \ifCD@\enskip\fi
270 \mathrel{\mathop{\hbox to\bigaw@{\leftarrowfill@\displaystyle}}%
271 \limits^{#1}\@ifnotempty{#2}{_{#2}}}%
272 \ifCD@\enskip\fi \ampersand@}
273 % \end{macrocode}
274 %
275 % Variants of the above two arrows, using \verb|(| and \verb|)|
276 % characters instead of \verb|<| and \verb|>| characters, are
277 % provided for those whose keyboards don't have the latter.
278 % \begin{macrocode}
279 \begingroup \catcode`\~=\active \lccode`\~=`\@
280 \lowercase{%
281 \global\atdef@)#1)#2){~>#1>#2>}
282 \global\atdef@(#1(#2({~<#1<#2<}
283 }% end lowercase
284 \endgroup
285 % \end{macrocode}
286 %
287 % \begin{macrocode}
288 \atdef@ A#1A#2A{\CD@check{A..A..A}{\llap{$\m@th\vcenter{\hbox
289 {$\scriptstyle#1$}}$}\Big\uparrow
290 \rlap{$\m@th\vcenter{\hbox{$\scriptstyle#2$}}$}&&}}
291 %
292 \atdef@ V#1V#2V{\CD@check{V..V..V}{\llap{$\m@th\vcenter{\hbox
293 {$\scriptstyle#1$}}$}\Big\downarrow
294 \rlap{$\m@th\vcenter{\hbox{$\scriptstyle#2$}}$}&&}}
295 %
296 \atdef@={\CD@check={&\enskip\mathrel
297 {\vbox{\hrule\@width\minCDarrowwidth\vskip2\ex@\hrule\@width
298 \minCDarrowwidth}}\enskip&}}
299 %
300 \atdef@|{\CD@check|{\Big\Vert&&}}
301 %
302 \atdef@\vert{\CD@check\vert{\Big\Vert&&}}
303 %
304 \atdef@.{\CD@check.{&&}}
305 % \end{macrocode}
306 %
307 % The \cn{pretend} command has weird syntax that doesn't fit well
308 % with standard \latex/ syntax so we leave it undone, at least for
309 % now. [mjd,1994/10/27]
310 % \begin{macrocode}
311 %\def\pretend#1\haswidth#2{\setboxz@h{$\m@th\scriptstyle{#2}$}\hbox
312 % to\wdz@{\hfill$\m@th\scriptstyle{#1}$\hfill}}
313 % \end{macrocode}
314 %
315 % The usual \cs{endinput} to ensure that random garbage at the end of
316 % the file doesn't get copied by \fn{docstrip}.
317 % \begin{macrocode}
318 \endinput
319 % \end{macrocode}
320 %
321 % \CheckSum{459}
322 % \Finale