-
Notifications
You must be signed in to change notification settings - Fork 182
/
cme211.sty
176 lines (157 loc) · 6.44 KB
/
cme211.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
\usepackage[english]{babel}
% Layout and Style
\usepackage{fancyhdr}
\frenchspacing % Spacing between sentences
\usepackage{paralist,booktabs} % compactlist, compactitem, and nice tables
%% \usepackage{tocloft} % Spacing in Table of Contents
%% \renewcommand{\cftbeforesecskip}{1.5pt}
% Math
\usepackage{amssymb,amsmath,amsthm} % Standard Math symbols, operators, and environments
%% \usepackage[nice]{nicefrac} % Better small fractions
%% \usepackage{esint,cases} % \oiint, \iint, and function case construction
\usepackage{geometry}[margin=0.5in]
% Python Code
\usepackage{listings, textcomp, color, verbatim}
\definecolor{deepgreen}{rgb}{0,0.4,0}
\lstdefinestyle{python}{
language=python,
basicstyle=\color{black}\ttfamily\footnotesize,
stringstyle=\color{deepgreen}\slshape,
commentstyle=\color{gray}\slshape,
keywordstyle=\color{red}\bf,
emphstyle=\color{blue}\bf,
tabsize=2,
%%%%%%%%%%%%%%%
showstringspaces=false,
emph={access,and,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,i s,lambda,not,or,pass,print,raise,return,try,while,as},
upquote=true,
morecomment=[s]{"""}{"""},
literate=*
{:}{{\textcolor{blue}:}}{1}%
{=}{{\textcolor{blue}=}}{1}%
{-}{{\textcolor{blue}-}}{1}%
{+}{{\textcolor{blue}+}}{1}%
{*}{{\textcolor{blue}*}}{1}%
{!}{{\textcolor{blue}!}}{1}%
{(}{{\textcolor{blue}(}}{1}%
{)}{{\textcolor{blue})}}{1}%
{[}{{\textcolor{blue}[}}{1}%
{]}{{\textcolor{blue}]}}{1}%
{<}{{\textcolor{blue}<}}{1}%
{>}{{\textcolor{blue}>}}{1},%
%%%%%%%%%%%%%%%%
aboveskip=\baselineskip,
xleftmargin=20pt, xrightmargin=15pt,
frame=lines,
numbers=left, numberstyle=\tiny
}
\lstnewenvironment{python}{\lstset{style=python}}{}
\newcommand{\inputsamplepython}[1]{\lstinputlisting[style=python]{../ClassCodes/#1}}
\newcommand{\inputpython}[1]{\lstinputlisting[style=python]{#1}}
% C++ Code
\usepackage{alltt, listings, textcomp, color, verbatim}
\lstdefinestyle{cpp}{
language=C++, % choose the language of the code
basicstyle=\ttfamily\scriptsize, % the size of the fonts that are used for the code
tabsize=2, % sets default tabsize to 2 spaces
showstringspaces=false, % show spaces adding particular underscores
showtabs=false, % show tabs within strings adding particular underscores
keywordstyle=\color{blue}, % keyword style
identifierstyle=\color{black}, % identifier style
emphstyle=\color{black}\bf, % emphasis style
commentstyle=\color{gray}\slshape, % comment style
stringstyle=\color{gray}, % string literal style
aboveskip=\baselineskip, % skip space when starting code environment
xleftmargin=10pt, xrightmargin=10pt, % code margins
frame=lines, % adds a frame around the code
numbers=left, % where to put the line-numbers
numberstyle=\tiny, % the size of the fonts that are used for the line-numbers
numbersep=10pt, % how far the line-numbers are from the code
}
\lstnewenvironment{cpp}{\lstset{style=cpp}}{}
\newcommand{\inputcpp}[1]{\lstinputlisting[style=cpp]{#1}}
% Fix verbatim whitespace
%% \usepackage{etoolbox}
% \makeatletter
% \preto{\@verbatim}{\topsep=0pt \partopsep=0pt}
% \makeatother
% Graphics
\usepackage{graphicx}
\usepackage{pgf,pgffor,pgfplots,pgfplotstable}
\usepgfmodule{shapes,plot}
\usepackage{tikz}
\usetikzlibrary{decorations,arrows,decorations}
% Hyperlink sections, references, and citations
\definecolor{LinkBlue}{RGB}{5,10,200}
\usepackage[urlcolor=LinkBlue,linkcolor=LinkBlue,citecolor=LinkBlue,colorlinks=true]{hyperref}
% Problems and Questions
\usepackage{suffix}
\newcommand{\problem}[1]{\newpage\addtocounter{section}{1}\phantomsection\addcontentsline{toc}{section}{Problem \arabic{section} - #1}\section*{Problem \arabic{section} - #1}}
\WithSuffix\newcommand\problem*[1]{\newpage\phantomsection\addcontentsline{toc}{section}{#1}\section*{#1}}
\newcommand{\subproblem}[1]{\phantomsection\addcontentsline{toc}{subsection}{#1}\subsection*{#1}}
\newcommand{\subsubproblem}[1]{\phantomsection\addcontentsline{toc}{subsubsection}{#1}\subsubsection*{#1}}
% Solution environment
\definecolor{SolutionColor}{rgb}{0.5,0,0}
% \ifsolution
% \newenvironment{solution}{
% {\bf Solution:}
% \endgraf\vskip-\lastskip
% \begingroup\addtolength{\leftskip}{0.5in}\color{SolutionColor}%
% \list{}{\parsep \listparindent}\item\relax}%
% {\endlist\endgroup}
% \else
% \newenvironment{solution}{\comment}{}
% \fi
% %% Margins
\oddsidemargin 0in \evensidemargin 0in \topmargin -0.5in
\headheight 0.25in \headsep 0.25in
\textwidth 6.5in \textheight 9in %\marginparsep 0pt \marginparwidth 0pt
\parskip 1.5ex \parindent 0ex \footskip 20pt
% %% Header
\newcommand*{\MyNumberOfPages}{\hypersetup{linkcolor=black}\pageref{NumberOfPages}\hypersetup{linkcolor=blue}}
\newfont{\bssnine}{cmssbx10 scaled 900}
\pagestyle{fancy}
\fancyhead{\bssnine CME211: Scientific Computing and Software Development for Engineers}
\fancyhead[RE]{}
\fancyhead[LO]{}
\fancyhead[LE]{\bssnine \arabic{page}/\MyNumberOfPages}
\fancyhead[RO]{\bssnine \arabic{page}/\MyNumberOfPages}
\lfoot{} \cfoot{} \rfoot{}
% \AtBeginDocument{
% %% First page header:
% \newfont{\bssten}{cmssbx10}
% \begin{minipage}[t]{0.5\linewidth}
% {\bssten CME212, Winter 2019\\Advanced Programming for Scientists and % % Engineers\\}
% \end{minipage}
% }
\AtEndDocument{
\label{NumberOfPages}
}
\newcommand{\HWcontents}{%
\vspace{-2em}
\def\contentsname{\empty}
\tableofcontents
}
% Custom commands %
% Shortcuts
\renewcommand{\tilde}{\raise.17ex\hbox{$\scriptstyle\sim$}}
\renewcommand{\O}{\mathcal{O}} % Big-Oh
\newcommand{\argmax}{\operatornamewithlimits{argmax}}
\newcommand{\argmin}{\operatornamewithlimits{argmin}}
\newcommand{\sgn}{\text{sgn}}
\renewcommand{\Re}{\text{Re}}
\renewcommand{\Im}{\text{Im}}
\newcommand{\Arg}{\text{Arg}}
% % Operators
\renewcommand{\v}{\mathbf} % Math bold for vectors
\newcommand{\vhat}[1]{\v{\hat{#1}}}
\renewcommand{\bar}{\overline}
\newcommand{\vbar}[1]{\v{\bar{#1}}}
\newcommand{\inner}[2]{#1 \cdot #2} % Inner product
\newcommand{\abs}[1]{\left| {#1} \right|}
\newcommand{\norm}[1]{\left\| {#1} \right\|}
\newcommand{\ceil}[1]{\left\lceil {#1} \right\rceil}
\newcommand{\floor}[1]{\left\lfloor {#1} \right\rfloor}
\newcommand{\pp}[2]{\frac{\partial #1}{\partial #2}}
\renewcommand{\d}[1]{\,\mathrm{d}{#1}} % \int x \d{x}
\newcommand{\del}{\nabla}