I asked this question here Best way to part answers from solutions? And obtained a very good answer. Though I now have a new problem.
I want to type the question, then have one answer linked to the number. And one answer linked to the question itself. (See my MWE in the inked thread for an example. Clicking on the number next to the problem should send you one place, clicking on the equation itself, should send you elsewhere)
Here is an MWE, for my progress so far
\documentclass{article}
\usepackage{answers}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{multicol}
\usepackage{changepage}
\usepackage{mathtools}
\newcommand{\dx}{\mathop{}\! \text{d} x}
\setlength{\parindent}{0.0mm}
\hypersetup{colorlinks=true,
linkcolor=blue}
% very useful during de-bugging!
%\usepackage[left]{showlabels}
%\showlabels{hypertarget}
%\showlabels{hyperlink}
% solutions file
\Opensolutionfile{mysolutions}
\Newassociation{mysolution}{mySoln}{mysolutions}
% new environment that sets up hypertargets both in the question
% section, and in the answer section
\newlist{myenum}{enumerate}{3}
\newcounter{question}[section]
\newenvironment{question}%
{%
\refstepcounter{question}%
% hyperlink to solution
\hypertarget{question:{\thequestion}}{}%
\Writetofile{mysolutions}{\protect\hypertarget{soln:\thequestion}{}}%
\begin{myenum}[label=\bfseries\protect\hyperlink{soln:\thequestion}{\thequestion}),ref=\thequestion,itemsep=5pt]
\item%
}%
{%
\end{myenum}}
\newenvironment{IntList}[1]{%
\Opensolutionfile{mysolutions}
\centering
\setlength{\columnsep}{50pt}
\begin{adjustwidth}{-3em}{-2em}\begin{multicols}{#1}}{\end{multicols}\end{adjustwidth}\Closesolutionfile{mysolutions}}
\begin{document}
\begin{IntList}{3}
\begin{question}
$\displaystyle \int\sqrt{4-x}\dx$
\begin{mysolution}
$2+3+4$
\end{mysolution}
\end{question}
\end{IntList}
\section{helo}
\begin{IntList}{3}
\begin{question}
$\displaystyle \int\sqrt{4-x}\dx$
\begin{mysolution}
$ \int x^3 + 2$
\end{mysolution}
\end{question}
\begin{question}
$\displaystyle \int \sqrt{\frac{1}{x^2+1}}\dx$
\begin{mysolution}
$-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
\end{mysolution}
\end{question}
\end{IntList}
% close solution file
\Closesolutionfile{mysolutions}
% renew the solution environment so that it hyperlinks back to
% the question
\renewenvironment{mySoln}[1]{%
% add some glue
\vskip .5cm plus 2cm minus 0.1cm%
{\bfseries \hyperlink{question:#1}{#1.}}%
}%
{%
}%
\clearpage
\section{Answers!}
% input the file if it exists
\IfFileExists{mysolutions.tex}{\input{mysolutions.tex}}{}
\end{document}
So I want to add another answer below each question, for an example like below
\begin{IntList}{3}
\begin{question}
$\displaystyle \int\sqrt{4-x}\dx$
\begin{mysolution}
$2+3+4$
\end{mysolution}
\begin{myanswer}
To solve this problem one must first...
\end{mysanswer}
\end{question}
\end{IntList}
Where my answer is linked to the whole question and the solution is linked to the number. Prefferably the linked equation should work the same way as the answer does. Eg the hyperref works both ways. Any ideas?
Edit: Here is a more minimal example
\documentclass[10pt,a4paper]{article}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{mathtools}
\newenvironment{IntList}[1]{%
\centering
\setlength{\columnsep}{50pt}
\begin{multicols}{#1}\begin{enumerate}[itemsep=5pt]}{\end{enumerate}\end{multicols}}
\usepackage[hidelinks]{hyperref}
\newcommand{\IntExerc}[2]{\item \hyperref[#1]{\mbox{ \( \displaystyle #2 \) }}}
\begin{document}
\begin{IntList}{3}
\IntExerc{R1.1}{\int \frac{x^2+3x}{x^2} \,\mathrm{d}x}
\IntExerc{R1.22}{\int\sin(x)\,\mathrm{d}x}
\IntExerc{R1.2}{\int_0^1 \frac{x}{x^2+1} \,\mathrm{d}x}
\end{IntList}
\newpage
\newpage
\begin{align}
\int \frac{x^2+3x}{x^2} \, \mathrm{d}x & = \int \frac{x^2}{x^2} + \frac{3x}{x^2} \, \mathrm{d}x = \int 1 \mathrm{d}x + 3\int \frac{\mathrm{d}x}{x} = x + 3 \ln|x| + \mathcal{C} \label{R1.1} \\
\int\sin(x)\,\mathrm{d}x & = -\cos(x) + C \label{R1.22} \\
\int\sin(x)\,\mathrm{d}x & = -\cos(x) + C \label{R1.2}
\end{align}
\end{document}
This is closer to the output I want from the answers, package. Note that I have to type the answers seperately, add labels. And have no hyperlinks attached to the numbers.
( I would also prefer to have the syntax below, but I guess this is not possible. )
\begin{Questions}[PartI]
\question
\solution
\answer
\question
\solution
\answer
\end{Questions}
\display{solution}{PartI}
\display{answer}{PartI}
Now, any comments and help would be great.
EDIT:
I made some progress! Is there any way to make the \long and \short "answers" to be incuded at the beginning? It seems cumbersome to type them over and over again.
\documentclass{article}
\usepackage{answers}
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{multicol}
\usepackage{changepage}
\usepackage{etoolbox}
\newcommand\getcurrentref[1]{%
\ifnumequal{\value{#1}}{0}
{??}
{\the\value{#1}}%
}
\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}
\Newassociation{short}{shortSolns}{shortsolutions}
% long solutions
\Opensolutionfile{longsolutions}
\Newassociation{longsolution}{longSoln}{longsolutions}
\Newassociation{longs}{longsSolns}{longsolutions}
% new environment that sets up hypertargets both in the question
% section, and in the answer section
\newlist{myenum}{enumerate}{3}
\newcounter{question}[subsection]
\newenvironment{question}[1]%
{%
\refstepcounter{question}%
% hyperlink to solution
\hypertarget{question:{\thesubsection\thequestion}}{}%
\Writetofile{shortsolutions}{\protect\hypertarget{shortsoln:\thesubsection\thequestion}{}}%
\Writetofile{longsolutions}{\protect\hypertarget{longsoln:\thesubsection\thequestion}{}}%
\begin{myenum}[label=\bfseries\protect\hyperlink{shortsoln:\thesubsection\thequestion}{\thequestion.},ref=\thequestion]
\item%
\hypersetup{linkcolor=black}%
\hyperlink{longsoln:\thesubsection\thequestion}{#1}%
}%
{%
\end{myenum}}
\newenvironment{IntList}[1]{%
\Opensolutionfile{mysolutions}
\centering
\setlength{\columnsep}{50pt}
\begin{adjustwidth}{-3em}{-2em}\begin{multicols}{#1}}{\end{multicols}\end{adjustwidth}\Closesolutionfile{mysolutions}}
\begin{document}
\section{Problems}
\subsection{Questions}
\begin{multicols}{3}
\begin{short}
\vspace*{\baselineskip}
\color{white} hello
\vspace*{-\baselineskip}
\end{short}
\begin{longs}
\vspace*{\baselineskip}
\color{white} hello
\vspace*{-\baselineskip}
\end{longs}
\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!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
Even longer!
\end{longsolution}
\end{question}
\end{multicols}
\subsection{Some more questions}
\begin{multicols}{3}
\begin{short}
\vspace*{\baselineskip}
\color{white} hello
\vspace*{-\baselineskip}
\end{short}
\begin{longs}
\vspace*{\baselineskip}
\color{white} hello
\vspace*{-\baselineskip}
\end{longs}
\begin{question}{$\int\sqrt{4-x}\mathrm{d}x$}
\begin{shortsolution}
$-\frac{2}{3}(4-x)^{\frac{3}{2}}+C$
\end{shortsolution}
\begin{longsolution}
hi
\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}
ho
\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}
lets go
\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}

