-
Notifications
You must be signed in to change notification settings - Fork 9
/
decls.tex
708 lines (660 loc) · 25.8 KB
/
decls.tex
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
\usepackage{amssymb,amsmath,stmaryrd,mathrsfs}
%% Set this to true before loading if we're using the TAC style file.
%% Note that eventually, TAC requires everything to be in one source file.
\def\definetac{\newif\iftac} % Can't define a \newif inside another \if!
\ifx\tactrue\undefined
\definetac
%% Guess whether we're using TAC by whether \state is defined.
\ifx\state\undefined\tacfalse\else\tactrue\fi
\fi
% Similarly detect beamer
\def\definebeamer{\newif\ifbeamer}
\ifx\beamertrue\undefined
\definebeamer
%% Guess whether we're using Beamer by whether \uncover is defined.
\ifx\uncover\undefined\beamerfalse\else\beamertrue\fi
\fi
% And cleveref
\def\definecref{\newif\ifcref}
\ifx\creftrue\undefined
\definecref
% Default to false
\creffalse
\fi
\iftac\else\usepackage{amsthm}\fi
\usepackage[all,2cell]{xy}
%\UseAllTwocells
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{ed/.style={auto,inner sep=0pt,font=\scriptsize}} %edges
\ifbeamer\else
\usepackage{enumitem}
\usepackage{xcolor}
\definecolor{darkgreen}{rgb}{0,0.45,0}
\iftac\else\usepackage[pagebackref,colorlinks,citecolor=darkgreen,linkcolor=darkgreen]{hyperref}\fi
\fi
\usepackage{mathtools} % for all sorts of things
\usepackage{graphics} % for \scalebox, used in \widecheck
\usepackage{ifmtarg} % used in \jd
\usepackage{microtype}
%\usepackage{color,epsfig}
%\usepackage{fullpage}
%\usepackage{eucal}
%\usepackage{wasysym}
%\usepackage{txfonts} % for \invamp, or for the nice fonts
\usepackage{braket} % for \Set, etc.
\let\setof\Set
\usepackage{url} % for citations to web sites
\usepackage{xspace} % put spaces after a \command in text
%\usepackage{cite} % compress and sort grouped citations (only use with numbered citations)
\ifcref\usepackage{cleveref,aliascnt}\fi
%% If you want to use biblatex, e.g. if a journal requires (Author name YEAR) citations.
% \usepackage[style=authoryear,
% backref=true,
% maxnames=4,
% maxbibnames=99,
% uniquename=false,
% firstinits=true
% ]{biblatex}
% \addbibresource{all.bib}
% \let\cite\parencite
% \DeclareNameAlias{sortname}{last-first}
\makeatletter
\let\ea\expandafter
%% Defining commands that are always in math mode.
\def\mdef#1#2{\ea\ea\ea\gdef\ea\ea\noexpand#1\ea{\ea\ensuremath\ea{#2}\xspace}}
\def\alwaysmath#1{\ea\ea\ea\global\ea\ea\ea\let\ea\ea\csname your@#1\endcsname\csname #1\endcsname
\ea\def\csname #1\endcsname{\ensuremath{\csname your@#1\endcsname}\xspace}}
%% WIDECHECK
\DeclareRobustCommand\widecheck[1]{{\mathpalette\@widecheck{#1}}}
\def\@widecheck#1#2{%
\setbox\z@\hbox{\m@th$#1#2$}%
\setbox\tw@\hbox{\m@th$#1%
\widehat{%
\vrule\@width\z@\@height\ht\z@
\vrule\@height\z@\@width\wd\z@}$}%
\dp\tw@-\ht\z@
\@tempdima\ht\z@ \advance\@tempdima2\ht\tw@ \divide\@tempdima\thr@@
\setbox\tw@\hbox{%
\raise\@tempdima\hbox{\scalebox{1}[-1]{\lower\@tempdima\box
\tw@}}}%
{\ooalign{\box\tw@ \cr \box\z@}}}
%% SIMPLE COMMANDS FOR FONTS AND DECORATIONS
\newcount\foreachcount
\def\foreachletter#1#2#3{\foreachcount=#1
\ea\loop\ea\ea\ea#3\@alph\foreachcount
\advance\foreachcount by 1
\ifnum\foreachcount<#2\repeat}
\def\foreachLetter#1#2#3{\foreachcount=#1
\ea\loop\ea\ea\ea#3\@Alph\foreachcount
\advance\foreachcount by 1
\ifnum\foreachcount<#2\repeat}
% Script: \sA is \mathscr{A}
\def\definescr#1{\ea\gdef\csname s#1\endcsname{\ensuremath{\mathscr{#1}}\xspace}}
\foreachLetter{1}{27}{\definescr}
% Calligraphic: \cA is \mathcal{A}
\def\definecal#1{\ea\gdef\csname c#1\endcsname{\ensuremath{\mathcal{#1}}\xspace}}
\foreachLetter{1}{27}{\definecal}
% Bold: \bA is \mathbf{A}
\def\definebold#1{\ea\gdef\csname b#1\endcsname{\ensuremath{\mathbf{#1}}\xspace}}
\foreachLetter{1}{27}{\definebold}
% Blackboard Bold: \dA is \mathbb{A}
\def\definebb#1{\ea\gdef\csname d#1\endcsname{\ensuremath{\mathbb{#1}}\xspace}}
\foreachLetter{1}{27}{\definebb}
% Fraktur: \fa is \mathfrak{a}, except for \fi; \fA is \mathfrak{A}
\def\definefrak#1{\ea\gdef\csname f#1\endcsname{\ensuremath{\mathfrak{#1}}\xspace}}
\foreachletter{1}{9}{\definefrak}
\foreachletter{10}{27}{\definefrak}
\foreachLetter{1}{27}{\definefrak}
% Sans serif: \ia is \mathsf{a}, except for \if and \in
\def\definesf#1{\ea\gdef\csname i#1\endcsname{\ensuremath{\mathsf{#1}}\xspace}}
\foreachletter{1}{6}{\definesf}
\foreachletter{7}{14}{\definesf}
\foreachletter{15}{27}{\definesf}
\foreachLetter{1}{27}{\definesf}
% Bar: \Abar is \overline{A}, \abar is \overline{a}
\def\definebar#1{\ea\gdef\csname #1bar\endcsname{\ensuremath{\overline{#1}}\xspace}}
\foreachLetter{1}{27}{\definebar}
\foreachletter{1}{8}{\definebar} % \hbar is something else!
\foreachletter{9}{15}{\definebar} % \obar is something else!
\foreachletter{16}{27}{\definebar}
% Tilde: \Atil is \widetilde{A}, \atil is \widetilde{a}
\def\definetil#1{\ea\gdef\csname #1til\endcsname{\ensuremath{\widetilde{#1}}\xspace}}
\foreachLetter{1}{27}{\definetil}
\foreachletter{1}{27}{\definetil}
% Hats: \Ahat is \widehat{A}, \ahat is \widehat{a}
\def\definehat#1{\ea\gdef\csname #1hat\endcsname{\ensuremath{\widehat{#1}}\xspace}}
\foreachLetter{1}{27}{\definehat}
\foreachletter{1}{27}{\definehat}
% Checks: \Achk is \widecheck{A}, \achk is \widecheck{a}
\def\definechk#1{\ea\gdef\csname #1chk\endcsname{\ensuremath{\widecheck{#1}}\xspace}}
\foreachLetter{1}{27}{\definechk}
\foreachletter{1}{27}{\definechk}
% Underline: \uA is \underline{A}, \ua is \underline{a}
\def\defineul#1{\ea\gdef\csname u#1\endcsname{\ensuremath{\underline{#1}}\xspace}}
\foreachLetter{1}{27}{\defineul}
\foreachletter{1}{27}{\defineul}
% Particular commands for typefaces, sometimes with the first letter
% different.
\def\autofmt@n#1\autofmt@end{\mathrm{#1}}
\def\autofmt@b#1\autofmt@end{\mathbf{#1}}
\def\autofmt@d#1#2\autofmt@end{\mathbb{#1}\mathsf{#2}}
\def\autofmt@c#1#2\autofmt@end{\mathcal{#1}\mathit{#2}}
\def\autofmt@s#1#2\autofmt@end{\mathscr{#1}\mathit{#2}}
\def\autofmt@f#1\autofmt@end{\mathsf{#1}}
\def\autofmt@k#1\autofmt@end{\mathfrak{#1}}
% Particular commands for decorations.
\def\autofmt@u#1\autofmt@end{\underline{\smash{\mathsf{#1}}}}
\def\autofmt@U#1\autofmt@end{\underline{\underline{\smash{\mathsf{#1}}}}}
\def\autofmt@h#1\autofmt@end{\widehat{#1}}
\def\autofmt@r#1\autofmt@end{\overline{#1}}
\def\autofmt@t#1\autofmt@end{\widetilde{#1}}
\def\autofmt@k#1\autofmt@end{\check{#1}}
% Defining multi-letter commands. Use this like so:
% \autodefs{\bSet\cCat\cCAT\kBicat\lProf}
\def\auto@drop#1{}
\def\autodef#1{\ea\ea\ea\@autodef\ea\ea\ea#1\ea\auto@drop\string#1\autodef@end}
\def\@autodef#1#2#3\autodef@end{%
\ea\def\ea#1\ea{\ea\ensuremath\ea{\csname autofmt@#2\endcsname#3\autofmt@end}\xspace}}
\def\autodefs@end{blarg!}
\def\autodefs#1{\@autodefs#1\autodefs@end}
\def\@autodefs#1{\ifx#1\autodefs@end%
\def\autodefs@next{}%
\else%
\def\autodefs@next{\autodef#1\@autodefs}%
\fi\autodefs@next}
%% FONTS AND DECORATION FOR GREEK LETTERS
%% the package `mathbbol' gives us blackboard bold greek and numbers,
%% but it does it by redefining \mathbb to use a different font, so that
%% all the other \mathbb letters look different too. Here we import the
%% font with bb greek and numbers, but assign it a different name,
%% \mathbbb, so as not to replace the usual one.
\DeclareSymbolFont{bbold}{U}{bbold}{m}{n}
\DeclareSymbolFontAlphabet{\mathbbb}{bbold}
\newcommand{\dDelta}{\ensuremath{\mathbbb{\Delta}}\xspace}
\newcommand{\done}{\ensuremath{\mathbbb{1}}\xspace}
\newcommand{\dtwo}{\ensuremath{\mathbbb{2}}\xspace}
\newcommand{\dthree}{\ensuremath{\mathbbb{3}}\xspace}
% greek with bars
\newcommand{\albar}{\ensuremath{\overline{\alpha}}\xspace}
\newcommand{\bebar}{\ensuremath{\overline{\beta}}\xspace}
\newcommand{\gmbar}{\ensuremath{\overline{\gamma}}\xspace}
\newcommand{\debar}{\ensuremath{\overline{\delta}}\xspace}
\newcommand{\phibar}{\ensuremath{\overline{\varphi}}\xspace}
\newcommand{\psibar}{\ensuremath{\overline{\psi}}\xspace}
\newcommand{\xibar}{\ensuremath{\overline{\xi}}\xspace}
\newcommand{\ombar}{\ensuremath{\overline{\omega}}\xspace}
% greek with tildes
\newcommand{\altil}{\ensuremath{\widetilde{\alpha}}\xspace}
\newcommand{\betil}{\ensuremath{\widetilde{\beta}}\xspace}
\newcommand{\gmtil}{\ensuremath{\widetilde{\gamma}}\xspace}
\newcommand{\phitil}{\ensuremath{\widetilde{\varphi}}\xspace}
\newcommand{\psitil}{\ensuremath{\widetilde{\psi}}\xspace}
\newcommand{\xitil}{\ensuremath{\widetilde{\xi}}\xspace}
\newcommand{\omtil}{\ensuremath{\widetilde{\omega}}\xspace}
% MISCELLANEOUS SYMBOLS
\let\del\partial
\mdef\delbar{\overline{\partial}}
\let\sm\wedge
\newcommand{\dd}[1]{\ensuremath{\frac{\partial}{\partial {#1}}}}
\newcommand{\inv}{^{-1}}
\newcommand{\dual}{^{\vee}}
\mdef\hf{\textstyle\frac12 }
\mdef\thrd{\textstyle\frac13 }
\mdef\qtr{\textstyle\frac14 }
\let\meet\wedge
\let\join\vee
\let\dn\downarrow
\newcommand{\op}{^{\mathrm{op}}}
\newcommand{\co}{^{\mathrm{co}}}
\newcommand{\coop}{^{\mathrm{coop}}}
\let\adj\dashv
\SelectTips{cm}{}
\newdir{ >}{{}*!/-10pt/\dir{>}} % extra spacing for tail arrows in XYpic
\makeatother
\newcommand{\pushout}[1][dr]{\save*!/#1+1.2pc/#1:(1,-1)@^{|-}\restore}
\newcommand{\pullback}[1][dr]{\save*!/#1-1.2pc/#1:(-1,1)@^{|-}\restore}
\makeatletter
\let\iso\cong
\let\eqv\simeq
\let\cng\equiv
\mdef\Id{\mathrm{Id}}
\mdef\id{\mathrm{id}}
\alwaysmath{ell}
\alwaysmath{infty}
\let\oo\infty
\alwaysmath{odot}
\def\frc#1/#2.{\frac{#1}{#2}} % \frc x^2+1 / x^2-1 .
\mdef\ten{\mathrel{\otimes}}
\let\bigten\bigotimes
\mdef\sqten{\mathrel{\boxtimes}}
\def\lt{<} % For iTex compatibility
\def\gt{>}
%% OPERATORS
\DeclareMathOperator\lan{Lan}
\DeclareMathOperator\ran{Ran}
\DeclareMathOperator\colim{colim}
\DeclareMathOperator\coeq{coeq}
\DeclareMathOperator\eq{eq}
\DeclareMathOperator\Tot{Tot}
\DeclareMathOperator\cosk{cosk}
\DeclareMathOperator\sk{sk}
\DeclareMathOperator\ob{ob}
%\DeclareMathOperator\im{im}
\DeclareMathOperator\Spec{Spec}
\DeclareMathOperator\Ho{Ho}
\DeclareMathOperator\Aut{Aut}
\DeclareMathOperator\End{End}
\DeclareMathOperator\Hom{Hom}
\DeclareMathOperator\Map{Map}
\DeclareMathOperator\dom{dom}
\DeclareMathOperator\cod{cod}
%% ARROWS
% \to already exists
\newcommand{\too}[1][]{\ensuremath{\overset{#1}{\longrightarrow}}}
\newcommand{\ot}{\ensuremath{\leftarrow}}
\newcommand{\oot}[1][]{\ensuremath{\overset{#1}{\longleftarrow}}}
\let\toot\rightleftarrows
\let\otto\leftrightarrows
\let\Impl\Rightarrow
\let\imp\Rightarrow
\let\toto\rightrightarrows
\let\into\hookrightarrow
\let\xinto\xhookrightarrow
\mdef\we{\overset{\sim}{\longrightarrow}}
\mdef\leftwe{\overset{\sim}{\longleftarrow}}
\let\mono\rightarrowtail
\let\leftmono\leftarrowtail
\let\cof\rightarrowtail
\let\leftcof\leftarrowtail
\let\epi\twoheadrightarrow
\let\leftepi\twoheadleftarrow
\let\fib\twoheadrightarrow
\let\leftfib\twoheadleftarrow
\let\cohto\rightsquigarrow
\let\maps\colon
\newcommand{\spam}{\,:\!} % \maps for left arrows
\def\acof{\mathrel{\mathrlap{\hspace{3pt}\raisebox{4pt}{$\scriptscriptstyle\sim$}}\mathord{\rightarrowtail}}}
% diagxy redefines \to, along with \toleft, \two, \epi, and \mon.
%% EXTENSIBLE ARROWS
\let\xto\xrightarrow
\let\xot\xleftarrow
% See Voss' Mathmode.tex for instructions on how to create new
% extensible arrows.
\def\rightarrowtailfill@{\arrowfill@{\Yright\joinrel\relbar}\relbar\rightarrow}
\newcommand\xrightarrowtail[2][]{\ext@arrow 0055{\rightarrowtailfill@}{#1}{#2}}
\let\xmono\xrightarrowtail
\let\xcof\xrightarrowtail
\def\twoheadrightarrowfill@{\arrowfill@{\relbar\joinrel\relbar}\relbar\twoheadrightarrow}
\newcommand\xtwoheadrightarrow[2][]{\ext@arrow 0055{\twoheadrightarrowfill@}{#1}{#2}}
\let\xepi\xtwoheadrightarrow
\let\xfib\xtwoheadrightarrow
% Let's leave the left-going ones until I need them.
%% EXTENSIBLE SLASHED ARROWS
% Making extensible slashed arrows, by modifying the underlying AMS code.
% Arguments are:
% 1 = arrowhead on the left (\relbar or \Relbar if none)
% 2 = fill character (usually \relbar or \Relbar)
% 3 = slash character (such as \mapstochar or \Mapstochar)
% 4 = arrowhead on the left (\relbar or \Relbar if none)
% 5 = display mode (\displaystyle etc)
\def\slashedarrowfill@#1#2#3#4#5{%
$\m@th\thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
\relax#5#1\mkern-7mu%
\cleaders\hbox{$#5\mkern-2mu#2\mkern-2mu$}\hfill
\mathclap{#3}\mathclap{#2}%
\cleaders\hbox{$#5\mkern-2mu#2\mkern-2mu$}\hfill
\mkern-7mu#4$%
}
% Here's the idea: \<slashed>arrowfill@ should be a box containing
% some stretchable space that is the "middle of the arrow". This
% space is created as a "leader" using \cleader<thing>\hfill, which
% fills an \hfill of space with copies of <thing>. Here instead of
% just one \cleader, we use two, with the slash in between (and an
% extra copy of the filler, to avoid extra space around the slash).
\def\rightslashedarrowfill@{%
\slashedarrowfill@\relbar\relbar\mapstochar\rightarrow}
\newcommand\xslashedrightarrow[2][]{%
\ext@arrow 0055{\rightslashedarrowfill@}{#1}{#2}}
\mdef\hto{\xslashedrightarrow{}}
\mdef\htoo{\xslashedrightarrow{\quad}}
\let\xhto\xslashedrightarrow
%% To get a slashed arrow in XYmatrix, do
% \[\xymatrix{A \ar[r]|-@{|} & B}\]
%% To get it in diagxy, do
% \morphism/{@{>}|-*@{|}}/[A`B;p]
%% Here is an \hto for diagxy:
% \def\htopppp/#1/<#2>^#3_#4{\:%
% \ifnum#2=0%
% \setwdth{#3}{#4}\deltax=\wdth \divide \deltax by \ul%
% \advance \deltax by \defaultmargin \ratchet{\deltax}{100}%
% \else \deltax #2%
% \fi%
% \xy\ar@{#1}|-@{|}^{#3}_{#4}(\deltax,0) \endxy%
% \:}%
% \def\htoppp/#1/<#2>^#3{\ifnextchar_{\htopppp/#1/<#2>^{#3}}{\htopppp/#1/<#2>^{#3}_{}}}%
% \def\htopp/#1/<#2>{\ifnextchar^{\htoppp/#1/<#2>}{\htoppp/#1/<#2>^{}}}%
% \def\htoop/#1/{\ifnextchar<{\htopp/#1/}{\htopp/#1/<0>}}%
% \def\hto{\ifnextchar/{\htoop}{\htoop/>/}}%
% LABELED ISOMORPHISMS
\def\xiso#1{\mathrel{\mathrlap{\smash{\xto[\smash{\raisebox{1.3mm}{$\scriptstyle\sim$}}]{#1}}}\hphantom{\xto{#1}}}}
\def\toiso{\xto{\smash{\raisebox{-.5mm}{$\scriptstyle\sim$}}}}
% SHADOWS
\def\shvar#1#2{{\ensuremath{%
\hspace{1mm}\makebox[-1mm]{$#1\langle$}\makebox[0mm]{$#1\langle$}\hspace{1mm}%
{#2}%
\makebox[1mm]{$#1\rangle$}\makebox[0mm]{$#1\rangle$}%
}}}
\def\sh{\shvar{}}
\def\scriptsh{\shvar{\scriptstyle}}
\def\bigsh{\shvar{\big}}
\def\Bigsh{\shvar{\Big}}
\def\biggsh{\shvar{\bigg}}
\def\Biggsh{\shvar{\Bigg}}
% TYPING JUDGMENTS
% Call this macro as \jd{x:A, y:B |- c:C}. It adds (what I think is)
% appropriate spacing, plus auto-sized parentheses around each typing judgment.
\def\jd#1{\@jd#1\ej}
\def\@jd#1|-#2\ej{\@@jd#1,,\;\vdash\;\left(#2\right)}
\def\@@jd#1,{\@ifmtarg{#1}{\let\next=\relax}{\left(#1\right)\let\next=\@@@jd}\next}
\def\@@@jd#1,{\@ifmtarg{#1}{\let\next=\relax}{,\,\left(#1\right)\let\next=\@@@jd}\next}
% Here's a version which puts a line break before the turnstyle.
\def\jdm#1{\@jdm#1\ej}
\def\@jdm#1|-#2\ej{\@@jd#1,,\\\vdash\;\left(#2\right)}
% Make an actual comma that doesn't separate typing judgments (e.g. A,B,C : Type).
\def\cm{,}
%% SKIPIT in TikZ
% See http://tex.stackexchange.com/questions/3513/draw-only-some-segments-of-a-path-in-tikz
\long\def\my@drawfill#1#2;{%
\@skipfalse
\fill[#1,draw=none] #2;
\@skiptrue
\draw[#1,fill=none] #2;
}
\newif\if@skip
\newcommand{\skipit}[1]{\if@skip\else#1\fi}
\newcommand{\drawfill}[1][]{\my@drawfill{#1}}
%% TODO: This \autoref in TAC doesn't work with figures (and anything
%% else other than theorems).
%%%% THEOREM-TYPE ENVIRONMENTS, hacked to
%%% (a) number all with the same numbers, and
%%% (b) have the right names.
%% The following code should work in TAC or out of it, and with
%% hyperref or without it. In all cases, we use \label to label
%% things and \autoref to refer to them (ordinary \ref declines to
%% include names). The non-hyperref label and reference hack is from
%% Mike Mandell, I believe.
\newif\ifhyperref
\@ifpackageloaded{hyperref}{\hyperreftrue}{\hyperreffalse}
\iftac
%% In the TAC style, all theorems are actually subsections. So
%% the hyperref \autoref doesn't work and we have to use our own code
%% in any case. We also have to hook into the \state macros instead
%% of \@thm since those are what know about the current theorem type.
\let\your@state\state
\def\state#1{\my@state#1}
\def\my@state#1.{\gdef\currthmtype{#1}\your@state{#1.}}
\let\your@staterm\staterm
\def\staterm#1{\my@staterm#1}
\def\my@staterm#1.{\gdef\currthmtype{#1}\your@staterm{#1.}}
\let\@defthm\newtheorem
\def\switchtotheoremrm{\let\@defthm\newtheoremrm}
\def\defthm#1#2#3{\@defthm{#1}{#2}} % Ignore the third argument (for cleveref only)
% Start out \currthmtype as empty
\def\currthmtype{}
% In a bit, we're going to redefine \label so that \label{athm} will
% also make a label "label@name@athm" which is the current value of
% \currthmtype. Now \autoref{athm} just adds a reference to this in
% front of the reference.
\ifhyperref
\def\autoref#1{\ref*{label@name@#1}~\ref{#1}}
\else
\def\autoref#1{\ref{label@name@#1}~\ref{#1}}
\fi
% This has to go AFTER the \begin{document} because apparently
% hyperref resets the definition of \label at that point.
\AtBeginDocument{%
% Save the old definition of \label
\let\old@label\label%
% Redefine \label so that \label{athm} will also make a label
% "label@name@athm" which is the current value of \currthmtype.
\def\label#1{%
{\let\your@currentlabel\@currentlabel%
\edef\@currentlabel{\currthmtype}%
\old@label{label@name@#1}}%
\old@label{#1}}
}
\let\cref\autoref
\else\ifcref
% Cleveref does most of it for us.
\def\defthm#1#2#3{%
%% Ensure all theorem types are numbered with the same counter
\newaliascnt{#1}{thm}
\newtheorem{#1}[#1]{#2}
\aliascntresetthe{#1}
%% This command tells cleveref's \cref what to call things
\crefname{#1}{#2}{#3}% following brace must be on separate line to support poorman cleveref sed file
}
% This one has its own number (e.g. exercises)
\def\defnewthm#1#2#3{%
\newtheorem{#1}{#2}[section]
%% This command tells cleveref's \cref what to call things
\crefname{#1}{#2}{#3}% following brace must be on separate line to support poorman cleveref sed file
}
% \let\autoref\cref % May want to use \autoref for xr-ed links
\else
% In non-TAC styles without cleveref, theorems have their own counters and so the
% hyperref \autoref works, if hyperref is loaded.
\ifhyperref
%% If we have hyperref, then we have to make sure all the theorem
%% types appear to use different counters so that hyperref can tell
%% them apart. However, we want them actually to use the same
%% counter, so we don't have both Theorem 9.1 and Definition 9.1.
\def\defthm#1#2#3{% Ignore the third argument (for cleveref only)
%% All types of theorems are number inside sections
\newtheorem{#1}{#2}[section]%
%% This command tells hyperref's \autoref what to call things
\expandafter\def\csname #1autorefname\endcsname{#2}%
%% This makes all the theorem counters actually the same counter
\expandafter\let\csname c@#1\endcsname\c@thm}
\else
%% Without hyperref, we have to roll our own. This code is due to
%% Mike Mandell. First, all theorems can now "officially" use the
%% same counter.
\def\defthm#1#2#3{\newtheorem{#1}[thm]{#2}} % Ignore the third argument (for cleveref only)
%% Save the label- and theorem-making commands
\ifx\SK@label\undefined\let\SK@label\label\fi
\let\old@label\label
\let\your@thm\@thm
%% Save the current type of theorem whenever we start one
\def\@thm#1#2#3{\gdef\currthmtype{#3}\your@thm{#1}{#2}{#3}}
%% Start that out as empty
\def\currthmtype{}
%% Redefine \label so that \label{athm} defines, in addition to a
%% label "athm" pointing to "9.1," a label "athm@" pointing to
%% "Theorem 9.1."
\def\label#1{{\let\your@currentlabel\@currentlabel\def\@currentlabel%
{\currthmtype~\your@currentlabel}%
\SK@label{#1@}}\old@label{#1}}
%% Now \autoref just looks at "athm@" instead of "athm."
\def\autoref#1{\ref{#1@}}
\fi
\let\cref\autoref
\fi\fi
%% Now the code that works in all cases. Note that TAC allows the
%% optional arguments, but ignores them. It also defines environments
%% called "theorem," etc.
\newtheorem{thm}{Theorem}[section]
\ifcref
\crefname{thm}{Theorem}{Theorems}
\else
\newcommand{\thmautorefname}{Theorem}
\fi
\defthm{cor}{Corollary}{Corollaries}
\defthm{prop}{Proposition}{Propositions}
\defthm{lem}{Lemma}{Lemmas}
\defthm{sch}{Scholium}{Scholia}
\defthm{assume}{Assumption}{Assumptions}
\defthm{claim}{Claim}{Claims}
\defthm{conj}{Conjecture}{Conjectures}
\defthm{hyp}{Hypothesis}{Hypotheses}
\defthm{princ}{Principle}{Principles}
\defthm{conv}{Convention}{Conventions}
\defthm{defnthm}{Definition/Theorem}{Definition/Theorems}
\iftac\switchtotheoremrm\else\theoremstyle{definition}\fi
\defthm{defn}{Definition}{Definitions}
\defthm{notn}{Notation}{Notations}
\iftac\switchtotheoremrm\else\theoremstyle{remark}\fi
\defthm{rmk}{Remark}{Remarks}
\defthm{eg}{Example}{Examples}
\defthm{egs}{Examples}{Examples}
\defthm{ceg}{Counterexample}{Counterexamples}
\defnewthm{@ex}{Exercise}{Exercises}
\ifcref
% Display format for sections
\crefformat{section}{\S#2#1#3}
\Crefformat{section}{Section~#2#1#3}
\crefrangeformat{section}{\S\S#3#1#4--#5#2#6}
\Crefrangeformat{section}{Sections~#3#1#4--#5#2#6}
\crefmultiformat{section}{\S\S#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
\Crefmultiformat{section}{Sections~#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
\crefrangemultiformat{section}{\S\S#3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}
\Crefrangemultiformat{section}{Sections~#3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}
% Display format for appendices
\crefformat{appendix}{Appendix~#2#1#3}
\Crefformat{appendix}{Appendix~#2#1#3}
\crefrangeformat{appendix}{Appendices~#3#1#4--#5#2#6}
\Crefrangeformat{appendix}{Appendices~#3#1#4--#5#2#6}
\crefmultiformat{appendix}{Appendices~#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
\Crefmultiformat{appendix}{Appendices~#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
\crefrangemultiformat{appendix}{Appendices~#3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}
\Crefrangemultiformat{appendix}{Appendices~#3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}
\crefformat{subappendix}{\S#2#1#3}
\Crefformat{subappendix}{Section~#2#1#3}
\crefrangeformat{subappendix}{\S\S#3#1#4--#5#2#6}
\Crefrangeformat{subappendix}{Sections~#3#1#4--#5#2#6}
\crefmultiformat{subappendix}{\S\S#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
\Crefmultiformat{subappendix}{Sections~#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
\crefrangemultiformat{subappendix}{\S\S#3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}
\Crefrangemultiformat{subappendix}{Sections~#3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}{ and~#3#1#4--#5#2#6}
% Display format for parts
\crefname{part}{Part}{Parts}
% Display format for figures
\crefname{figure}{Figure}{Figures}
\fi
% \qedhere for TAC
\iftac
\let\qed\endproof
\let\your@endproof\endproof
\def\my@endproof{\your@endproof}
\def\endproof{\my@endproof\gdef\my@endproof{\your@endproof}}
\def\qedhere{\tag*{\endproofbox}\gdef\my@endproof{\relax}}
\fi
% Make the optional arguments to TAC's \proof behave like everyone else's
\iftac
\def\pr@@f[#1]{\subsubsection*{\sc #1.}}
\fi
% How to get QED symbols inside equations at the end of the statements
% of theorems. AMS LaTeX knows how to do this inside equations at the
% end of *proofs* with \qedhere, and at the end of the statement of a
% theorem with \qed (meaning no proof will be given), but it can't
% seem to combine the two. Use this instead.
\def\thmqedhere{\expandafter\csname\csname @currenvir\endcsname @qed\endcsname}
\ifbeamer\else
\renewcommand{\theenumi}{(\alph{enumi})}
\renewcommand{\labelenumi}{\theenumi}
\renewcommand{\theenumii}{(\roman{enumii})}
\renewcommand{\labelenumii}{\theenumii}
\fi
% Left margins for enumitem
\ifbeamer\else
\setitemize[1]{leftmargin=2em}
\setenumerate[1]{leftmargin=*}
\fi
% Also number formulas with the theorem counter
\iftac
\let\c@equation\c@subsection
\else
\let\c@equation\c@thm
\fi
\numberwithin{equation}{section}
% Only show numbers for equations that are actually referenced (or
% whose tags are specified manually) - uses mathtools. All equations
% need to be referenced with \eqref, not \ref, for this to work!
\ifcref\else
\@ifpackageloaded{mathtools}{\mathtoolsset{showonlyrefs,showmanualtags}}{}
\fi
% GREEK LETTERS, ETC.
\alwaysmath{alpha}
\alwaysmath{beta}
\alwaysmath{gamma}
\alwaysmath{Gamma}
\alwaysmath{delta}
\alwaysmath{Delta}
\alwaysmath{epsilon}
\mdef\ep{\varepsilon}
\alwaysmath{zeta}
\alwaysmath{eta}
\alwaysmath{theta}
\alwaysmath{Theta}
\alwaysmath{iota}
\alwaysmath{kappa}
\alwaysmath{lambda}
\alwaysmath{Lambda}
\alwaysmath{mu}
\alwaysmath{nu}
\alwaysmath{xi}
\alwaysmath{pi}
\alwaysmath{rho}
\alwaysmath{sigma}
\alwaysmath{Sigma}
\alwaysmath{tau}
\alwaysmath{upsilon}
\alwaysmath{Upsilon}
\alwaysmath{phi}
\alwaysmath{Pi}
\alwaysmath{Phi}
\mdef\ph{\varphi}
\alwaysmath{chi}
\alwaysmath{psi}
\alwaysmath{Psi}
\alwaysmath{omega}
\alwaysmath{Omega}
\let\al\alpha
\let\be\beta
\let\gm\gamma
\let\Gm\Gamma
\let\de\delta
\let\De\Delta
\let\si\sigma
\let\Si\Sigma
\let\om\omega
\let\ka\kappa
\let\la\lambda
\let\La\Lambda
\let\ze\zeta
\let\th\theta
\let\Th\Theta
\let\vth\vartheta
\let\Om\Omega
%% Include or exclude solutions
% This code is basically copied from version.sty, except that when the
% solutions are included, we put them in a `proof' environment as
% well. To include solutions, say \includesolutions; to exclude them
% say \excludesolutions.
% \begingroup
%
% \catcode`{=12\relax\catcode`}=12\relax%
% \catcode`(=1\relax \catcode`)=2\relax%
% \gdef\includesolutions(\newenvironment(soln)(\begin(proof)[Solution])(\end(proof)))%
% \gdef\excludesolutions(%
% \gdef\soln(\@bsphack\catcode`{=12\relax\catcode`}=12\relax\soln@NOTE)%
% \long\gdef\soln@NOTE##1\end{soln}(\solnEND@NOTE)%
% \gdef\solnEND@NOTE(\@esphack\end(soln))%
% )%
% \endgroup
\makeatother
% Local Variables:
% mode: latex
% TeX-master: ""
% End: