%Include [oneside] option after \documentclass for one-sided printing.
\documentclass{book}
%\documentclass[oneside]{book}
%Note if you use includeonly while editing you may need to uncomment
%\customlistofanswer or \listofanswer below.
%below as it will break the LaTeXing.
%
% The following package is required to prevent a "! No room for a new \dimen"
% error which has to do with a hardcoded limit of registers in TeX.  The origin
% of these may be all the \newdimen\ASYdimen commands in the asymptote files.
% In any event the following package solves the problem.  (It should be the
% first package loaded after the documentclass apparently.)
% Note: In newer versions of LaTeX this is no longer needed.
\usepackage{etex}
%
% Newer versions of the etoolbox package defines a version of the
% \ifboolexpr command which conflicts with the same command in the
% boolexpr package which gets loaded by other packages.  If etoolbox
% is loaded first, boolexpr will load without generating an error so
% we'll load it here so this won't break on newer versions of latex.
\usepackage{etoolbox}
% 
% The following imports commands created for formatting the document.
% This is custom-made and not part of a latex install.  Currently it
% contains some commands that should likely be migrated to textbooktools.
\input{layoutv2}
%
% Create pdf hyperlinks and display urls. This must be loaded before
% textbooktools for exercise hyperlinks in answer key to work
% properly.  Note that if you don't want hyperlinks it is still worth
% selecting the second option as this fixes the page number mismatch
% that appears in a pdfviewer due to the frontmatter numbering in the
% book document class.  We turn off links for footnotes as they are
% both distracting and broken for some footnotes.
%
\usepackage[hyperfootnotes=false]{hyperref}
%\usepackage[pdfpagelabels,draft]{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The following textbooktoolsv1 code is customized for this document
% by the code below it up to the other comment line.
% The following imports a custom set of tools for creating a textbook
\input{textbooktoolsv1}
% Change the textbook exercise environment so it does no highlighting
%\renewenvironment{exerciselayout}{}{}
% Change the textbook exercise title so it prints nothing
%\renewcommand{\exercisetitlelayout}[1][]{\textbf{\Large\exercisetitle}}
% The blocks of problems (each file) has a title for that group.  We define
% the command to print nothing.
\newcommand{\problemgrouptitle}[1]{}
% Choose exercises labeled by chapter
\inlineexercises[0]
%\depthfixedexercises[0]
% We modify the existing exercise and reviewexercise environments for our
% specific purposes.  
% exercise environment:
% We make the exercise environment additionally do several things:
% 1) Include the beginning and ending enumeration as all our exercises will
% be in enumerated environments.
% 2) Put an appropriate running header in the answer key.
% Note that I need to use the \LetLtxMacro command for my redefinition of the
% begin and end environments here due to my exercise environments having
% optional arguments.
\usepackage{letltxmacro}
\LetLtxMacro{\oldstartexercise}{\exercise}
\LetLtxMacro{\oldendexercise}{\endexercise}
% These won't work:
%\let\oldstartexercise\exercise
%\let\oldendexercise\endexercise
%\def\exercise{\oldstartexercise%
\renewcommand{\exercise}[1][]{\oldstartexercise[{#1}] %
% The following puts lines in the answer key to change the header to
% say what chapter exercises are on the page.
\addtocontents{ans}{\protect\markboth{\chaptername~\thechapter~Exercises}{Answers}}%
% For unknown reasons the previous line adds space within the actual exercise
% before the numbering.  I'm removing it manually
\vspace{-2em}
\begin{enumerate}%
}
% The following ends enumeration when we do \end{exercise}
\def\endexercise{\end{enumerate}\oldendexercise}
% Make the same changes as we did in the exercise environment.
% Additionally it will do the following:
% 1) Add toc entries for the review exercises
% 2) Put an appropriate running header on the page.
% 3) Start a new page.
\let\oldstartreviewexercise\reviewexercise
\let\oldendreviewexercise\endreviewexercise
\def\reviewexercise{%
\clearpage
% Change the running header over the exercise itself.
\markright{Review Exercises}
% This does the old \begin{reviewexercise}
\oldstartreviewexercise
% The following puts lines in the answer key to change the header to
% say what chapter exercises are on the page.
\addtocontents{ans}{\protect\markboth{\chaptername~\thechapter~Exercises}{Answers}}%
% Correct spacing caused by addcontents command
\vspace{-2em}
%Put the Exercise page in the table of contents.
\addcontentsline{toc}{section}{Review Exercises}%
%Start the enumeration environment.
\begin{enumerate}}
% End the enumeration environment when we end the review exercise.
\def\endreviewexercise{\end{enumerate}\oldendreviewexercise}
\newenvironment{areviewexercise}{%Begin
%\clearpage
% Change the running header over the exercise itself.
%\markright{Review Exercises}
\begin{oldreviewexercise}
% The following puts lines in the answer key to change the header to
% say what chapter exercises are on the page.
\addtocontents{ans}{\protect\markboth{\chaptername~\thechapter~Exercises}{Answers}}%
%Put the Exercise page in the table of contents.
\addcontentsline{toc}{section}{Review Exercises}%
\begin{enumerate}
}{%End
\end{enumerate}
\end{reviewexercise}}
% Choose examples indexed by chapter.
\initexamples[0]
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The problem sets are currently being used for two different
% documents The following commands wrap special formatting that only
% applies to one or the other documents.  Custom page breaks, column
% breaks or multicolumn commands that only apply to either document
% should be wrapped by these commands.  This document wraps these in a
% \textbook command.  Any formatting for the other document (a lab
% manual) are similarly be wrapped in a \lab command and will be
% ignored.  Actually I have wrapped ALL pagebreaks, etc. for the textbook
% with the \textbook command so it will be easy to find any special space
% formatting when changes are made for future editions.
\newcommand{\textbook}[1]{#1}
\newcommand{\lab}[1]{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%The following imports a custom set of calculus symbol definitions
\input{calculussymbolsv1}
% The following imports symbols and further definitions for linear
% algebra.
\input{linearalgebrasymbolsv1}
% Include details of the course being compiled.  Likely edit it.
\input{course_info.tex}
\begin{document}
\frontmatter
%Create title page
\makecoursetitle
%Include the copyright, etc. page.  Placed in a separate latex file for
%convenience.
\input{copyright}
%%%%%%%%%
%Make a table of contents.
\customtableofcontents
%Reset the pages to start the actual content and change to arabic numbering
%since \makecoursetitle set it to roman numerals.
% Note, if you want to force a column break in the toc
% put the following line after a chapter (or wherever.)
%\addtocontents{toc}{\protect\columnbreak}
%\setcounter{page}{1}
%\pagenumbering{arabic}
\mainmatter
\chapter{Linear Equations}
\label{chap:linearequations}
\include{linearequations/linearequations}
\chapter{Matrices}
\label{chap:matrices}
\include{matrices/matrices}
\chapter{Determinants}
\label{chap:determinants}
\include{determinants/determinants}
\chapter{Vectors}
\label{chap:vectors}
\include{vectors/vectors}
\chapter{Lines and Planes}
\label{chap:linesandplanes}
\include{linesandplanes/linesandplanes}
\chapter{Linear Transformations}
\label{chap:lineartransformations}
\include{lineartransformations/lineartransformations}
% We force a columnbreak in the toc to make it look better
\textbook{\addtocontents{toc}{\protect\columnbreak}}
\chapter{Subspaces of $\mathset{R}^n$}
\label{chap:subspaces}
\include{subspaces/subspaces}
\chapter{Eigenvalues and Eigenvectors}
\label{chap:eigenvaluesandeigenvectors}
\include{eigenvalueseigenvectors/eigenvalueseigenvectors}
\chapter{Complex Numbers}
\label{chap:complexnumbers}
\include{complexnumbers/complexnumbers}
\appendix
\cleardoublepage
% For some reason my appendix is being called a chapter so I change
% the chapter name.
\renewcommand{\chaptername}{Appendix}
% The answer section to exercises can be placed here.
%\cleardoublepage
%\phantomsection % Needed for hyperref links to Answer page to work
%\addcontentsline{toc}{chapter}{Answers}
%\listofexercise
% A summary section with some formulas, etc. could be placed here.
%\customlistofexercise
%\cleardoublepage\markboth{Summary}{Summary}
%\phantomsection
%\addcontentsline{toc}{chapter}{Summary}
%\input{summary}
\backmatter
% Print the license
\gfdldoublenewpage[chapter]
\end{document}
