Code: Select all
\documentclass[11pt,twocolumn,twoside]{book}
%---------- PACKAGES ------------------
\usepackage{answers}
%\usepackage{amsthm} %enhanced theorems
%\usepackage{graphicx,epstopdf} %insert graphics and convert eps to pdf
%\usepackage[format=plain,font=small,labelfont=bf,up]{caption} %,textfont=it,up
\usepackage[version=3]{mhchem} %chemical formula
%\usepackage{float} %improved placement of floats
%\usepackage{placeins} %makes it possible to prevent floats from floating past the end of a section
\usepackage{pdfpages} %facilitates the insertion of pdf-pages into document (is not needed when the whole text is in LaTeX)
%\usepackage{makeidx} %index processor
%\usepackage{enumerate} % to make it easy to use for example levels of A, B, C for enumerate
% %\usepackage{dblfloatfix} %makes it possible to use [b] with double column floats
%\usepackage{fixltx2e} %amalgamates figure and table lists for single and double columns
%\usepackage{caption} %to customize captions
\usepackage{siunitx} %proper formatting of numbers and SI-units
%\usepackage{xspace} %used only for fixing spaces in \oC
%\usepackage{textgreek} %to write non-italic Greek letters (in Greek box in Thermodynamics chapter)
%---------- ANSWERS PACKAGE ------------------
%I here create four types of files (the exercises are written where they are given): answers, hints, solutions for the book, and %solutions for the teacher. The solutions for the teacher (those solutions that are not given in the book) are given in solt.txt to be %printed separately.
\newtheorem{Ex}{Exercise}
\Newassociation{ans}{Answer}{ans}
\Newassociation{hint}{Hint}{hint}
\Newassociation{sol}{Solution}{sol}
\Newassociation{solt}{SolutionTeacher}{solt}
\renewcommand{\Answerlabel}[1]{\bf{Answer #1.}}
\renewcommand{\Hintlabel}[1]{\bf{Hint #1.} }
\renewcommand{\Solutionlabel}[1]{\bf{Solution #1.} }
\renewcommand{\SolutionTeacherlabel}[1]{\bf{Solution #1.} }
\begin{document}
%---------- START UP USE OF ANSWERS PACKAGE ------------------
\Opensolutionfile{ans}[ans1] % file for answers
\Opensolutionfile{hint}[hint1] % file for hints
\Opensolutionfile{sol}[sol1] % file for solutions for book
\Opensolutionfile{solt}[sol1t] % file for solutions for teacher
\Writetofile{ans}{Here are answers to the exercises.}
\Writetofile{hint}{Here are hints for the exercises.}
\Writetofile{sol}{Here are solutions to selected exercises.}
\Writetofile{solt}{Solutions for the teacher only.}
\chapter{Heat}
Here is the chapter text about heat.
\section{Exercises}
\Writetofile{ans}{\protect\subsection*{Heat}}
\Writetofile{hint}{\protect\subsection*{Heat}}
\Writetofile{sol}{\protect\subsection*{Heat}}
\begin{Ex}
Heat question X.
\begin{ans}Answer X.\end{ans}
\begin{hint}Hint X.\end{hint}
\begin{sol}Solution X.\end{sol}
\end{Ex}
\begin{Ex}
Heat question Y.
\begin{ans}Answer Y.\end{ans}
\begin{hint}Hint Y.\end{hint}
\begin{solt}Solution Y (for teacher only).\end{solt}
\end{Ex}
\chapter{Biology}
Here is the chapter text about biology.
\section{Exercises}
\Writetofile{ans}{\protect\subsection*{Biology}}
\Writetofile{hint}{\protect\subsection*{Biology}}
\Writetofile{sol}{\protect\subsection*{Biology}}
\begin{Ex} %-------------------
Biology question Z.
\begin{ans}Answer Z.\end{ans}
\begin{hint}Hint Z.\end{hint}
\begin{sol}Solution Z.\end{sol}
\end{Ex}
%---------- ANSWERS PACKAGE ------------------
\Closesolutionfile{ans} % answers
\Closesolutionfile{hint} % hints
\Closesolutionfile{sol} % solutions
\Closesolutionfile{solt} % solutions for teacher
\chapter{Answers}
\input{ans1}\newpage
\chapter{Hints}
\input{hint1}\newpage
\chapter{Solutions}
\input{sol1}
\end{document}