-
Notifications
You must be signed in to change notification settings - Fork 0
/
apc-basic.sty
390 lines (302 loc) · 11.3 KB
/
apc-basic.sty
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
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\ProvidesPackage{apc-basic}
%Load standard packages, fontspec, etc.
\usepackage{amsmath,amsthm}
\usepackage[MnSymbol]{mathspec}
\usepackage{lineno}
\usepackage{datetime}
% \usepackage{seqsplit}
\usepackage{linguex}
\usepackage{hyperref}
\usepackage[overload]{textcase}
\urlstyle{rm}
% \usepackage{color}
\usepackage[dvipsnames]{xcolor}
% \usepackage{colornames}
% The following package makes prettier tables. We're all about the bling!
\usepackage{booktabs}
% The units package provides nice, non-stacked fractions and better spacing
% for units.
\usepackage{units}
% The fancyvrb package lets us customize the formatting of verbatim
% environments. We use a slightly smaller font.
\usepackage{fancyvrb}
\fvset{fontsize=\normalsize}
% Small sections of multiple columns
\usepackage{multicol}
% A bit more flexibility to avoid overfull boxes
\tolerance=200
\setlength{\emergencystretch}{2em}
% ===============================
% Use author and name from tex file to set metadata.
% ===============================
\AtBeginDocument{
\makeatletter
\hypersetup{
pdftitle = {\@title},
pdfauthor = {\@author}
}
\makeatother
}
% =============================================================================
% Typography options for XeLaTeX. Using: Minion Pro, Myriad Pro, and Pragmata.
% =============================================================================
\setmainfont[Mapping=tex-text]{Minion Pro}
\setromanfont[Mapping=tex-text,Numbers=OldStyle,Ligatures={Common},SmallCapsFeatures = {LetterSpace=3.0}]{Minion Pro}
\setsansfont[Mapping=tex-text,Scale=MatchLowercase]{Myriad Pro}
\setmonofont[Mapping=tex-text,Scale=MatchLowercase]{PragmataPro}
\setmathsfont(Digits,Latin){Minion Pro}
\setmathsf[Scale=MatchLowercase]{Myriad Pro}
\setmathtt[Scale=MatchLowercase]{PragmataPro}
\setmathbb[Scale=MatchUppercase]{msbm10}
% =============================================================================
% CUSTOM COMMANDS
% =============================================================================
% Sent blackboard font using \dfbb
%\newcommand{\dfblackboard}{\setmathbb[Scale=MatchUppercase]{msbm10}}
% Counterfactual conditional
\AtBeginDocument{
\DeclareSymbolFont{symbolsC}{U}{txsyc}{m}{n}
\DeclareMathSymbol{\boxright}{\mathrel}{symbolsC}{128}
}
% Change autoref feature so that it uses \S instead of `section'; eliminate space between \S and section number; use `fn' instead of `footnote'.
\def\Snospace~{\S{}}
\renewcommand*\sectionautorefname{\Snospace}
\renewcommand*\subsectionautorefname{\Snospace}
\renewcommand*\footnoteautorefname{fn.}
% Allow for labels pointing to arbitrary points in the file
\newcommand{\hlabel}[1]{\phantomsection\label{#1}}
% Blank Footnote:
% Use \symbolfootnote[0]{Footnote text} for a blank footnote.
% Useful for initial acknowledgment note.
\long\def\symbolfootnote[#1]#2{\begingroup%
\def\thefootnote{\fnsymbol{footnote}}\footnote[#1]{#2}\endgroup}
\newcommand{\ack}[1]{\symbolfootnote{#1}}
% Ampersand
\newcommand{\amper}{{\itshape \&}\xspace}
%% Small quote environment
\newenvironment{smquote}{\begin{small}\begin{quote}}{\end{quote}\end{small}}
\newcommand{\allcaps}[1]{\textsc{\MakeTextUppercase{#1}}}
\newcommand{\smallcaps}[1]{\textsc{\MakeTextLowercase{#1}}}
\renewcommand{\firstrefdash}{}
% =============================================================================
% Redefine formatting of footnotes and block quotes
% =============================================================================
%Format footnotes:
\setlength{\footmarkwidth}{-0.3em}
\setlength{\footmarksep}{-\footmarkwidth}
% \footmarkstyle{{#1}}
% Reformat quote environment
\usepackage{etoolbox}
\patchcmd{\quote}{\rightmargin}{\leftmargin 0em \rightmargin}{}{}
\AtBeginEnvironment{quote}{\small}
% =============================================================================
% Bibliography options for biblatex
% =============================================================================
\usepackage[style=authoryear-comp,natbib,backend=bibtex,sorting=nyt,firstinits,url=false,doi=false,isbn=false,useprefix=false,sortcites=true]{biblatex}
% \usepackage[style=authortitle-comp,sorting=nyt,firstinits,natbib,url=false,doi=false,isbn=false,backend=bibtex]{biblatex}
% Removed option firstinits
\AtBeginDocument{\toggletrue{blx@useprefix}}
\AtBeginBibliography{\togglefalse{blx@useprefix}}
%Clear day and month fields; clear `eprint'.
\AtEveryBibitem{
\clearfield{day}
\clearfield{month}
\clearfield{endday}
\clearfield{endmonth}
\clearfield{eprint}
}
%Make references font smaller.
\renewcommand{\bibfont}{\normalfont\small}
% Remove comma between author and year in citations.
\renewcommand{\nameyeardelim}{ }
% Redefine dash for recurring author to make it longer than an em dash.
% \renewcommand*\bibnamedash{\rule[0.5ex]{23pt}{0.3pt} }
\renewcommand*\bibnamedash{\rule[0.48ex]{3em}{0.14ex}\space}
% Turn titles into hyperlinks using data from the url field and removes quotation mark around titles in article, incollection, inproceedings, and unpublished. Also, treat thesis title as book title.
% NOTE: To put the quotation marks back on, simply wrap the argument in DeclareFieldFormat within \mkbibquote.
\newbibmacro{string+url}[1]{%
\iffieldundef{url}{#1}{\href{\thefield{url}}{#1}}}
\DeclareFieldFormat{title}{\usebibmacro{string+url}{\mkbibemph{#1}}}
\DeclareFieldFormat[thesis]{title}{\usebibmacro{string+url}{\mkbibemph{#1}}}
\DeclareFieldFormat[article,incollection,inproceedings,unpublished]{title}{\usebibmacro{string+url}{#1}}
% Suppress "In:" for article citations.
\renewbibmacro{in:}{%
\ifentrytype{article}{}{%
\printtext{\bibstring{in}\intitlepunct}}}
%Removes parentheses around year in the bibliography.
\def\act@on@bibmacro#1#2{%
\expandafter#1\csname abx@macro@\detokenize{#2}\endcsname
}
\def\patchbibmacro{\act@on@bibmacro\patchcmd}
\def\pretobibmacro{\act@on@bibmacro\pretocmd}
\def\apptobibmacro{\act@on@bibmacro\apptocmd}
\def\showbibmacro{\act@on@bibmacro\show}
\patchbibmacro{date+extrayear}{%
\printtext[parens]%
}{%
\addperiod\space%
\printtext%
}{}{}
% Turn name+year in citations into hyperlinks (rather than just the year)
\let\abx@macro@citeOrig\abx@macro@cite
\renewbibmacro{cite}{%
\bibhyperref{%
\let\bibhyperref\relax\relax%
\abx@macro@citeOrig%
}%
}
\let\abx@macro@textciteOrig\abx@macro@textcite
\renewbibmacro{textcite}{%
\bibhyperref{%
\let\bibhyperref\relax\relax%
\abx@macro@textciteOrig%
}%
}%
% \let\abx@macro@citeyearOrig\abx@macro@citeyear
% \renewbibmacro{citeyear}{%
% \bibhyperref{%
% \let\bibhyperref\relax\relax%
% \abx@macro@citeyearOrig%
% }%
% }%
% \let\abx@macro@citeyearparOrig\abx@macro@citeyearpar
% \renewbibmacro{citeyearpar}{%
% \bibhyperref{%
% \let\bibhyperref\relax\relax%
% \abx@macro@citeyearparOrig%
% }%
% }%
% \DeclareCiteCommand{\citeyear}
% {\usebibmacro{prenote}}
% {\bibhyperref{\printdate}}
% {\multicitedelim}
% {\usebibmacro{postnote}}
\DeclareCiteCommand{\citeyear}
{\usebibmacro{prenote}}
{\bibhyperref{\printdateextra}}
{\multicitedelim}
{\usebibmacro{postnote}}
% \DeclareCiteCommand{\citeyearpar}
% {\usebibmacro{prenote}}
% {\mkbibparens{\bibhyperref{\printdate}}}
% {\multicitedelim}
% {\usebibmacro{postnote}}
\DeclareCiteCommand{\citeyearpar}[\mkbibparens]
{\usebibmacro{prenote}}
{\bibhyperref{\printdateextra}}
{\multicitedelim}
{\usebibmacro{postnote}}
%\providecommand{\doi}[1]{\href{http://dx.doi.org/#1}{\nolinkurl{doi:#1}}}
% =============================================================================
% Margin notes (needs to be improved)
% =============================================================================
\usepackage{alphalph}
\setlength{\marginparwidth}{1.1in}
\setlength{\marginparsep}{.4in}
\let\oldmarginpar\marginpar
\renewcommand\marginpar[1]{\-\oldmarginpar[\raggedleft\scriptsize #1]%
{\raggedright\scriptsize #1}}
\renewcommand{\marg}[1]{}
% =============================================================================
% Option to define Possessive cite commands that mesh well with hyperref. Under review.
% =============================================================================
\DeclareOption{bibextend}{
%% Commands for possessive cite.
\newcommand{\citeapos}[1]{\citeauthor{#1}'s (\citeyear{#1})}
\newcommand{\citeaposalt}[1]{\citeauthor{#1}'s \citeyear{#1}}
\DeclareNameFormat{labelname:poss}{% Based on labelname from biblatex.def
\ifcase\value{uniquename}%
\usebibmacro{name:last}{#1}{#3}{#5}{#7}%
\or
\ifuseprefix
{\usebibmacro{name:first-last}{#1}{#4}{#5}{#8}}
{\usebibmacro{name:first-last}{#1}{#4}{#6}{#8}}%
\or
\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
\fi
\usebibmacro{name:andothers}%
\ifnumequal{\value{listcount}}{\value{liststop}}{'s}{}}
\DeclareFieldFormat{shorthand:poss}{%
\ifnameundef{labelname}{#1's}{#1}}
\DeclareFieldFormat{citetitle:poss}{\mkbibemph{#1}'s}
\DeclareFieldFormat{label:poss}{#1's}
\newrobustcmd*{\posscitealias}{%
\AtNextCite{%
\DeclareNameAlias{labelname}{labelname:poss}%
\DeclareFieldAlias{shorthand}{shorthand:poss}%
\DeclareFieldAlias{citetitle}{citetitle:poss}%
\DeclareFieldAlias{label}{label:poss}}}
\newrobustcmd*{\posscite}{%
\posscitealias%
\textcite}
\newrobustcmd*{\Posscite}{\bibsentence\posscite}
\newrobustcmd*{\posscites}{%
\posscitealias%
\textcites}
}
% =============================================================================
% Define Theorem environments
% (fold)
% =============================================================================
\DeclareOption{thm}{
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{remark*}{Observation}
\newtheorem{fact}[thm]{Fact}
\newtheorem{claim}[thm]{Claim}
\newtheorem{question}[thm]{Question}
\newtheorem{conjecture}[thm]{Conjecture}
\theoremstyle{definition}
\newtheorem{definition}[thm]{Definition}
\newtheorem{exo}{Exercise}[section]
\newtheorem{example}{Example}
\newtheorem{ques}{Question}
\newtheorem{ass}[thm]{Assumption}
\newtheorem{remark}[thm]{Remark}
}
%(end)
%% Hyperref options. The print option removes colored links to make for more legible printouts.
\newif\if@screen\@screentrue
\newif\if@print\@printtrue
\DeclareOption{screen}{\@screentrue \@printfalse}
\DeclareOption{print}{\@screenfalse \@printtrue}
\ExecuteOptions{screen}
\DeclareOption*{
\PackageWarning{apc-basic}{Unknown option ‘\CurrentOption’}%
}
\ProcessOptions\relax
% =============================================================================
% Declare screen and print options: print option makes all hyperlinks black,
% for better quality printing.
% =============================================================================
% (fold)
\if@screen
\hypersetup{breaklinks=true,
colorlinks=true,
linkcolor=Maroon,
urlcolor=Maroon,
citecolor=BlueViolet,
plainpages=false,
pdfpagelabels,
bookmarksnumbered,
backref=page}
\else\relax
\fi
\if@print
\hypersetup{breaklinks=true,
colorlinks=false,
% linkbordercolor=BrickRed,
% urlbordercolor=BrickRed,
% citebordercolor=BlueViolet,
plainpages=false,
pdfpagelabels,
bookmarksnumbered
}
\else\relax
\fi
%(end)
\endinput