-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommonheader.sty
362 lines (304 loc) · 12.5 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
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% _______ _______ ___ ____ _______
% | || || | | | | _ |
% | || _____|| |___ | | | |_| |
% | || |_____ | _ | | | | |
% | _||_____ || | | | | | | |
% | |_ _____| || |_| | | | | _ |
% |_______||_______||_______| |___| |__| |__|
%
% Header for CS61A Tutoring TeX Files
%
% Collected and modified by Jonathan Kotker and Thomas Magrino
%
% 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Uncomment the following line to display solutions
%\def\discussionsolutions{}
\ProvidesPackage{commonheader}
%%% Packages Needed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{color}
\usepackage{comment}
\usepackage{enumerate}
\usepackage{fancybox}
\usepackage{fix-cm}
\usepackage{float}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage[pdftex,colorlinks]{hyperref}
\usepackage{import}
\usepackage{listings}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{palatino}
\usepackage{paralist}
\usepackage{parskip}
\usepackage{tabularx}
\usepackage[calcwidth]{titlesec}
\usepackage{upquote}
\usepackage{verbatim}
\usepackage{wasysym}
\usepackage{tikz}
\usepackage{tikz-qtree,tikz-qtree-compat}
\usepackage{synttree}
\usepackage{soul}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define solution style
\unframedsolutions
\renewcommand{\solutiontitle}{}
\SolutionEmphasis{\color{red}}
%%% Information about the class %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\semester}[1]{\newcommand{\sem}{#1}}
\newcommand{\stafflist}[1]{\newcommand{\staff}{#1}}
\newcommand{\wsfeedback}[1]{\newcommand{\wsfdbk}{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% MODIFY THIS INFORMATION AS NECESSARY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\semester{Fall 2024}
\stafflist{Created by Jim Fang,
Bryan Adolfo Ventura Benitez.
}
\wsfeedback{Worksheet feedback: \href{https://links.jimfang.dev/feedback}{links.jimfang.dev/feedback}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Margins and definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setlength{\marginparwidth}{1.2in}
\let\oldmarginpar\marginpar
\renewcommand{\marginpar}[1]{\-\oldmarginpar[\raggedleft\footnotesize #1]%
{\raggedright\footnotesize #1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Configuring the document title %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{titlecol}{gray}{0.6}
% \titlebreak is used to insert a break in the title of the page without
% causing a break in the running footer.
\newcommand{\titlebreak}{\par}
\let\oldtitle\title
\renewcommand{\title}[1]
{\oldtitle{
{\begin{flushright}
\huge {\sc{#1}}
\fontsize{45}{0} \sffamily \color{titlecol} \selectfont
\ifdefined\discussionmetas
\marginpar{\Large{\textcolor{blue}{Meta}}}
\else
\ifdefined\discussionsolutions
\marginpar{\Large{\textcolor{red}{Solutions}}}
\fi
\fi
\end{flushright}}
\rule{\textwidth}{0.2em}}
\newcommand{\disctitle}{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Configuring the header and footer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\discnumber}[1]{\newcommand{\discnum}{#1}}
\pagestyle{headandfoot}
\firstpagefootrule
\firstpagefooter{\small \staff \wsfdbk \newline Provided by CSM 61A contributors under \href{https://github.com/csmberkeley/csm-61a/blob/main/LICENSE}{CC BY 4.0/3-clause BSD}.}{}{}
\runningfootrule
\runningfooter{
\let\titlebreak\relax
\sc \oddeven{Week \discnum: \disctitle}{\thepage}}{}{\sc \oddeven{\thepage}{CSM 61A \sem}
}
\let\oldmaketitle\maketitle
\renewcommand{\maketitle}[0]{\oldmaketitle \thispagestyle{headandfoot}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Configuring the section and subsection titles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\titleformat{\section}[hang]{\sffamily \bfseries}
{\fontsize{15}{25} \color{titlecol} \selectfont \thesection}{10pt}
{\fontfamily{ppl} \fontsize{15}{0} \selectfont \raggedleft}
[{\titlerule[1.0pt]}]
\titleformat{\subsection}[hang]{\sffamily \bfseries}
{\thesubsection}{10pt}{}[{\titlerule[0.5pt]}]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Colored titles for sections %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\colorsec}[2]{\section[#1]{{\color{#2} #1}}}
\newcommand{\colorsubsec}[2]{\subsection[#1]{{\color{#2} #1}}}
\newcommand{\colorsubsubsec}[2]{\subsubsection[#1]{{\color{#2} #1}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% 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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% These parameters determine the sizes of the boxes used %%%%%%%%%%%%%%%%%%%%
%%% to explain special and/or subtle points. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\boxlarge}{6.40in}
\newcommand{\boxmed}{6.05in}
\newcommand{\boxsmall}{5.75in}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Miscellaneous parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setlength{\parindent}{0in}
%\settimeformat{ampmtime}
\allowdisplaybreaks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% 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 w/parens 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}}}
% creates a \tboxed{} with an invisible charater
\newcommand{\tphan}[1]{\tboxed{\phantom{#1}}}
\def\({\left(}
\def\){\right)}
\def\<{\left\langle}
\def\>{\right\rangle}
% For lemmas
\newtheorem{lemma}{Lemma}
% For Python code
\lstset{language=Python,
basicstyle=\ttfamily,
commentstyle=\ttfamily,
showstringspaces=false,
breaklines=true,
breakatwhitespace=true,
}
% For Scheme code
\lstdefinelanguage{Scheme}{
morekeywords=[1]{define, define-syntax, define-macro, lambda, define-stream,
stream-lambda},
morekeywords=[2]{begin, call-with-current-continuation, call/cc,
call-with-input-file, call-with-output-file, case, cond, do,
else, for-each, if, let*, let, let-syntax, letrec,
letrec-syntax, let-values, let*-values, and, or, not, delay,
force, quasiquote, quote, unquote, unquote-splicing,
fold, syntax, syntax-rules, eval, environment, query, mu, expect,
cons-stream, set!},
morekeywords=[3]{import, export},
alsodigit=!\$\%&*+-./:<=>?@^_~,
sensitive=true,
morecomment=[l]{;},
morecomment=[s]{\#|}{|\#},
morestring=[b]",
basicstyle=\ttfamily,
keywordstyle=\bf\ttfamily,
upquote=true,
breaklines=true,
breakatwhitespace=true,
literate=*{`}{{`}}{1}
}
% 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.
%
% Source:
% http://tex.stackexchange.com/questions/43002/how-to-preserve-the-same-parskip-in-minipage
\newlength{\currentparskip}
\newenvironment{blocksection}
{
\setlength{\currentparskip}{\parskip}% save the value
\begin{minipage}{\linewidth}
\setlength{\parskip}{\currentparskip}% restore the value
}
{
\end{minipage}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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
% Meta information is mentor-facing information to assist with teaching the
% worksheet. Information is presented in blue.
\ifdefined\discussionmetas
\newenvironment{meta}{\color{blue}}{}
\newenvironment{questionmeta}{
\begin{solution}
\color{blue}
}{
\end{solution}
}
\else
\newenvironment{meta}{\comment}{\endcomment}
\newenvironment{questionmeta}{\comment}{\endcomment}
\fi
% Backward compatibility with old templates that use "guide"
\let\guide\meta
% The nonsol environment will show items within it only if answers are not set
% to be printed. Useful for hiding docstring in worksheet solutions.
\newenvironment{nonsol}{}{}
\ifdefined\discussionsolutions
\excludecomment{nonsol}
\else
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\author{ \Large \sc Computer Science Mentors 61A}