-
Notifications
You must be signed in to change notification settings - Fork 2
/
commonheader.sty
255 lines (228 loc) · 8.03 KB
/
commonheader.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Header for Discussion TeX Files
%
% Collected and modified by Jonathan Kotker and Thomas Magrino (CS 61A su12).
% Largely redesigned by Kevin Lin (CS 61A su17).
%
% This package contains references to other packages, new commands, and values
% for different parameters, common to all discussion documents.
% This file should be placed one level above the discussion TeX files in
% the directory tree.
%
% Please modify the appropriate section below with information about
% the class: this information needs to be updated only once per semester.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Display solutions
% \def\discussionsolutions{}
\ProvidesPackage{commonheader}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage[noend]{algpseudocode}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{comment}
\usepackage{fancybox}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage[colorlinks]{hyperref}
\usepackage{import}
\usepackage{listings}
\usepackage{paralist}
\usepackage{parskip}
\usepackage{tabularx}
\usepackage{upquote}
\usepackage{verbatim}
\usepackage{wasysym}
\usepackage{tikz,tikz-qtree,tikz-qtree-compat}
% Draw trees
\usepackage{wrapfig}
\usetikzlibrary{arrows,positioning,calc,shapes}
\tikzstyle{vertex}=[draw,circle,minimum size=18pt,inner sep=0pt]
% Fonts
\usepackage[varqu]{inconsolata}
% Define solution style
\unframedsolutions
\renewcommand{\solutiontitle}{}
\SolutionEmphasis{\color{red}}
% Course information
\def\coursenumber{CSM 61B}
\def\semester{Spring 2019}
% Provide discnum and disctitle
\newcommand{\discnumber}[1]{\newcommand{\discnum}{#1}}
\def\title#1{\gdef\@title{#1}\gdef\disctitle{#1}}
% Provide "Extra" section text
\newcommand{\extra}[1]{#1 \large\textit{Extra Practice}}
\newcommand{\midterm}[1]{#1 \textit{Midterm Question}}
% Configuring the header and footer
\pagestyle{head}
\runningheader{
\oddeven{}{\thepage \quad \textit{\disctitle}}}
{}
{\oddeven{\textit{\disctitle} \quad \thepage}{}
}
% Define formatting
\textheight=9.5in
\textwidth=5in
\voffset=-0.5in
\hoffset=-0.25in
\headsep=1em
\marginparsep=1em
\marginparwidth=2in
\footskip=2em
\renewcommand{\baselinestretch}{1.2}
\font\dunhd=cmdunh10 scaled \magstep5
\font\dunhc=cmdunh10 scaled \magstep4
\font\dunhb=cmdunh10 scaled \magstep3
\font\dunha=cmdunh10 scaled \magstep2
\font\dunhs=cmdunh10 scaled \magstep1
\def\preamble#1{\gdef\@preamble{#1}}
\def\sp#1{\underline{\hspace*{#1}}}
% Use \printanswers to print with answers and \noprintanswers to print without.
% Check for defined flag \discussionsolutions to show solutions
\ifdefined\discussionsolutions
\printanswers
\else
\noprintanswers
\fi
% Use \printmeta to print with meta and \noprintmeta to print without
\newif\ifprintmeta
\newcommand{\printmeta}{\printmetatrue}
\newcommand{\noprintmeta}{\printmetafalse}
\noprintmeta % default to no print meta
\usepackage{environ}
\NewEnviron{meta}{\ifprintmeta\expandafter \textbf{Meta:} \BODY\fi}
% define meta inside \begin{meta} \end{meta}
% Define title
\renewcommand{\maketitle}{\@maketitle\thispagestyle{empty}}
\def\@maketitle{
\newpage
\vspace*{-\topskip}
\hrule height1pt width\textwidth
\vskip 0.25em
\makebox[1.6in][l]{\dunhb \coursenumber}
{\dunhb \hfill \disctitle}
\vskip 0em
\makebox[1.6in][l]{\dunhb \semester}
{\dunhb \hfill \dunhs \ifdefined\discnum Mentoring \discnum: \fi\@date}
\vskip 0.75em
\hrule height1pt width\textwidth \par \vskip 0.5em
}
% Define section and subsection styles
\def\section{\@startsection{section}{1}{\z@}
{-3.0ex plus -.6ex minus -.2ex}{1.3ex plus .1ex}{\dunhb}}
\def\subsection{\@startsection{subsection}{2}{\z@}
{-1.6ex plus -.5ex minus -.1ex}{0.9ex plus .1ex}{\dunha}}
% Define questions listings
\renewcommand{\questionshook}{
\setlength{\leftmargin}{0in}
\setlength{\labelwidth}{0.2in}
}
\renewcommand{\thequestion}{\thesection.\arabic{question}}
\renewcommand{\questionlabel}{\scriptsize\thequestion\hfill}
\long\def\@makecaption#1#2{
\vskip 10pt
\setbox\@tempboxa\hbox{{\bf #2}}
\ifdim \wd\@tempboxa >\hsize {\bf #2}\par \else \hbox
to\hsize{\hfil\box\@tempboxa\hfil}
\fi}
% Commands used to add rules to tables and figures
\floatstyle{ruled}
\newfloat{ruledfigure}{tbph!}{lop}
\floatname{ruledfigure}{Figure}
\newfloat{ruledtable}{tbph!}{lop}
\floatname{ruledtable}{Table}
% Commands for references
\renewcommand{\eqref}[1]{\hyperref[#1]{Equation \ref*{#1}}}
\newcommand{\exref}[1]{\hyperref[#1]{exercise \ref*{#1}}}
\newcommand{\figref}[1]{\hyperref[#1]{Figure \ref*{#1}}}
\newcommand{\lccderef}[1]{\hyperref[#1]{LCCDE \ref*{#1}}}
\newcommand{\quesref}[1]{\hyperref[#1]{question \ref*{#1}}}
\newcommand{\secref}[1]{\hyperref[#1]{section \ref*{#1}}}
\newcommand{\stepref}[1]{\hyperref[#1]{step \ref*{#1}}}
\newcommand{\tableref}[1]{\hyperref[#1]{Table \ref*{#1}}}
\renewcommand{\equationautorefname}{equation}
% Useful new commands
\newcommand{\email}[1]{\href{#1}{{\tt #1}}}
\newcommand{\super}[1]{\ensuremath{^{\textrm{#1}}}}
\newcommand{\sub}[1]{\ensuremath{_{\textrm{#1}}}}
\newcommand{\boxtext}[2]{\framebox{\parbox[b]{#1}{#2}}}
% Defining terms
\newcommand{\define}[1]{\textbf{#1}}
% Rendering an unnumbered footnote
\makeatletter
\long\def\unmarkedfootnote#1{{\long\def\@makefntext##1{##1}\footnotetext{#1}}}
\makeatother
% Box sizes
\newcommand{\boxlarge}{6.40in}
\newcommand{\boxmed}{6.05in}
\newcommand{\boxsmall}{5.75in}
% Define lstlisting styles
\lstset{language=Java,
basicstyle=\ttfamily,
showstringspaces=false,
breaklines=true,
linewidth=7in,
keepspaces=true,
columns=fullflexible,
}
% Creates a minipage environment, which can be used to section off text so that
% it won't be split between two pages. Minipage sets the parskip variable to 0,
% so this preserves the value in the minipage environment.
\newlength{\currentparskip}
\newenvironment{blocksection}{
\setlength{\currentparskip}{\parskip} % save the value
\begin{minipage}{\linewidth}
\setlength{\parskip}{\currentparskip} % restore the value
}{\end{minipage}}
% Mathematical commands
\newcommand{\surjects}{\twoheadrightarrow}
\newcommand{\injects}{\hookrightarrow}
\newcommand{\isom}{\simeq}
\newcommand{\notdiv}{\nmid}
\newcommand{\del}{\partial}
\newcommand{\Intersection}{\bigcap} % intersection of a collection
\newcommand{\intersect}{\cap} % binary intersection
\newcommand{\Union}{\bigcup} % union of a collection
\newcommand{\union}{\cup} % binary union
\newcommand{\tensor}{\otimes}
\newcommand{\directsum}{\oplus} % binary direct sum
\newcommand{\Directsum}{\bigoplus} % direct sum of a collection
\newcommand{\isomto}{\overset{\sim}{\rightarrow}}
% Expected value
\newcommand{\E}[0]{\ensuremath{\mathbb{E}}}
% Probability (of an event)
\renewcommand{\P}[0]{\ensuremath{\mathbb{P}}}
% Variance/covariance
\newcommand{\var}[0]{\text{var}}
\newcommand{\cov}[0]{\text{cov}}
% Fraction with parentheses around it
\newcommand{\pfrac}[2]{\ensuremath{\left(\frac{#1}{#2}\right)}}
% Fraction you can use even if you're not in math mode
\newcommand{\mfrac}[2]{\ensuremath{\frac{#1}{#2}}}
% "maybe equal" - equal with a ? sign on top
\newcommand{\meq}[0]{\ensuremath{\stackrel{?}{=}}}
% maybe anything - anything with a ? on top
\newcommand{\maybe}[1]{\ensuremath{\stackrel{?}{#1}}}
% \problem{1.1} gives you a spiffy-looking "Problem 1.1"
\newcommand{\problem}[1]{ \vspace{.15in} \noindent{\bf Problem #1} \quad\\
\noindent}
% negative/positive infinity
\newcommand{\ninfty}[0]{{\ensuremath{{-\infty}}}}
\newcommand{\pinfty}[0]{{\ensuremath{{+\infty}}}}
% Derivative wrt argument
\newcommand{\der}[1]{\ensuremath{\frac{d}{d #1}}}
% Partial derivative of arg1 wrt arg2
\newcommand{\pder}[2]{\ensuremath{\frac{\partial #1}{\partial #2}}}
% nth derivative
\newcommand{\nder}[2]{\ensuremath{\frac{d^{#2}}{d #1^{#2}}}}
% floor and ceiling
\newcommand{\floor}[1]{\ensuremath{\lfloor{} #1 \rfloor{}}}
\newcommand{\ceil}[1]{\ensuremath{\lceil{} #1 \rceil{}}}
% like \boxed{} but for text instead of math
\newcommand{\tboxed}[1]{\boxed{\text{#1}}}
\def\({\left(}
\def\){\right)}
\def\<{\left\langle}
\def\>{\right\rangle}
% For lemmas
\newtheorem{lemma}{Lemma}