-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw_template.tex
193 lines (128 loc) · 6.27 KB
/
hw_template.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
% hw-latex-template is a simple template for writing up your math or CS homework in LaTeX.
% Copyright (C) 2020 Rishi Advani
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
\documentclass[letterpaper, 11pt, fleqn]{article}
\newif\ifLM
%\LMtrue % use `lmodern` fonts instead of `newpx` fonts
%%% Layout and typography %%%
\usepackage{mathtools} % also loads `amsmath` package
\usepackage{amssymb}
\usepackage{amsthm} % load before `newpxmath` package
\ifLM
\usepackage{lmodern}
\else
\usepackage[theoremfont, trueslanted, largesc]{newpxtext} % package author wants this loaded after `babel`, but this doesn't seem necessary
\usepackage[vvarbb, noamssymbols]{newpxmath} % package author has `fontenc` loaded before this, but it's unclear if this is necessary
\fi
\usepackage[T1]{fontenc} % allows LaTeX to output non-ASCII characters better; load after fonts if possible
\usepackage[english]{babel} % sets language to American English
\AddBabelHook{frspacing}{afterextras}{\frenchspacing} % enables single sentence spacing
%\usepackage{csquotes} % for formal quotations
\usepackage[hmargin=1.2in, marginparwidth=1in, marginparsep=0.1in, vmargin=1in, headheight=0.6in, headsep=0.3in, footskip=0.5in, heightrounded]{geometry} % useful for setting page dimensions and layout
%\usepackage{parskip} % enables alternate paragraph layout
\usepackage{ragged2e} % adds improved flush/ragged alignment commands
\newcommand{\sidenote}[1]{\marginpar[\RaggedLeft\footnotesize #1]{\RaggedRight\footnotesize #1}} % use for sidenotes
\usepackage{ftcap} % fixes table–caption spacing in `article` class
\usepackage[tracking]{microtype} % improves typographic details (e.g., kerning)
\usepackage{fnpct} % adjusts kerning of footnote marks (superscripts) before commas or periods
%%% Images %%%
\usepackage{graphicx} % allows inclusion of images in document
\graphicspath{{./images/}} % location of images in file system
% Example:
%\begin{figure}[bhpt]
%\centering
%\includegraphics[width=0.8\linewidth]{p1_1}
%\caption{[insert caption]}
%\label{p1_relevantname}
%\end{figure}
%%% Tables %%%
\usepackage{booktabs}
%\usepackage{tabularx}
%%% Math %%%
\allowdisplaybreaks[1] % allows page breaks within `amsmath` environments; optional value sets permissibility (min=1, max=4)
%\mathchardef\mhyphen="2D % hyphen for math mode (credit to Gernot Salzer)
\renewcommand*{\emptyset}{\varnothing} % prettier empty set symbol
\ifLM\newcommand*{\transp}{\mathsf{T}}\fi % use for matrix transpose
%\usepackage{bm} % use `\bm` for bold math symbols
% Use `\phanrel` to insert an invisible relation operator to align an equation split across two lines.
\newcommand*{\phanrel}{\mathrel{\phantom{=}}}
% Example:
%\begin{align*}
% &\phanrel \text{a very long expression} \\
% &= \text{another long expression}
%\end{align*}
\newcommand*{\Complex}{\mathbb{C}}
\newcommand*{\Reals}{\mathbb{R}}
\newcommand*{\Rationals}{\mathbb{Q}}
\newcommand*{\Integers}{\mathbb{Z}}
\newcommand*{\Naturals}{\mathbb{N}}
\DeclareMathOperator{\E}{\mathbb{E}}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
% Use `\set` for set notation. Optional size argument accepted.
\DeclarePairedDelimiterX\set[1]\lbrace\rbrace{\mkern1.5mu\def\suchthat{\;\delimsize|\;}#1\mkern1.5mu}
% Example:
%\[\set[\bigg]{\frac{x^2}{2} \suchthat x > 0}\]
%%% Graphs %%%
\usepackage{xcolor} % enables teal color for `listings` package; load before `tikz` package
%\usepackage{tikz}
%\usetikzlibrary{babel, positioning}
%%% Algorithms %%%
\usepackage{algorithm} % enables floating of algorithms
\usepackage{algpseudocode} % also loads `algorithmicx` package; use `noend` option to supress block ending lines
\newcommand*{\algorithmautorefname}{Algorithm} % for `hyperref` package's autoref macro
% Use `\LongState` to replace `\State` when the contents of the line overflow. This preserves the indentation level of the first line. Inspired by a macro designed by TeX.SX user Werner.
\newcommand*{\LongState}[2]{\State\parbox[t]{\dimexpr\linewidth-\dimexpr\algorithmicindent*#1}{#2\strut}}
% Example:
%\LongState{2}{very long line that needs to be indented 2 levels}
%\usepackage{fancyvrb}
\usepackage{listings}
\renewcommand*{\lstlistingname}{Algorithm}
\lstset{
tabsize=4,
language=Python,
frame=single,
morekeywords={True,False},
commentstyle=\color{gray},
keywordstyle=\color{blue},
stringstyle=\color{teal},
basicstyle=\small\ttfamily,
showstringspaces=false,
rulecolor=\color{black}
}
% Example:
%\begin{lstlisting}[title=My Title, label=my_label, float=bhpt]
% print("Hello World!")
%\end{lstlisting}
%%% Fancy header %%%
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[L]{Rishi Advani} % TODO update
\fancyhead[C]{MATH 101 --- Homework 1} % TODO update
\fancyhead[R]{January 10, 1938} % TODO update
\fancyfoot{}
%\fancyfoot[L]{Collaborators: N/A}
%\renewcommand*{\footrulewidth}{0.5pt} % uncomment if you have collaborators
%%% Miscellaneous %%%
% Use `\isitdefined` to check if a command is defined.
\newcommand*{\isitdefined}[1]{\%\% command `#1' does \ifcsname#1\endcsname\else NOT \fi exist \%\%}
% Example:
%\isitdefined{potato}
%%% Load last %%%
\usepackage[colorlinks, allcolors=blue]{hyperref} % enables hyperlinks; load before `ellipsis` package
\usepackage{ellipsis} % adjusts spacing of ellipses before punctuation
\begin{document}
% TODO remove %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{sample_input} % only needed for this template
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}