% Macros and include files for 18.02 LaTeX details files.  HB, 10/25/10
% Recommended by jorloff@mit.edu

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  Packages
\usepackage{amssymb,amsmath}
\usepackage{bm}
\usepackage{array} 
\usepackage{amsfonts} 
\usepackage{mathpazo}
\usepackage{graphicx}  %needed for the includegraphics command
\usepackage{verbatim} % needed for comment environment
\usepackage{ifthen} % needed for ifthenelse
%\def\paperwd{4.5in}
%\def\boardwd{4.5in}
%\def\marginwd{2ex}
%\def\boardht{2in}
%\usepackage[papersize={\paperwd,\boardht},hmargin=\marginwd,vmargin=\marginwd,marginparsep=0in,marginparwidth=0in,textwidth=\boardwd,textheight=\boardht,offset=0in]{geometry}

\usepackage{enumerate}     % lets me use letters for responses.
\usepackage{cancel} % For cancelling in equations
\usepackage{color} % used in 18.02 lecture 21 boards
%\usepackage{wasysym} % double integral over a closed surface symbol
\usepackage{pifont}

%\setlength{\tabcolsep}{1mm}
%\setlength{\parindent}{0in}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Imageds
\def\imgdir{../Images}

% Change from eps to pdf to make work with TeXworks.
\def\mypic#1{\includegraphics{\imgdir/#1.pdf}}
%\def\mypic#1{\includegraphics{\imgdir/#1.eps}}
\def\mypicw#1#2{\includegraphics[width=#2\textwidth]{\imgdir/#1.pdf}}
%\def\mypic#1{\includegraphics[width=1in]{\imgdir/temp.pdf}}
%\def\mypicw#1#2{\includegraphics[width=#2\textwidth]{\imgdir/temp.pdf}}
\def\mypica#1#2#3{\begin{minipage}[#3]{#2\textwidth}\includegraphics[width=\textwidth]{\imgdir/#1.pdf}\end{minipage}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  Simple macros
\def\mypar{\\[1ex]}
\def\mcent#1{\hspace*{\stretch{1}}#1\hspace*{\stretch{1}}{ }}
\def\hs#1{\hspace*{#1 ex}}
\def\nl#1{\\[.#1ex]}
\def\ds{\displaystyle}

\def\dfn{\textbf{Definition:  }}
\def\thm{\textbf{Theorem:  }}
\def\myover#1#2{\overbrace{#1}^{#2}}
\def\myunder#1#2{\underbrace{#1}_{#2}}
\def\qa#1#2{\bigskip\textbf{Question:  }#1

 \textbf{Answer:  }#2 \bigskip}
\def\mdds#1#2{\displaystyle{\frac{d#1}{d#2}}}

%%%% Problem and solution environments for 18.06 assignments
\newcounter{problem}
\newcounter{session}
\def\problem#1{\addtocounter{problem}{1}\vspace{15 pt} \noindent\textbf{Problem \arabic{session}.\arabic{problem}:} \quad #1}
% Use the following definition to see full solutions in the pdf.
% Comment it out and uncomment the next to hide solutions.
\long\def\solution#1{\vspace{10 pt} \noindent\textbf{Solution:}\quad #1}
% Use the following definition to hide full solutions in the pdf.
% Comment it out and uncomment the previous to see solutions.
%\long\def\solution#1{}

\def\cont{\vspace*{\stretch{1}}\emph{(continued)} \newpage}
\def\topic{\textbf{Topic: }}
\def\reading{\textbf{Reading: }}
\def\examples{\textbf{Examples: }}
\def\example{\textbf{Example: }}
\def\examp#1{\textbf{Example #1: }}
\def\problems{\textbf{Problems: }}
\def\indetop#1#2#3{\stackrel{\; \scriptstyle{{#1}{#3}{#2}}}{=} \;}
\def\indet#1#2{\stackrel{\scriptstyle{\; \frac{#1}{#2}}}{=} \;}
\def\indetzero{\indet{0}{0}}
\def\indetinf{\indetop{\infty}{\infty}{/}}
\def\qedbox{\rule{1ex}{1ex}}

%% Blackboard bold R and C, for real and complex numbers.  --HB, June 2011
\def\R{\mathbb{R}}
\def\C{\mathbb{C}}

