%% Calculator button
\usepackage{array, amsmath, mathrsfs, amssymb, color, graphicx, url}
\usepackage{setspace, srcltx,varioref,subfigure,float,stmaryrd,skull}
\usepackage[dvipsnames]{pstricks}
\usepackage{pst-eucl,pst-text,pst-tree,pst-tools,pstricks-add}
\usepackage{paralist,enumitem}
\usepackage{etoolbox}
\usepackage{calc,pifont,fontawesome}
\usepackage[utf8]{inputenc}
\usepackage[none]{hyphenat}
\usepackage[thicklines,Smaller]{cancel}
\usepackage{xlop}
\usepackage[dvips,unicode]{hyperref}
%\usepackage{multienum}
\usepackage[normalem]{ulem}
\usepackage[misc]{ifsym}
\usepackage{multicol}
%\usepackage[toc]{multitoc}
\usepackage[units]{lhelp}
\usepackage[pagestyles]{titlesec}
\usepackage{titletoc}
\usepackage{manfnt}
\usepackage[dvips,twoside,includeheadfoot,bindingoffset=1.5cm,left=1.5cm,right=1.5cm,height=0.9\paperheight]{geometry}
\usepackage[np,autolanguage]{numprint}
\usepackage{apacite}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=endash,format=hang]{caption}
\usepackage[contents=]{background}

%%%%% Custom commands
%%% Multicols 201406 bug fix
%\makeatletter
%\patchcmd\endmulticols
%     {\if@boxedmulticols\color@endgroup}
%     {\if@boxedmulticols\remove@discardable@items\color@endgroup}
%     {\typeout{Success}}{\FAIL}
%\makeatother



\newcommand{\Course}{Mathematics}
\newcommand{\Title}{Introduction to Differentiation}
\newcommand{\Topic}{Course book}
\newcommand{\FileLocation}{/math (ext1)/topics/Topic 07 - Differential calculus/summary/series.tex}

