I have previously tried to make a document with questions and answers.
In a previous question I was shown a great way to do this, using the answer package in combination with hyperref.
Adding another answer hyperlinked to the question itself
The problem is that the document has grown quite large, counting over 100 pages.
I need to reset the counters for the answers and questions at the subsubsection
instead of at the 'subsection'. I tried changing the counters in the answer provided, but alas either the document failed to compile, or nothing changed at all.
Here is a minimal working example with the counters reset at the subsection level http://spot.pcc.edu/~chughes/buzzard/
I know this must seem like a trivial question, but for a novice like me the code was quite hard to interpret.
A even more minimal example, the backhypperrefs fail here. Also I am not able to reproduce the error where it fails to distinguish between the subsubsections
\documentclass{article}
\usepackage{answers}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{multicol}
\hypersetup{colorlinks=true}
\setlength{\parindent}{0.0mm}
% very useful during de-bugging!
%\usepackage[left]{showlabels}
%\showlabels{hypertarget}
%\showlabels{hyperlink}
% solutions files
% short solutions
\Opensolutionfile{shortsolutions}
\Newassociation{shortsolution}{shortSoln}{shortsolutions}
% long solutions
\Opensolutionfile{longsolutions}
\Newassociation{longsolution}{longSoln}{longsolutions}
% new environment that sets up hypertargets both in the question
% section, and in the answer section
\newlist{myenum}{enumerate}{3}
\newcounter{question}[subsubsection]
\newenvironment{question}[1]%
{%
\refstepcounter{question}%
% hyperlink to solution
\hypertarget{question:{\thequestion}}{}%
\Writetofile{shortsolutions}{\protect\hypertarget{shortsoln:\thequestion}{}}%
\Writetofile{longsolutions}{\protect\hypertarget{longsoln:\thequestion}{}}%
\begin{myenum}[label=\bfseries\protect\hyperlink{shortsoln:\thequestion}{\thequestion},ref=\thequestion]
\item%
\hypersetup{linkcolor=blue}%
\hyperlink{longsoln:\thequestion}{#1}%
}%
{%
\end{myenum}}
\begin{document}
\section{Questions}
\subsubsection{Set I}
\begin{multicols}{3}
\begin{question}{$\int\sqrt{4-x}\mathrm{d}x$}
\begin{shortsolution}
$-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
\end{shortsolution}
\begin{longsolution}
In order to do this, we must first make a substitution\ldots
\end{longsolution}
\end{question}
\begin{question}{$\int(2x-1)^{50}\mathrm{d}x$}
\begin{shortsolution}
$\frac{1}{102}(2x-1)^{51}+C$
\end{shortsolution}
\begin{longsolution}
A very long solution| much longer than the shorter solution
\end{longsolution}
\end{question}
\begin{question}{$\int\sqrt[n]{x}\mathrm{d}x$}
\begin{shortsolution}
$\frac{n}{n+1}x^{\frac{1+n}{n}}+C$
\end{shortsolution}
\begin{longsolution}
Even longer!
\end{longsolution}
\end{question}
\end{multicols}
\subsubsection{Set II}
\begin{multicols}{3}
\begin{question}{$\int\sqrt{x}\mathrm{d}x$}
\begin{shortsolution}
$\frac{n}{n+1}x^{\frac{1+n}{n}}+C$
\end{shortsolution}
\begin{longsolution}
Even longer!
\end{longsolution}
\end{question}
\begin{question}{$\int\sqrt{4-x}\mathrm{d}x$}
\begin{shortsolution}
$-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
\end{shortsolution}
\begin{longsolution}
In order to do this, we must first make a substitution\ldots
\end{longsolution}
\end{question}
\begin{question}{$\int(2x)^{50}\mathrm{d}x$}
\begin{shortsolution}
$\frac{1}{102}(2x-1)^{51}+C$
\end{shortsolution}
\begin{longsolution}
A very long solution| much longer than the shorter solution
\end{longsolution}
\end{question}
\end{multicols}
\clearpage
\section{Questions}
\subsubsection{Set I}
\begin{multicols}{3}
\begin{question}{$\int\sqrt{4-x}\mathrm{d}x$}
\begin{shortsolution}
$-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
\end{shortsolution}
\begin{longsolution}
In order to do this, we must first make a substitution\ldots
\end{longsolution}
\end{question}
\begin{question}{$\int(2x-1)^{50}\mathrm{d}x$}
\begin{shortsolution}
$\frac{1}{102}(2x-1)^{51}+C$
\end{shortsolution}
\begin{longsolution}
A very long solution| much longer than the shorter solution
\end{longsolution}
\end{question}
\begin{question}{$\int\sqrt[n]{x}\mathrm{d}x$}
\begin{shortsolution}
$\frac{n}{n+1}x^{\frac{1+n}{n}}+C$
\end{shortsolution}
\begin{longsolution}
Even longer!
\end{longsolution}
\end{question}
\end{multicols}
\subsubsection{Set II}
\begin{multicols}{3}
\begin{question}{$\int\sqrt{x}\mathrm{d}x$}
\begin{shortsolution}
$\frac{n}{n+1}x^{\frac{1+n}{n}}+C$
\end{shortsolution}
\begin{longsolution}
Even longer!
\end{longsolution}
\end{question}
\begin{question}{$\int\sqrt{4-x}\mathrm{d}x$}
\begin{shortsolution}
$-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
\end{shortsolution}
\begin{longsolution}
In order to do this, we must first make a substitution\ldots
\end{longsolution}
\end{question}
\begin{question}{$\int(2x)^{50}\mathrm{d}x$}
\begin{shortsolution}
$\frac{1}{102}(2x-1)^{51}+C$
\end{shortsolution}
\begin{longsolution}
A very long solution| much longer than the shorter solution
\end{longsolution}
\end{question}
\end{multicols}
% close solution files
\Closesolutionfile{shortsolutions}
\Closesolutionfile{longsolutions}
\clearpage
\section{SHORT answers}
% renew the SHORT solution environment so that it hyperlinks back to
% the question
\renewenvironment{shortSoln}[1]{%
% add some glue
\vskip .5cm plus 2cm minus 0.1cm%
{\bfseries \hyperlink{question:#1}{#1.}}%
}%
{%
}%
% input the file if it exists
\IfFileExists{shortsolutions.tex}{\input{shortsolutions.tex}}{}
\clearpage
\section{LONG answers}
% renew the LONG solution environment so that it hyperlinks back to
% the question
\renewenvironment{longSoln}[1]{%
% add some glue
\vskip .5cm plus 2cm minus 0.1cm%
{\bfseries \hypersetup{linkcolor=blue}\hyperlink{question:#1}{#1.}}%
}%
{%
}%
% input the file if it exists
\IfFileExists{longsolutions.tex}{\input{longsolutions.tex}}{}
\end{document}
\newcounter{question}[subsection]– Sigur Dec 12 '13 at 23:26\newcounter{question}[subsubsection]? – Werner Dec 12 '13 at 23:35For your amusement I did try to narrow it down a notch =)
– N3buchadnezzar Dec 15 '13 at 00:07