-
Notifications
You must be signed in to change notification settings - Fork 165
/
qabook.sty
247 lines (196 loc) · 6.77 KB
/
qabook.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
\usepackage[utf8]{inputenc}
\usepackage{color}
\usepackage[table,usenames,dvipsnames]{xcolor}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage[color=green!10,
colorinlistoftodos,
linecolor=lightgray,
bordercolor=green!10,
textsize=footnotesize]{todonotes} % add [disable] to hide notes
\usepackage[noend]{algpseudocode}
\usepackage{amsmath,amssymb,mleftright}
\usepackage{mathtools} % For cases environment
\usepackage[a4paper]{geometry}
\usepackage[round]{natbib}
\usepackage{float}
\usepackage{nicefrac}
\usepackage[section]{placeins} % This gives the \FloatBarrier command
\usepackage[minmargin=0.1\textwidth,
labelfont=bf,
font=footnotesize,
labelsep=period,
justification=centering]{caption}
\usepackage{setspace}
\usepackage{url}
\usepackage{ntheorem}
\usepackage{titlesec}
\usepackage{microtype}
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{
decorations.pathreplacing,
calc,
patterns,
datavisualization.formats.functions,
external}
\usepackage[hang,flushmargin]{footmisc} % remove the footnoteindex.
% Activate pre-compilation of images (see section 50.4 in tikz/pgfmanual
% This just makes it faster to recompile while editing the book, as it
% pre-builds all the images.
% You should remove it and compile the document properly for the final version
% I use the `list and make` option, which means after compilation I get a
% make file. Then I need to run:
% `make -f Maindocument.makefile`
% on the command line to make all the pics
% \tikzexternalize[mode=list and make]
\usepackage{xparse}
\usepackage{minted}
% Setup the fancyvrb (which is called by minted)
\fvset{frame=single}
% This sets the description environment to use itshape rather than bold
\setlist[description]{font=\normalfont\itshape\textbullet\space}
\usepackage[british]{babel}
\babelhyphenation[english]{pro-gram-ming}
% Define colours first
\definecolor{linkcolor}{RGB}{0,0,128}
\definecolor{dwgreen}{RGB}{0,128,0}
\definecolor{dwred}{RGB}{176,0,64}
\definecolor{dwblue}{HTML}{0B486B}
%\usepackage[hidelinks]{hyperref}
\usepackage[pagebackref,
pdfpagelabels,
plainpages=false,
hypertexnames=true,
colorlinks=true,
linkcolor=linkcolor,
anchorcolor=linkcolor,
citecolor=linkcolor,
filecolor=linkcolor,
menucolor=linkcolor,
runcolor=linkcolor,
urlcolor=linkcolor,
pdfborder={0 0 0}]{hyperref}
% Got this from the stan manual
% File that fixes and activates the line numbers
%\input{fixlinenumbers.tex}
% File that gives me the nice dice
\input{plots/dice/dice.tex}
\makeindex
% \usepackage{showkeys}
\interfootnotelinepenalty=10000 % to ensure footnotes stay on the same page
\allowdisplaybreaks[1] %{amsmath} -- allows formulas to span multiple pages
% the number can be 1 to 4, where one allows it but avoids it.
% you can also force displaybreaks anywhere by putting \displaybreak[4] a formula, [1] is a suggestion, [4] is a command.
% the default value for both of these is [4]
%DW's commands
\renewcommand{\vec}{\boldsymbol}
\DeclareMathOperator{\E}{\mathrm{E}}
\DeclareMathOperator{\Var}{\mathrm{Var}}
\DeclareMathOperator{\Cov}{\mathrm{Cov}}
\DeclareMathOperator*{\argmax}{arg\,max}
\providecommand{\abs}[1]{\lvert#1\rvert}
\providecommand{\determinant}[1]{\lvert#1\rvert}
\providecommand{\norm}[1]{\lVert#1\rVert}
% change marginpar fontsize
\makeatletter
\renewcommand{\@marginparreset}{%
\reset@font\scriptsize
\raggedright
\@setminipage
}
\makeatother
% Make some ntheorem environments to hold the questions and answers
\theoremstyle{break}
\theoremheaderfont{\bfseries}
\theorembodyfont{}
\theoremnumbering{arabic}
\theoremseparator{:}
\newtheorem{ntquestion}{Question}
\theoremstyle{break}
\theoremheaderfont{\bfseries}
\theorembodyfont{}
\theoremnumbering{alph}
\theoremseparator{)}
\theoremindent=0.6cm
\newtheorem{ntsubquestion}{}[ntquestion]
\theoremstyle{plain}
\theoremheaderfont{\bfseries}
\theorembodyfont{}
\theoremnumbering{arabic}
\theoremseparator{}
\theoremindent=0cm
\newtheorem*{ntanswer}{Answer}
\theoremstyle{plain}
\theoremheaderfont{\bfseries}
\theoremnumbering{alph}
\theorembodyfont{}
\theoremseparator{}
\theoremindent=0cm
\newtheorem*{ntsubanswer}{Answer}[ntanswer]
% Make new environments to ease the labelling
% use the xparse package, since we need the arguments in the last bit of the environment as well
\NewDocumentEnvironment{question}{m}%
{\begin{ntquestion}\label{q:#1}}%
{\begin{flushright}(\hyperref[a:#1]{Answer on page \pageref*{a:#1}})\end{flushright}\end{ntquestion}}
\newenvironment{questionwithnoanswer}%
{\begin{ntquestion}}{\end{ntquestion}}
\NewDocumentEnvironment{subquestion}{m}%
{\begin{ntsubquestion}\label{q:#1}}%
{\begin{flushright}(\hyperref[a:#1]{Answer on page \pageref*{a:#1}})\end{flushright}\end{ntsubquestion}}
\NewDocumentEnvironment{answer}{m}%
{\begin{ntanswer}\ref*{q:#1}:
\label{a:#1}\hfill(\hyperref[q:#1]{Question on page \pageref*{q:#1}})
\\}%
{\end{ntanswer}}
\NewDocumentEnvironment{subanswer}{m}%
{\begin{ntsubanswer}\ref*{q:#1}):
\label{a:#1}\hfill(\hyperref[q:#1]{Question on page \pageref*{q:#1}})
\\}%
{\end{ntsubanswer}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Usage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{question}{questionlabelname}
% Write stuff here
%\end{question}
%\begin{answer}{questionlabelname}
% Write stuff here
%\end{answer}
% this will automatically create the labels called `q:questionlabelname` and `a:questionlabelname`.
% To change the formatting of the question and answer blocks, change their corresponding ntheorem styles.
% Make a nice titlepage
\providecommand{\HUGE}{\Huge}% if not using memoir
\newlength{\drop}% for my convenience
%% select a (FontSite) font by its font family ID
\newcommand*{\FSfont}[1]{\fontencoding{T1}\fontfamily{#1}\selectfont}
%% if you don’t have the FontSite fonts either \renewcommand*{\FSfont}[1]{}
%% or use your own choice of family.
%% select a (TeX Font) font by its font family ID
\newcommand*{\TXfont}[1]{\fontencoding{T1}\fontfamily{#1}\selectfont}
%% Generic publisher’s logo
\newcommand*{\plogo}{\fbox{$\mathcal{PL}$}}
\newcommand*{\titleDB}{
\begingroup% AW, Design of Books
\FSfont{ppl} % FontSite URW Palladio (Palatino)
\drop = 0.14\textheight
\centering
\vspace*{\drop}
{\Large AN}\\[\baselineskip]
{\Huge INTERVIEW PRIMER}\\[\baselineskip]
{\Large FOR}\\[\baselineskip]
{\LARGE QUANTITATIVE FINANCE}\par
\vfill
{BY DIRK BESTER}\\%\\[8\baselineskip]
{\small 2017}\par
{\small \docversion}\par
\vfill
\endgroup
}
%to give a version and date:
\def\parsetime #1#2#3#4#5\empty{#1#2:#3#4}
\def\parsedatetime #1:20#2#3#4#5#6#7#8\empty{20#2#3-#4#5-#6#7 \parsetime#8\empty }
\def\parsedate #1:20#2#3#4#5#6#7#8\empty{20#2#3-#4#5-#6#7\empty }
\def\moddate#1{\expandafter\parsedate\pdffilemoddate{#1}\empty}
%% This gives the \moddate{\jobname.tex}} command