-
Notifications
You must be signed in to change notification settings - Fork 1
/
coursedoc.sty
173 lines (153 loc) · 4.29 KB
/
coursedoc.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
\DeclareOption{tikz}{\tikztrue}
\DeclareOption{listings}{\listingstrue}
\DeclareOption{exam}{\examtrue}
\newif\iftikz\tikzfalse
\newif\iflistings\listingsfalse
\newif\ifexam\examfalse
\ProcessOptions
\ifexam
\else
\RequirePackage{thaixelatex}
%% math setup
\RequirePackage{amsmath}
\RequirePackage{unicode-math}
\setmathfont{TeX Gyre Termes Math}
\setmathfontface\mathrm{TeX Gyre Termes}
\setmathfontface\mathbf{TeX Gyre Termes Bold}
\setmathfontface\mathit{TeX Gyre Termes Italic}
%\setmathfont[range=\mathbfit]{TeX Gyre Termes Bold Italic}
%% margins
\usepackage[margin=1in,headheight=0.25in]{geometry}
%% list setup
\usepackage{enumitem}
\setlist{nosep,leftmargin=*,listparindent=1.5em}
%% homework setup
\newlist{problems}{enumerate}{1} % 1 is max depth
\setlist[problems]{resume,label=\arabic*.,ref=\arabic*,font=\bf,%
leftmargin=*,listparindent=1.5em}
\newlist{subproblems}{enumerate}{2} % 2 is max depth
\setlist[subproblems]{label=(\alph*),ref=(\alph*),%
leftmargin=*,listparindent=1.5em}
\newcommand\stars[1]{[#1 \ifnum #1=1 star\else stars\fi]}
\newcommand\pts[1]{[#1 \ifnum #1=1 pt\else pts\fi]}
%% header commands
\newcommand\headerBase{%
{\large\bf \courseno{}---ภาคเรียนที่~\semesterno{} ปีการศึกษา~\acadyear{}\\
\@title
}
}
\newcommand\header{%
\begin{center}
\headerBase
\end{center}
}
\def\@duedate{due date}
\newcommand\duedate[1]{\def\@duedate{#1}}
\newcommand\hwheader{%
\begin{center}
\headerBase
Due: \@duedate
\end{center}
}
\usepackage[colorlinks=true,urlcolor=blue]{hyperref}
%
% \setanswerstyle{...}
% Change the default style, color, etc. of answer text
% E.g., \setanswerstyle{\color{red}\em}
%
\newcommand\setanswerstyle[1]{\gdef\@answerstyle{#1}}
\newcommand\@answerstyle{}
%
% \presentanswer{text} is used to present the answer 'text'.
% Can be overridden to present answers differently.
%
\newcommand\presentanswer[1]{%
\par\noindent\textbf{Answer}:\nopagebreak #1%
}
\newenvironment{answer}{%
%\nopagebreak\par\noindent
%\begin{minipage}{\linewidth}
\presentanswer
%\setlength{\parindent}{1.5em}
\bgroup\@answerstyle
}{\egroup}%\end{minipage}}
\fi % exam
%% title formatting
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\large\bfseries}
{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\bfseries}
{\thesubsection}{1em}{}
\usepackage{amsthm}
\theoremstyle{definition}
% \newcounter{thm}
\newtheorem{thm}{Theorem}[section]
\newtheorem{axiom}[thm]{Axiom}
\newtheorem{conjecture}[thm]{Conjecture}
\newtheorem{corollary}[thm]{Corollary}
\newtheorem{definition}[thm]{Definition}
\newtheorem{example}[thm]{Example}
\newtheorem{lemma}[thm]{Lemma}
\newtheorem{theorem}[thm]{Theorem}
\newtheorem{remark}[thm]{Remark}
\newtheorem{exercise}[thm]{Exercise}
\newenvironment{pf}[1][Proof]{%
\begin{proof}[\bf #1]
}
{\end{proof}}
%% tikz setup (if needed)
\iftikz
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta}
\tikzset{>/.tip={Latex[length=2mm]}}
\tikzset{arrow/.style={->}}
\tikzset{double distance=2pt}
\fi
%% listings setup (if needed)
\iflistings
\usepackage[final]{listings}
\usepackage{xunicode}
\usepackage{relsize}
\lstset{
columns=flexible,
basicstyle=\linespread{0.9}\ttfamily,%\relscale{0.9},
keywordstyle=\bfseries,
%commentstyle=\itshape,
showstringspaces=false,
numbers=left,
numberstyle=\scriptsize\itshape,
escapeinside={(*}{*)},
literate={*}{*}1{-}{-}1,escapeinside={(*}{*)}
}
\fi
\usepackage{stmaryrd}
%% math commands
\allowdisplaybreaks
%%% set
\newcommand\set[1]{\ensuremath{\left\{#1\right\}}}
\newcommand\pow{\ensuremath{\mathrm{pow}}}
%%% logic
\newcommand\true{\ensuremath{\mathrm{T}}}
\newcommand\false{\ensuremath{\mathrm{F}}}
\newcommand\True{\ensuremath{\mathrm{true}}}
\newcommand\False{\ensuremath{\mathrm{false}}}
%%% relations
\newcommand\R[3][R]{\ensuremath{#2 \mathrel{#1} #3}}
%%% regular expressions
\newcommand\str[1]{\texttt{#1}}
%%% context-free grammars
\newcommand\nt[1]{\textit{#1}}
\newcommand\ntl[1]{\ensuremath{\langle\textsc{#1}\rangle}}
%%% lists
\newcommand\lconcat{\ensuremath{\mathbin{+\!\!+}}}
%% miscellaneous
\newcommand\ost{\textsuperscript{st}}
\newcommand\ond{\textsuperscript{nd}}
\newcommand\ord{\textsuperscript{rd}}
\newcommand\oth{\textsuperscript{th}}
\usepackage{pifont}
\newcommand\yea{{\disableTransitionRules\ding{52}}}
\newcommand\nay{{\disableTransitionRules\ding{55}}}