\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\newcommand{\button}[1]{\fbox{\rule[-0.5ex]{0cm}{12pt}\hspace{0.25em}\texttt{#1}\hspace{0.25em}}\ }
\newcommand{\displayas}[2]{\dotfill \psset{xunit=0.5cm,yunit=0.21cm}
\psframebox[linecolor=lightgray]{
\begin{pspicture}(0,-8)(8,0)
\rput[tl](0,0){$\mathtt{#1}$}
\rput[rb](5,-6){$#2$}
\end{pspicture}
}}


%% Table filler - usage: \tablefiller{1cm}


\newcommand{\tablefiller}[1]{\rule[-0.25cm]{0em}{0.6cm}\parbox[m]{#1}{\hfill}}


%% Graph space - usage: \graphspace{horizontal_cm}{vertical_cm}

\newcommand{\graphspace}[2]{
    \begin{center}
    \begin{pspicture}(0,0)(#1,#2)
    \psgrid[gridlabels=0pt,griddots=20,subgriddiv=5,subgriddots=5,gridcolor=gray,subgridcolor=gray]
    \end{pspicture}
    \end{center}
}

\newcommand{\HWDueDate}{
    \paragraph{\faCalendarCheckO\  Complete this by:} \ %

    \Cloze{write due date} %
}


\newcommand{\Var}{\ensuremath{\operatorname{Var}}}
%% http://melusine.eu.org/syracuse/latex/exemples/desousa/definition.tex

\def\mygraphpaper{%
    \rput[tl](-15.5cm,-14.85cm){\psgrid[gridcolor=black!50,subgridcolor=black!80,gridlabels=0pt,griddots=10,subgriddiv=2,subgriddots=5](0,0)(30cm,29.7cm)}
}

%% Placement on first page containing content.
\def\StudentWritingGridOn{
\backgroundsetup{
    angle=0,
    scale=1,
    contents=\mygraphpaper
}
}

%% Placement on pages where no grid required.
\def\StudentWritingGridOff{
\backgroundsetup{
  angle=0,
  contents=,
}
}


%% Placement on pages which has no student written content.

\newcounter{NumLines}
\newcommand{\Lines}[1]{ %
    \setcounter{NumLines}{#1 - 1} %
    \vspace{3mm}
    \begin{flushleft}
    \psLoop{\theNumLines}{\dotfill \\[3ex]}  %
    \dotfill %
    \end{flushleft}
}

\renewcommand{\thepart}{\Roman{part}}

\newcommand{\Dashes}[1]{\vspace{2ex} \psLoop{#1}{\rule{1.5em}{0.4pt} \hspace{0.5ex}}}

\newcommand{\nPr}[2]{\ensuremath{^{#1}P_{#2}}}
\newcommand{\nCr}[2]{\ensuremath{^{#1}C_{#2}}}



\newif\ifShowCloze
\ShowClozefalse
\newcommand{\Cloze}[1]{ %
    \ifShowCloze  %
        \dotuline{\parbox[b]{\widthof{\Huge\textbf{#1}}}{ \vphantom{\vspace{1ex}} \centering %
        {\color{red}  {\protect #1}} %
        }}
         %
    \else %
        \dotuline{\parbox[b]{\widthof{\Huge\textbf{#1}}}{ \vphantom{\vspace{1ex}}\centering %
            \hfill
            }
        }
        %\begin{minipage}[b] %
%        {\widthof{\Huge \textbf{#1}}}  %
%        \vspace{3ex}  %
%        \dotfill  %
%        \end{minipage}   %
    \fi %
}

\newcounter{example}
\newcounter{definition}
\newcounter{theorem}

\newsavebox{\ggbbox}
\newsavebox{\exercisebox}
\newsavebox{\examplebox}
\newsavebox{\histbox}
\newsavebox{\defbox}
\newsavebox{\clozebox}
\newsavebox{\thmbox}
\newsavebox{\lawbox}
\newsavebox{\stepsbox}
\newsavebox{\notebox}
\newsavebox{\remindbox}
\newsavebox{\mmbox}
\newsavebox{\titlebox}
\newsavebox{\learningbox}
\newlength{\margedef}
\newlength{\marge}


\newcommand{\geogebraboxtext}{\textsf{GeoGebra}}
\newcommand{\exampleboxtext}{\raisebox{-0.8ex}{\huge \faGraduationCap} \textsf{Example \theexample}}
\newcommand{\defboxtext}{\raisebox{-0.5ex}{\Large \faBook} \textsf{Definition \thedefinition}}
\newcommand{\stepsboxtext}{\raisebox{-0.8ex}{\huge \faListAlt} \textsf{Steps}}
\newcommand{\thmboxtext}{\raisebox{-0.5ex}{\Large \faMagic} \textsf{Theorem \thetheorem}}
\newcommand{\lawboxtext}{\raisebox{-0.5ex}{\Large \faGavel} \textsf{Laws/Results}}
\newcommand{\histboxtext}{\textsf{History}}
\newcommand{\corboxtext}{\raisebox{-0.5ex}{\Large \faMagic} \textsf{Corollary \thetheorem}}
\newcommand{\exerciseboxtext}{\raisebox{-0.5ex}{\Large \faListOl} \textsf{Further exercises}}
\newcommand{\exerciselegacyboxtext}{\raisebox{-0.5ex}{\Large \faListOl} \textsf{Further exercises (Legacy Textbooks)}}
\newcommand{\clozeboxtext}{\raisebox{-0.25ex}{\large \faEdit} \textsf{Fill in the spaces}}
\newcommand{\noteboxtext}{\raisebox{-0.8ex}{\huge \faExclamationCircle} \textsf{Important note}}
\newcommand{\mmboxtext}{\raisebox{-0.8ex}{\huge \faYoutubePlay} \textsf{Watch multimedia}}
\newcommand{\remindboxtext}{\raisebox{-0.8ex}{\huge \faExclamationCircle} \textsf{Gentle reminder}}
\newcommand{\titleboxtext}{\raisebox{-0.8ex}{\huge \faGraduationCap} \Large \textsf{Topic summary and exercises:}}
\newcommand{\learningboxtext}{\raisebox{-0.8ex}{\huge \faGraduationCap} \textsf{Learning Goal(s)}}

\newlength{\clozetextlength}
\setlength{\clozetextlength}{\widthof{\textbf{\clozeboxtext}+0.5em}}

\newlength{\stepstextlength}
\setlength{\stepstextlength}{\widthof{\textbf{\stepsboxtext}+0.66cm+0.5em}}

\newlength{\thmtextlength}
\setlength{\thmtextlength}{\widthof{\textbf{\thmboxtext}+0.5em}}

\newlength{\lawtextlength}
\setlength{\lawtextlength}{\widthof{\textbf{\lawboxtext}+0.5em}}


\newlength{\histtextlength}
\setlength{\histtextlength}{\widthof{\textbf{\histboxtext}+0.5em}}


\newlength{\ggbtextlength}
\setlength{\ggbtextlength}{\widthof{\textbf{\geogebraboxtext}}+0.5em+1cm}

\newlength{\learningtextlength}
\setlength{\learningtextlength}{\widthof{\textbf{\learningboxtext}+0.5em}}

\newlength{\exampletextlength}
\setlength{\exampletextlength}{\widthof{\textbf{\exampleboxtext}}+\widthof{\textsf{\textbf{8}}}+1cm}

\newlength{\deftextlength}
\setlength{\deftextlength}{\widthof{\textbf{\defboxtext}}+\widthof{\textsf{\textbf{8}}}+0.66cm+1cm}


\newlength{\exercisetextlength}
\setlength{\exercisetextlength}{\widthof{\textbf{\exerciseboxtext}}+1.66cm}


\newlength{\exerciselegacytextlength}
\setlength{\exerciselegacytextlength}{\widthof{\textbf{\exerciselegacyboxtext}}+1.66cm}

\newlength{\notetextlength}
\setlength{\notetextlength}{\widthof{\textbf{\noteboxtext}}+1.66cm}


\newlength{\remindtextlength}
\setlength{\remindtextlength}{\widthof{\textbf{\remindboxtext}}+1.66cm}

\newlength{\mmtextlength}
\setlength{\mmtextlength}{\widthof{\textbf{\mmboxtext}}+1.66cm}

\newlength{\titletextlength}
\setlength{\titletextlength}{\widthof{\textbf{\titleboxtext}}+2.66cm}

\setlength{\marge}{0.75cm}

\newlength{\clozeboxheight}
\newenvironment{cloze}{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   \begin{lrbox}{\clozebox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\clozeboxheight}{\totalheightof{\usebox{\clozebox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=CornflowerBlue!20,framearc=0,framesep=10pt,linecolor=BlueViolet,linestyle=none]{%
      \usebox{\clozebox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\clozetextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    \textcolor{BlueViolet}{\textbf{\clozeboxtext}}%
  }
  \psline[linewidth=3pt,linecolor=BlueViolet](0.22,0)(0.22,-\clozeboxheight)
  \par
  \setlength{\margedef}{\ht\clozebox+\dp\clozebox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\exampleboxheight}
\newenvironment{boxexample}{
%   \par\noindent                        % No indentation
   \begin{flushleft}
   \refstepcounter{example}             % Counter for this environment
   \begin{lrbox}{\examplebox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\exampleboxheight}{\totalheightof{\usebox{\examplebox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=LimeGreen!30,framearc=0,framesep=10pt,linecolor=Green,linestyle=none]{%
      \usebox{\examplebox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\exampletextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{Green}{\parbox[m]{0.7cm}{\includegraphics[width=0.7cm]{./include/question42_Green.eps}} \textbf{\exampleboxtext}}%
    \color{Green} \textbf{\exampleboxtext}
  }
  \psline[linewidth=3pt,linecolor=Green](0.22,0)(0.22,-\exampleboxheight)
  \par
  \setlength{\margedef}{\ht\examplebox+\dp\examplebox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}




\newlength{\stepsboxheight}
\newenvironment{boxsteps}{
   \begin{flushleft}
   \begin{lrbox}{\stepsbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\stepsboxheight}{\totalheightof{\usebox{\stepsbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=magenta!10,framearc=0,framesep=10pt,linecolor=magenta,linestyle=none]{%
      \usebox{\stepsbox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\stepstextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{magenta}{\parbox[m]{0.6cm}{\includegraphics[width=0.6cm]{./include/verification5_magenta.eps}} \textbf{\stepsboxtext}}%
    \color{magenta} \textbf{\stepsboxtext}
  }
  \psline[linewidth=3pt,linecolor=magenta](0.22,0)(0.22,-\stepsboxheight)
  \par
  \setlength{\margedef}{\ht\stepsbox+\dp\stepsbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\histboxheight}
\newenvironment{boxhist}{
%   \par\noindent                        % No indentation
%   \refstepcounter{example}             % Counter for this environment
    \begin{flushleft}
   \begin{lrbox}{\histbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\histboxheight}{\totalheightof{\usebox{\histbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=LimeGreen!30,framearc=0,framesep=10pt,linecolor=Green,linestyle=none]{%
      \usebox{\histbox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\histtextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    \textcolor{Green}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/history3_Green.eps}} \textbf{\histboxtext}}%
  }
  \psline[linewidth=3pt,linecolor=Green](0.22,0)(0.22,-\histboxheight)
  \par
  \setlength{\margedef}{\ht\histbox+\dp\histbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\theoremboxheight}
\newenvironment{boxthm}{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   \refstepcounter{theorem}             % Counter for this environment
   \begin{lrbox}{\thmbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\theoremboxheight}{\totalheightof{\usebox{\thmbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=yellow!30,framearc=0,framesep=10pt,linecolor=red,linestyle=none]{%
      \usebox{\thmbox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\thmtextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    % \textcolor{red}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/books8_red.eps}} \textbf{\thmboxtext}}%
    \color{red} \textbf{\thmboxtext}
  }
  \psline[linewidth=3pt,linecolor=red](0.22,0)(0.22,-\theoremboxheight)
  \par
  \setlength{\margedef}{\ht\thmbox+\dp\thmbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}


\newenvironment{boxcor}{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   \refstepcounter{theorem}             % Counter for this environment
   \begin{lrbox}{\thmbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\theoremboxheight}{\totalheightof{\usebox{\thmbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
     \psframebox[opacity=0.8,fillstyle=solid,fillcolor=yellow!30,framearc=0,framesep=10pt,linecolor=red,linestyle=none]{%
      \usebox{\thmbox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\thmtextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{red}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/right33_red.eps}} \textbf{\corboxtext}}%
    \color{red} \textbf{\corboxtext}
  }
  \psline[linewidth=3pt,linecolor=red](0.22,0)(0.22,-\theoremboxheight)
  \par
  \setlength{\margedef}{\ht\thmbox+\dp\thmbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\lawboxheight}
\newenvironment{boxlaw}{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   %\refstepcounter{theorem}             % Counter for this environment
   \begin{lrbox}{\lawbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\lawboxheight}{\totalheightof{\usebox{\lawbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=yellow!30,framearc=0,framesep=10pt,linecolor=red,linestyle=none]{%
      \usebox{\lawbox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\lawtextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    % \textcolor{red}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/law_red.eps}} \textbf{\lawboxtext}}%
    \color{red} \textbf{\lawboxtext}
  }
  \psline[linewidth=3pt,linecolor=red](0.22,0)(0.22,-\lawboxheight)
  \par
  \setlength{\margedef}{\ht\lawbox+\dp\lawbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\defboxheight}
\newenvironment{boxdef}{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   \refstepcounter{definition}             % Counter for this environment
   \begin{lrbox}{\defbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\defboxheight}{\totalheightof{\usebox{\defbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=blue!10,framearc=0,framesep=10pt,linecolor=blue,linestyle=none]{%
      \usebox{\defbox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\deftextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{Blue}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/books8_Blue.eps}} \textbf{\defboxtext}}%
    \color{Blue} \textbf{\defboxtext}
  }
  \psline[linewidth=3pt,linecolor=Blue](0.22,0)(0.22,-\defboxheight)
  \par
  \setlength{\margedef}{\ht\defbox+\dp\defbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\learningboxheight}


\newenvironment{learninggoal}[5]{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   \begin{lrbox}{\learningbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm} \footnotesize
   \begin{minipage}[t]{0.3\linewidth}
    {\color{magenta} \faList\ \textsf{\textbf{Knowledge}}} \\
    #3
    \end{minipage}
    \hfill
    \begin{minipage}[t]{0.3\linewidth}
    {\color{magenta} \faGears\ \textsf{\textbf{Skills}}} \\
    #4
    \end{minipage}
    \hfill\begin{minipage}[t]{0.3\linewidth}
    {\color{magenta} \faLightbulbO\ \textsf{\textbf{Understanding}}} \\
    #5
    \end{minipage} \\[6pt]
   \textcolor{magenta}{\faCheckSquareO\ \textsf{\textbf{By the end of this section am I able to:}}}
   \begin{enumerate}[label={#1.\arabic*},start=#2]
}
{
  \end{enumerate}
  \end{minipage}
  \end{lrbox}%
  \setlength{\learningboxheight}{\totalheightof{\usebox{\learningbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=magenta!10,framesep=10pt,linecolor=Green,linestyle=none]{ %framearc=0.1,
      \usebox{\learningbox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\learningtextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{magenta}{\parbox[m]{4cm}{\faGraduationCap\ \textbf{\learningboxtext}}}%
    \color{magenta} \textbf{\learningboxtext}
  }
  \psline[linewidth=3pt,linecolor=magenta](0.22,0)(0.22,-\learningboxheight)
  \par
  \setlength{\margedef}{\ht\learningbox+\dp\learningbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

% \newlength{\learningboxheight}
% \newenvironment{learninggoal}[2]{
%   %\par\noindent                        % No indentation
%   \begin{flushleft}
%   \begin{lrbox}{\learningbox}           % Name of box to contain text \footnotesize
%   \begin{minipage}{0.95\linewidth-0.5cm}  \footnotesize
%   \textcolor{Green}{\faCheckSquareO\ \textsf{\textbf{By the end of this section am I able to:}}}
%   \begin{enumerate}[label={#1.\arabic*},start=#2]
% }
% {
%   \end{enumerate}
%   \end{minipage}
%   \end{lrbox}%
%   \setlength{\learningboxheight}{\totalheightof{\usebox{\learningbox}}+20.5pt}
%   \rput[tl](0,0){   % Choose colours of framebox
%     \psframebox[opacity=0.8,fillstyle=solid,fillcolor=LimeGreen!30,framesep=10pt,linecolor=Green,linestyle=none]{ %framearc=0.1,
%       \usebox{\learningbox}
%     }
%   }
%   \rput[l](1cm,0){      % Patch white line
%     \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\learningtextlength,0)%
%   }%
%   \rput[l](1cm,0.5ex){  % Place text
%     \textcolor{Green}{\parbox[m]{4cm}{\faGraduationCap\ \textbf{\learningboxtext}}}%
%   }
%   \psline[linewidth=3pt,linecolor=Green](0.22,0)(0.22,-\learningboxheight)
%   \par
%   \setlength{\margedef}{\ht\learningbox+\dp\learningbox+\marge}
%   \vspace{\margedef}
%   \end{flushleft}
% }

\newlength{\titleboxheight}
\newenvironment{boxtitle}{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   \begin{lrbox}{\titlebox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\titleboxheight}{\totalheightof{\usebox{\titlebox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=LimeGreen!30,framesep=10pt,linecolor=Green,linestyle=none]{% %%% framearc=0.25
      \usebox{\titlebox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\titletextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{Green}{\parbox[m]{1cm}{\includegraphics[width=1cm]{./include/question42_Green.eps}} \textbf{\titleboxtext}}%
    \color{Green} \textbf{\titleboxtext}
  }
  \psline[linewidth=3pt,linecolor=Green](0.22,0)(0.22,-\titleboxheight)
  \par
  \setlength{\margedef}{\ht\titlebox+\dp\titlebox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

%%% Boxed number macro from http://tex.stackexchange.com/questions/22381/how-to-box-every-digit-of-an-integer
\newcommand*{\boxednumber}[1]{%
    \expandafter\readdigit\the\numexpr#1\relax\relax
}
\newcommand*{\readdigit}[1]{%
    \ifx\relax#1\else
        \boxeddigit{#1}%
        \expandafter\readdigit
    \fi
}
% Format macro used for every digit, adjust to your liking:
\newcommand*{\boxeddigit}[1]{\fbox{#1}\hspace{-\fboxrule}}


%%%%%%
\newlength{\exerciseboxheight}
\newenvironment{exercise}{
   \par\noindent                        % No indentation    
   \begin{flushleft}
   \begin{lrbox}{\exercisebox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\exerciseboxheight}{\totalheightof{\usebox{\exercisebox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=YellowOrange!30,framearc=0,framesep=10pt,linestyle=none,linecolor=RedOrange]{%
      \usebox{\exercisebox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\exercisetextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{RedOrange}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/online16_orangered.eps}} \textbf{\exerciseboxtext}}%
    \color{RedOrange} \textbf{\exerciseboxtext}
  }
  \psline[linewidth=3pt,linecolor=RedOrange](0.22,0)(0.22,-\exerciseboxheight)
  \par
  \setlength{\margedef}{\ht\exercisebox+\dp\exercisebox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newenvironment{exerciselegacy}{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   \begin{lrbox}{\exercisebox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\exerciseboxheight}{\totalheightof{\usebox{\exercisebox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=gray!40,framearc=0,framesep=10pt,linecolor=black,linestyle=none]{%
      \usebox{\exercisebox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\exerciselegacytextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{black}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/online16_orangered.eps}} \textbf{\exerciselegacyboxtext}}%
    \color{black} \textbf{\exerciselegacyboxtext}
  }
  \psline[linewidth=3pt,linecolor=black](0.22,0)(0.22,-\exerciseboxheight)
  \par
  \setlength{\margedef}{\ht\exercisebox+\dp\exercisebox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\noteboxheight}
\newenvironment{boxnote}{
   \begin{flushleft}                        % No indentation
   \begin{lrbox}{\notebox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\noteboxheight}{\totalheightof{\usebox{\notebox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=red!30,framesep=10pt,linecolor=BrickRed,linestyle=none]{
      \usebox{\notebox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\notetextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{BrickRed}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/man176_brickred.eps}} \textbf{\noteboxtext}}%
    \color{BrickRed} \textbf{\noteboxtext}
  }
  \psline[linewidth=3pt,linecolor=BrickRed](0.22,0)(0.22,-\noteboxheight)
  \par
  \setlength{\margedef}{\ht\notebox+\dp\notebox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\remindboxheight}
\newenvironment{boxremind}{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   \begin{lrbox}{\remindbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\remindboxheight}{\totalheightof{\usebox{\remindbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=red!30,framesep=10pt,linecolor=BrickRed,linestyle=none]{ % framearc=0.25,
      \usebox{\remindbox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\remindtextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{BrickRed}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/man176_brickred.eps}} \textbf{\remindboxtext}}%
    \color{BrickRed} \textbf{\remindboxtext}
  }
  \psline[linewidth=3pt,linecolor=BrickRed](0.22,0)(0.22,-\remindboxheight)
  \par
  \setlength{\margedef}{\ht\remindbox+\dp\remindbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\mmboxheight}
\newenvironment{boxmm}{
   %\par\noindent                        % No indentation
   \begin{flushleft}
   \begin{lrbox}{\mmbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\mmboxheight}{\totalheightof{\usebox{\mmbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=red!30,framesep=10pt,linecolor=BrickRed,linestyle=none]{ % framearc=0.25,
      \usebox{\mmbox}
    }
  }
  \rput[l](1cm,0){      % Patch white line
    \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\mmtextlength,0)%
  }%
  \rput[l](1cm,0.5ex){  % Place text
    \color{BrickRed} \textbf{\mmboxtext}%
  }
  \psline[linewidth=3pt,linecolor=BrickRed](0.22,0)(0.22,-\mmboxheight)
  \par
  \setlength{\margedef}{\ht\mmbox+\dp\mmbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

\newlength{\ggbboxheight}
\newenvironment{geogebra}{
%   \par\noindent                        % No indentation
   \begin{flushleft}
   %\refstepcounter{example}             % Counter for this environment
   \begin{lrbox}{\ggbbox}           % Name of box to contain text
   \begin{minipage}{0.95\linewidth-0.5cm}
}
{
  \end{minipage}
  \end{lrbox}%
  \setlength{\ggbboxheight}{\totalheightof{\usebox{\ggbbox}}+20.5pt}
  \rput[tl](0,0){   % Choose colours of framebox
    \psframebox[opacity=0.8,fillstyle=solid,fillcolor=blue!10,framearc=0,
 	framesep=10pt,linecolor=blue,linestyle=none]{%
      \usebox{\ggbbox}
    }
  }
%   \rput[l](1cm,0){      % Patch white line
%     \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\geogebraboxtext)%
%   }%
  \rput[l](1cm,0.5ex){  % Place text
    %\textcolor{Green}{\parbox[m]{0.7cm}{\includegraphics[width=0.7cm]{./include/question42_Green.eps}} \textbf{\exampleboxtext}}%
    %\color{blue} \textbf{\geogebraboxtext}
    \textcolor{blue}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/geogebra.eps}} \textbf{\geogebraboxtext}}%
  }
  \psline[linewidth=3pt,linecolor=gray](0.22,0)(0.22,-\ggbboxheight)
  \par
  \setlength{\margedef}{\ht\ggbbox+\dp\ggbbox+\marge}
  \vspace{\margedef}
  \end{flushleft}
}

% \newlength{\ggbboxheight}
% \newenvironment{geogebra}{%
%   %\par\noindent          % attention au retrait d'aline'a
%   \begin{flushleft}
%   \begin{lrbox}{\ggbbox} %de'finition de la boite contenant le texte
%   \begin{minipage}{0.95\linewidth-0.5cm}
% }
% {%
%   \end{minipage}
%   \end{lrbox}%
%   \setlength{\ggbboxheight}{\totalheightof{\usebox{\ggbbox}}+20.5pt}
%   \rput[tl](0,0){%
%     \psframebox[opacity=0.8,fillstyle=solid,fillcolor=blue!10,framearc=0,
% 	framesep=10pt,linecolor=blue,linestyle=none]{%
%       \usebox{\ggbbox}
%     }%
%   }%
% %on enle`ve le trait
% %   \rput[l](1cm,0){%
% %     \psline[linewidth=2.1\pslinewidth,linecolor=white](-0.25em,0)(\ggbtextlength,0)%
% %   }%
% %on e'crit ce qu'on veut...
%   \rput[l](1cm,0.5ex){%
%     \textcolor{blue}{\parbox[m]{0.66cm}{\includegraphics[width=0.66cm]{./include/geogebra.eps}} \textbf{\geogebraboxtext}}%
%   }%
%   \psline[linewidth=3pt,linecolor=gray](0.22,0)(0.22,-\ggbboxheight)
%   \par
%   \setlength{\margedef}{\ht\ggbbox+\dp\ggbbox+\marge}
%   \vspace{\margedef}
%   \end{flushleft}
% }

\newcommand{\answer}[1]{\vphantom{a} \hfill {\scriptsize \textbf{Answer:} #1}}
\renewcommand{\marks}[1]{(#1 \ifthenelse{#1=1}{mark}{marks})}
\newsavebox{\QuestionContent}
\newsavebox{\MarksPerQuestion}

\newenvironment{question}[1]{
\sbox{\MarksPerQuestion}{\textbf{#1}}
\begin{minipage}[t]{0.9\linewidth}
}
{\end{minipage} \usebox{\QuestionContent} \hfill \usebox{\MarksPerQuestion}
}

\newenvironment{answers}{
\subsubsection{Answers}
\scriptsize
}
{ \normalsize
}

\newcommand{\CommonContent}{\protect\scalebox{0.65}{\raisebox{0.2ex}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{S2}}}}} }
\newcommand{\TwoU}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{2}}}} }
\newcommand{\Adv}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{A}}}} }
\newcommand{\ExtOne}{\protect\scalebox{0.6}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{X1}}}} }
\newcommand{\ExtTwo}{\protect\scalebox{0.6}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{X2}}}} }

%\newcommand{\Adv}{\protect\scalebox{0.8}{\protect\pscirclebox[fillstyle=solid,fillcolor=linewidth=1pt]{\textbf{\textsf{MA}}}} }
%\newcommand{\ExtOne}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{ME}}}} }
%\newcommand{\ExtTwo}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{MX}}}} }

%\newcommand{\Review}{\textbf{[R]} }
% \newcommand{\Review}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{R}}}} }
\newcommand{\Review}{{\Large \raisebox{-1pt}{\faRefresh}} }

% \newcommand{\RefSheet}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{F}}}} }
\newcommand{\RefSheet}{{\Large \raisebox{-1pt}{\faFileCodeO}} }
%\newcommand{\Warn}{\protect\scalebox{0.88}{\raisebox{-0.45pt}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{!}}}}} }
\newcommand{\Warn}{{\Large \raisebox{-1pt}{\faExclamationTriangle}} }

%\newcommand{\Literacy}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{L}}}} }
\newcommand{\Literacy}{{\Large \raisebox{-1pt}{\faLanguage}} }

% \newcommand{\Extension}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{E}}}} }
\newcommand{\Extension}{{\Large \raisebox{-1pt}{\faStepForward}} }

%\newcommand{\SyllCont}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{S}}}} }
\newcommand{\SyllCont}{{\Large \raisebox{-1pt}{\faQuoteLeft}} }

%\newcommand{\Enrich}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{N}}}} }
\newcommand{\Enrich}{{\Large \raisebox{-1pt}{\faMagic}} }

\newcommand{\Uncertain}{\protect\scalebox{0.88}{\raisebox{-0.45pt}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{?}}}}} }


%\newcommand{\URL}{\protect\scalebox{0.45}{\raisebox{2.9pt}{\pscirclebox[linewidth=1.75pt]{\textbf{\textsf{URL}}}}} }
\newcommand{\URL}{{\Large \raisebox{-1pt}{\faExternalLink}} }

%\newcommand{\ICT}{\protect\scalebox{0.885}{\raisebox{-0.5pt}{\pscirclebox[linewidth=0.95pt]{\includegraphics[scale=0.0092]{./include/mouse-cursor-icon.eps}}}} }
\newcommand{\ICT}{{\Large \raisebox{-1pt}{\faLaptop}} }


% \newcommand{\Assumption}{\protect\scalebox{0.8}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{A}}}} }


\newcommand{\Assumption}{{\Large \raisebox{-1pt}{\faQuoteRight}} }
%\newcommand{\Memorise}{\protect\scalebox{0.72}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{M}}}} }
\newcommand{\Memorise}{{\Large \raisebox{-1pt}{\faSave}} }

% \newcommand{\Understand}{\protect\scalebox{0.76}{\protect\pscirclebox[linewidth=1pt]{\textbf{\textsf{U}}}} }

\newcommand{\Understand}{{\Large \raisebox{-1pt}{\faLightbulbO}} }


\newcommand{\abs}[1]{\ensuremath{\left| #1 \right|}}
\newcommand{\dotX}[1]{\ensuremath{\overset{\psdot[dotscale=0.66]}{#1}}}
\newcommand{\ddotX}[1]{\ensuremath{\overset{\psdot[dotscale=0.66]\hspace{0.55ex}\psdot[dotscale=0.66]}{#1}}}
\newcommand{\ATAN}{\ensuremath{\tan^{-1}}}
\newcommand{\ACOS}{\ensuremath{\cos^{-1}}}
\newcommand{\ASIN}{\ensuremath{\sin^{-1}}}
\newcommand{\Arg}{\ensuremath{\operatorname{Arg}}}
\newcommand{\cvv}[2]{\ensuremath{\begin{pmatrix} #1 \\ #2 \end{pmatrix}}}
\newcommand{\cvvv}[3]{\ensuremath{\begin{pmatrix} #1 \\ #2 \\ #3 \end{pmatrix}}}
%\newcommand{\vb}[1]{\ensuremath{\mathbf{#1}}}
\newcommand{\vb}[1]{\ensuremath{\undertilde{\mathrm{#1}}}}
\newcommand{\nbinom}[2]{\ensuremath{\,{^{#1}}C_{#2}}}
\newcommand{\vij}[2]{\ensuremath{ % remove the '1' if it's '-1'
    \ifthenelse{\equal{#1}{0}}{}{
        \ifthenelse{\equal{#1}{-1}}{-}{
            \ifthenelse{\equal{#1}{1}}{}{#1\,} %
        } \vb{i} % leave a blank if it's '1'
    }
    \ifthenelse{\equal{#2}{0}}{}{
        \ifthenelse{\equal{#2}{-1}}{-}{ % remove the '1' if it's '-1'
            \ifthenelse{\equal{#2}{1}}{+}{ % leave a blank if it's '1'
                \noexpandarg\IfBeginWith{#2}{-}{#2 \,}{+ #2 \,} % check if it's negative or not
            } 
        } \vb{j}
    }
}}
\newcommand{\vijk}[3]{\ensuremath{ % remove the '1' if it's '-1'
    \ifthenelse{\equal{#1}{0}}{}{
        \ifthenelse{\equal{#1}{-1}}{-}{
            \ifthenelse{\equal{#1}{1}}{}{#1\,} %
        } \vb{i} % leave a blank if it's '1'
    }
    \ifthenelse{\equal{#2}{0}}{}{
        \ifthenelse{\equal{#2}{-1}}{-}{ % remove the '1' if it's '-1'
            \ifthenelse{\equal{#2}{1}}{+}{ % leave a blank if it's '1'
                \noexpandarg\IfBeginWith{#2}{-}{#2 \,}{+ #2 \,} % check if it's negative or not
            }
        } \vb{j} 
    }
    \ifthenelse{\equal{#3}{0}}{}{
        \ifthenelse{\equal{#3}{-1}}{-}{ % remove the '1' if it's '-1'
            \ifthenelse{\equal{#3}{1}}{+}{ % leave a blank if it's '1'
                \noexpandarg\IfBeginWith{#3}{-}{#3 \,}{+ #3 \,} % check if it's negative or not
            }
        } \vb{k} 
    }
}}
\newcommand{\proj}{\ensuremath{\operatorname{proj}}}

\newcommand{\titleblock}{%
\begin{center}
\begin{minipage}[m]{2cm}
\includegraphics[width=2cm]{/latex/school/nbhlogo.eps}
\end{minipage} \qquad
\begin{minipage}[m]{\widthof{\LARGE \textbf{\MakeUppercase{Normanhurst Boys High School}}}}
\textbf{\Large \MakeUppercase{Normanhurst Boys' High School}}

\emph{An academically selective high school}
\end{minipage}
\end{center} %
}


\renewcommand{\Re}{\operatorname{Re}}
\renewcommand{\Im}{\operatorname{Im}}




\newcommand{\cosec}{\operatorname{cosec}} 
