%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
%\customlistofexercise or \listofexercise below.
%below as it may break the LaTeXing.
%\includeonly{equations_and_functions}
%\includeonly{limits}
%\includeonly{differentiation}
%\includeonly{derivative_applications}
%\includeonly{integration}
%
% Package used for making the index
\usepackage{makeidx}
\makeindex
% 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{layout}
%
% 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. linktocpage makes the
% links be the pages rather than names in toc.
\usepackage[hyperfootnotes=false,linktocpage=true]{hyperref}
% \usepackage[pdfpagelabels,draft]{hyperref}
%
% The following removes the boxes around links.  Newer versions of hyperref
% allow the hidelinks option.  Note the xcolor package is required here.
\usepackage{xcolor}
\hypersetup{
  colorlinks=true,
%    bordercolor={red!50!black},
%    anchorcolor={red!50!black},
%    linkcolor={red!50!black},
   linkcolor={blue},
%    citecolor={red!50!black},
%    urlcolor={red!80!black},
%    filecolor={blue!50!black},
    filecolor={blue},
    pdfborder={0 0 0},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The following textbooktools 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{textbooktools}
% 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{calculussymbols}
% 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{Equations and Functions}
\label{chap:equationsandfunctions}
\include{equations_and_functions}
\chapter{Limits}
\label{chap:limits}
\include{limits}
\chapter{Differentiation}
\label{chap:differentiation}
\include{differentiation}
\chapter{Derivative Applications}
\label{chap:derivativeapplications}
\include{derivative_applications}
\chapter{Integration}
\label{chap:integration}
\include{integration}
\appendix
\cleardoublepage
% For some reason my appendix is being called a chapter so I change
% the chapter name.
\renewcommand{\chaptername}{Appendix}
\chapter{Advanced Factoring}
\label{ap:advancedfactoring}
\include{advanced_factoring}
\chapter{Inequalities}
\label{ap:inequalities}
\include{inequalities}
\chapter{Trigonometric Equations}
\label{ap:solvingtrigequations}
\include{solving_trig_equations}
\chapter{Geometry Formulas}
\label{ap:geometryformulas}
\include{geometry_formulas}
\cleardoublepage
\phantomsection % Needed for hyperref links to Answer page to work
\addcontentsline{toc}{chapter}{Answers}
\listofexercise
%\customlistofexercise
\cleardoublepage\markboth{Summary}{Summary}
\phantomsection
\addcontentsline{toc}{chapter}{Summary}
\input{summary}

% Location of the index
\cleardoublepage\markboth{Index}{Index}
\phantomsection
\addcontentsline{toc}{chapter}{Index}
\printindex
\backmatter
% Print the license
\gfdldoublenewpage[chapter]
\end{document}