\def\mypart#1#2{\frac{\partial #1}{\partial #2}}
%      fully specified partial
\def\fp#1#2#3{(\partial #1/\partial #2)_{#3}}                %without \frac
\def\ffp#1#2#3{\left.\frac{\partial #1}{\partial #2}\right|_{#3}}  %with \frac
\def\mpp#1#2#3{\left(\mypart{#1}{#2}\right)_{#3}}
\def\myderiv#1#2{\frac{d#1}{d#2}}
\def\mynderiv#1#2#3{\frac{d^{#3}#1}{d#2^{#3}}}
\def\mygrad{\vba{\boldsymbol{\nabla}}}         %gradient
\def\mycurl{\mbox{curl}}
\def\gf#1#2{\left.\mygrad #1\right|_{#2}}
\def\endandindent{\\ \hspace*{20pt}}
\def\e#1{\mathrm{e}^{#1}}
\def\myIm{\textup{Im}}
\def\myRe{\textup{Re}}
\def\conj#1{\overline{#1}}
\def\tran{^\mathrm{T}}
\def\ans{{\bf \underline{answer:}}{ }}
\def\th{$^{\mathrm{th}}$}
\def\myhead#1{\noindent \textbf{#1}}
\def\tbf#1{\textbf{#1}}
\def\mysep{: }
\def\lap{{\mathcal{L}}}
\def\ilap{\lap^{-1}}
\def\myimply{\; \Rightarrow \;}
\def\myequiv{\; \Leftrightarrow \;}
\def\ft{\hat}
\def\bypartshelp#1#2#3#4#5#6#7{\framebox{$\begin{array}[#7]{lll}
#5=#1 & d#6=#2\\
d#5=#3 & #6=#4 \end{array}$}}
\def\byparts#1#2#3#4{\bypartshelp{#1}{#2}{#3}{#4}{u}{v}{l}}
\def\bypartst#1#2#3#4{\bypartshelp{#1}{#2}{#3}{#4}{u}{v}{t}}

%matrices
\def\defleftbrace{[}
\def\defrightbrace{]}
\def\twobytwohelp#1#2#3#4#5#6#7{\left#6 \begin{array}{#1} #2 & #3 \\ #4 & #5 \end{array} \right#7}
\def\twobytwo#1#2#3#4{\twobytwohelp{rr}{#1}{#2}{#3}{#4}{\defleftbrace}{\defrightbrace}}
\def\twobytwoc#1#2#3#4{\twobytwohelp{cc}{#1}{#2}{#3}{#4}{\defleftbrace}{\defrightbrace}}
\def\twobytwodet#1#2#3#4{\twobytwohelp{rr}{#1}{#2}{#3}{#4}{|}{|}}
\def\twobytwodetc#1#2#3#4{\twobytwohelp{cc}{#1}{#2}{#3}{#4}{|}{|}}
\def\twobyonehelp#1#2#3{\left\defleftbrace \begin{array}{#1} #2\\ #3  \end{array} \right\defrightbrace}
\def\twobyone#1#2{\twobyonehelp{r}{#1}{#2}}
\def\twobyonec#1#2{\twobyonehelp{c}{#1}{#2}}
\def\threebythree#1#2#3#4#5#6#7#8#9{\left\defleftbrace \begin{array}{rrr} #1&#2&#3\\ #4&#5&#6\\ #7&#8&#9 \end{array} \right\defrightbrace}
\def\threebythreec#1#2#3#4#5#6#7#8#9{\left\defleftbrace \begin{array}{ccc} #1&#2&#3\\ #4&#5&#6\\ #7&#8&#9 \end{array} \right\defrightbrace}
\def\threebythreedet#1#2#3#4#5#6#7#8#9{\left| \begin{array}{rrr} #1&#2&#3\\ #4&#5&#6\\ #7&#8&#9 \end{array} \right|}
\def\threebythreedetc#1#2#3#4#5#6#7#8#9{\left| \begin{array}{ccc} #1&#2&#3\\ #4&#5&#6\\ #7&#8&#9 \end{array} \right|}
\def\threebyone#1#2#3{\left\defleftbrace \begin{array}{r} #1\\ #2\\ #3 \end{array} \right\defrightbrace}
\def\threebyonec#1#2#3{\left\defleftbrace \begin{array}{c} #1\\ #2\\ #3 \end{array} \right\defrightbrace}
\def\threebytwo#1#2#3#4#5#6{\left\defleftbrace \begin{array}{rr} #1&#2\\ #3&#4\\ #5&#6 \end{array} \right\defrightbrace}
\def\twobythree#1#2#3#4#5#6{\left\defleftbrace \begin{array}{rrr} #1&#2&#3\\#4&#5&#6 \end{array} \right\defrightbrace}
\def\threebytwoc#1#2#3#4#5#6{\left\defleftbrace \begin{array}{cc} #1&#2\\ #3&#4\\ #5&#6 \end{array} \right\defrightbrace}
\def\fourbyone#1#2#3#4{\left\defleftbrace \begin{array}{r} #1\\ #2\\ #3\\ #4 \end{array} \right\defrightbrace}
\def\onebytwo#1#2{\left\defleftbrace\begin{array}{rr} #1&#2 \end{array}\right\defrightbrace}
\def\onebythree#1#2#3{\left\defleftbrace\begin{array}{rrr} #1&#2&#3 \end{array}\right\defrightbrace}
\def\onebyfour#1#2#3#4{\left\defleftbrace\begin{array}{rrrr} #1&#2&#3&#4 \end{array}\right\defrightbrace}


