% Style file for Physical Mathematics I
% Ewan Stewart
% KAIST
% 2012/1/1


%%%% Layout %%%%

\addtolength{\hoffset}{-1cm}
\addtolength{\textwidth}{2cm}
\addtolength{\voffset}{-1cm}
\addtolength{\headheight}{1mm}
\addtolength{\textheight}{1.9cm}
% Reduces the margins and expands the text to fit.

\def\today{\number\day~\ifcase\month
\or January\or February\or March\or April\or May\or June%
\or July\or August\or September\or October\or November\or December%
\fi\space\number\year}
% Redefines the date format generated by "\today".

\usepackage{fancyhdr} % A package for adding fancy headers and footers.
\renewcommand{\headrulewidth}{0pt} % Eliminates the headrule.
\pagestyle{fancy}
\lhead{PH211}
\chead{Physical Mathematics I}
\rhead{Fall \number\year}
\lfoot{Ewan Stewart}
\rfoot{\number\year/\number\month/\number\day}


%%%% Figures %%%%

\usepackage{tikz} % PGF figures
%\usepackage{graphicx} % A package for including external graphics (included in the TikZ package loaded above).

\usetikzlibrary{decorations.markings} % A TikZ library for adding marks, for example arrows or labels, to paths.
\tikzset{labelled arrow/.style 2 args={postaction={decorate,decoration={markings,mark=at position #1 with {\arrow[xshift=0.5\pgflinewidth]{>}; \path #2;}}}}} % Defines the TikZ style "labelled arrow={<position along path>}{<label contents>}" to be an arrow at "<position along path>" labelled by "\path<label contents>;".


%%%% Color %%%%

%\usepackage{xcolor} % A package to add color (included in the TikZ package loaded above).
\definecolor{green}{rgb}{0,0.8,0} % Redefines the color green.


%%%% Hypertext links %%%%

\usepackage[hidelinks]{hyperref} % A package for creating hypertext links. The option "hidelinks" sets links to be unhighlighted.


%%%% Mathematics %%%%

\usepackage{amssymb} % A package for extra mathematical symbols.
\usepackage{bm} % A package for bold mathematical symbols.

\newcommand{\N}{\mathbb{N}} % Defines the command "\N" to be "N" written in blackboard bold font.
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}

\renewcommand{\Re}{\mathop{\mathrm{Re}}} % Redefines the command "\Re" to be "Re" written in Roman font and treated as a mathematical operator.
\renewcommand{\Im}{\mathop{\mathrm{Im}}}
\newcommand{\sgn}{\mathop{\mathrm{sgn}}}
\newcommand{\Tr}{\mathop{\mathrm{Tr}}}

\renewcommand{\d}[1]{\mathinner{d#1}} % Redefines the command "\d{ }" to be "d" followed by its argument and treated as a sub-formula.
\newcommand{\fn}[2]{\mathinner{#1\mathopen{\left(#2\right)}}} % Defines the command "\fn{ }{ }" to be its first argument followed by "\left(" followed by its second argument followed by "\right)" and treated as a sub-formula. The "\mathopen" command makes the spacing before the "\left(" appropriate for a "(" rather than a sub-formula.
\newcommand{\order}[1]{\mathinner{\mathcal{O}\mathopen{\left(#1\right)}}}
\newcommand{\dd}[1]{\mathop{\frac{d}{d #1}}} % Defines the command "\dd{}" to be the total derivative with respect to its argument and treated as a mathematical operator.
\newcommand{\derder}[1]{\mathop{\frac{\partial}{\partial #1}}} % Defines the command "\derder{}" to be the partial derivative with respect to its argument and treated as a mathematical operator.

\newcommand{\bra}[1]{\left\langle #1 \right|} % Defines a new command "\bra{ }" to be a left angled bracket "\langle" followed by its argument followed by "|".
\newcommand{\ket}[1]{\left| #1 \right\rangle}
\newcommand{\braket}[2]{\left\langle \mathord{#1} | \mathord{#2} \right\rangle} % Defines a new command "\braket{ }{ }" to be a left angled bracket "\langle" followed by its first argument followed by "|" followed by its second argument followed by a right angled bracket "\rangle".

\newcommand{\hilbert}[1]{\mathcal{#1}} % Defines the notation for Hilbert spaces to be calligraphic.

\newcommand{\vect}[1]{\bm{#1}} % Defines vector notation to be boldface.
\newcommand{\unitvect}[1]{\hat{\bm{#1}}} % Defines unit vector notation to be hatted boldface.

\newcommand{\eqnarrayrelation}[1]{\hspace{\tabcolsep} #1 \hspace{\tabcolsep}} % Puts spacing around its argument equivalent to that in an eqnarray environment.


%%%% Text %%%%

\newcommand{\keyword}[1]{\textbf{#1}} % Defines the command "\keyword{<text>}" to be its argument written in bold font.
\newcommand{\eq}[1]{Eq.~(\ref{#1})} % Defines the command "\eq{<equation label>}" to be "Eq.~(<equation number>)".
\newcommand{\eqs}[2]{Eqs.~(\ref{#1}) and (\ref{#2})} % Defines the command "\eqs{<first equation label>}{<second equation label>}" to be "Eqs.~(<first equation number>) and (<second equation number>)".
\newcommand{\eqss}[3]{Eqs.~(\ref{#1}), (\ref{#2}) and (\ref{#3})} % Defines the command "\eqss{<first equation label>}{<second equation label>}{<third equation label>}" to be "Eqs.~(<first equation number>), (<second equation number>) and (<third equation number>)".


%%%% Counters %%%%

\@addtoreset{equation}{section} % Resets the equation counter to zero at the beginning of each section.
\renewcommand{\theequation}{\thesection.\arabic{equation}} % Changes equation numbering to "(chapter.section.equation)".
\@addtoreset{table}{section}
\renewcommand{\thetable}{\thesection.\arabic{table}}
\@addtoreset{figure}{section}
\renewcommand{\thefigure}{\thesection.\arabic{figure}}


%%%% Homework %%%%

\newcounter{homework} % Defines a new counter "homework".

\newenvironment{homework}[1][]{
\renewcommand{\thequestion}{\thehomework.\arabic{question}} % Redefines the question number to be "<the homework number>.<value of the question counter written in Arabic numerals>".
\renewcommand{\theequation}{\theenumi.\arabic{equation}} % Redefines the equation number to be "<the item number>.<value of the equation counter written in Arabic numerals>".
\renewcommand{\thefigure}{\theenumi.\arabic{figure}} % Redefines the figure number to be "<the item number>.<value of the figure counter written in Arabic numerals>".
\section*{Homework \thehomework}
#1
\begin{enumerate}
}{
\end{enumerate}
}
% Defines the environment "homework" to be an unnumbered section title "Homework <the homework number>" followed by its optional argument followed by a numbered list environment.


%%%% Exam %%%%

\newenvironment{exam}[2]{
\renewcommand{\theequation}{\theenumi.\arabic{equation}} % Redefines the equation number to be "<the item number>.<value of the equation counter written in Arabic numerals>".
\renewcommand{\thefigure}{\theenumi.\arabic{figure}} % Redefines the figure number to be "<the item number>.<value of the figure counter written in Arabic numerals>".
\subsection*{Final Exam - #1, #2}
You should start from basic principles and give reasoning at every step.
Answers should be clear and concise.
Unclear or excessively long answers will not be graded.
\begin{enumerate}
}{
\end{enumerate}
}
% Defines the environment "exam", with two arguments for time and place, to be an unnumbered section title "Final Exam - <time>, <place>" followed by some comments and a numbered list environment.


%%%% Questions and Answers %%%%

\newcounter{question} % Defines a new counter "question".

\newcommand{\question}[1]{
\refstepcounter{question} \label{#1} % Adds one to the question counter and makes a reference to the label produce the question number.
\renewcommand{\theenumi}{Q\thequestion} % Redefines the item number to be "Q<the question number>".
\item
\setcounter{equation}{0} % Resets the equation counter to zero.
\setcounter{figure}{0} % Resets the figure counter to zero.
}
% Defines the command "\question{<question label>}" to be a labelled list item.

\newcommand{\answer}[1]{
\renewcommand{\theenumi}{A\ref{#1}} % Redefines the item number to be "A<the referred question number>".
\item
\setcounter{equation}{0} % Resets the equation counter to zero.
\setcounter{figure}{0} % Resets the figure counter to zero.
}
% Defines the command "\answer{<question label>}" to be a list item with reference to a question.


%%%% End %%%%