%Vectors and line segments
\def\vb#1{\mathbf{#1}}  %bold
\def\vh#1{\hat{\mathbf{#1}}}  %bold
%\def\mb#1{\mathbf{#1}}  %bold (intended for matrices)
\def\mb#1{#1}  %bold (intended for matrices)
%\def\va#1{\overrightarrow{#1}}  %arraow
\def\va#1{\vec{\mathbf{#1}}}  %{\vec{#1}}  %arraow
\def\vba#1{\overrightarrow{\mathbf{#1}}}  %bold/arraow
\def\vl#1{\overline{#1}} %overline
\def\vbl#1{\overline{\mathbf{#1}}} %bold/overline
\def\vu#1{\vbu{#1}} %unit vector
\def\vbu#1{\hat{\mathbf{#1}}} %bold/unit vector
\def\un#1{\frac{#1}{\left|#1\right|}}  %normalize vector
\def\vbi{\mathbf{i}}
\def\vbj{\mathbf{j}}
\def\vbk{\mathbf{k}}
\def\vc#1{\langle #1 \rangle}
\def\vcb#1{\left\langle #1 \right\rangle}
\def\bbi{\vb{i}} %{\vu{\bm\imath}} %{\hat \imath}
\def\bbj{\vb{j}} %{\vu{\bm\jmath}} %{\hat \jmath}
\def\bbk{\vb{k}}  %{\hat k}

%spencer's commands
\newcommand{\ul}[1]{\emph{#1}} 
\newcommand{\fdotdr}{\int_C \va{F} \cdot d\va{r}} % Changed by Heidi
\newcommand{\F}{\va{F}} % Changed by Heidi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 18.02 blackboard macros

%The debugtag adds a label to the end of the board
%\def\debugtag{\,\textbf{ENDBOARD}}
\def\debugtag{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\dividecellsnoline{\hspace*{.3ex}}
\def\dividecellsline{\hspace*{1ex}&\hspace*{1ex}}
\def\blankboard{\hs1\\}
\def\myaddpagenumber{\raisebox{1.5ex}[0pt][0pt]{\hspace*{4.2in}\thepage}\\[-2.5ex]}

\newenvironment{board}{\myaddpagenumber}{\debugtag\newpage}

% We offer two alternative ways to split boards: using parboxes and using
% minipages

%Args: width1, width2, pos1, pos2, betweenBoxText, text1, text2
\newcommand{\twoboardparboxhelper}[7]{\parbox[#3]{#1}{#6}
#5
\parbox[#4]{#2}{#7}}

%Args: width1, width2, pos1, pos2, betweenBoxText, text1, text2
\newcommand{\twoboardminipagehelper}[7]{\begin{minipage}[#3]{#1}{#6}
\end{minipage}
#5
\begin{minipage}[#4]{#2}{#7}\end{minipage}}


%The boardtwo commands are like the twocell commands 
% except they end with a newpage

%width1, width2, text1, text2 uses l,l for parbox alignment
% No line between boxes, uses parboxes
\long\def\twocell#1#2#3#4{\twoboardparboxhelper{#1}{#2}{l}{l}{\dividecellsnoline}{#3}{#4}\par}

\long\def\boardtwo#1#2#3#4{\myaddpagenumber\twoboardparboxhelper{#1}{#2}{l}{l}{\dividecellsnoline}{#3}{#4}\debugtag\newpage}

%\boardtwot has no line, uses t,t for alignment --same as boardtwoa would be
\long\def\boardtwot#1#2#3#4{\myaddpagenumber\twoboardparboxhelper{#1}{#2}{t}{t}{\dividecellsnoline}{#3}{#4}\debugtag\newpage}

%Args: width1, width2, text1, text2 (uses t,t for position)
% No line between boxes, uses parboxes
\newcommand{\twocella}[4]{\twoboardparboxhelper{#1}{#2}{t}{t}{\dividecellsnoline}{#3}{#4}}

\newcommand{\twocellb}[4]{\twoboardminipagehelper{#1}{#2}{t}{t}{\dividecellsnoline}{#3}{#4}}

\newcommand{\boardtwob}[4]{\myaddpagenumber\twoboardminipagehelper{#1}{#2}{t}{t}{\dividecellsnoline}{#3}{#4}\debugtag\newpage}

%Args: width1, width2, text1, text2 (uses t,t for position)
%Puts line between boxes, uses parboxes
\newcommand{\twocellc}[4]{\begin{tabular}{l|l}
\twoboardparboxhelper{#1}{#2}{t}{t}{\dividecellsline}{#3}{#4}
\end{tabular}}

\newcommand{\boardtwoc}[4]{\myaddpagenumber\begin{tabular}{l|l}
\twoboardparboxhelper{#1}{#2}{t}{t}{\dividecellsline}{#3}{#4}
\end{tabular}\debugtag\newpage}

%Args: width1, width2, text1, text2 (uses t,t for position)
%Puts line between boxes, uses minipages
\newcommand{\twocelld}[4]{\begin{tabular}{l|l}
\twoboardminipagehelper{#1}{#2}{t}{t}{\dividecellsline}{#3}{#4}
\end{tabular}}

\newcommand{\boardtwod}[4]{\myaddpagenumber\begin{tabular}{l|l}
\twoboardminipagehelper{#1}{#2}{t}{t}{\dividecellsline}{#3}{#4}
\end{tabular}\debugtag\newpage}
