# Automatically position detailed information about an equation into appendix

How can I automatically position the details about a certain equation into an appendix?

I've attempted this answer with some success. However, I would like the numbers to work as clickable cross-references like when I use \ref{something} inside text with the hyperref package.

For instance:

        2x(3+3)=12             (1.1)
details: see page (clickable)123


and in the appendix:

    details of equation (clickable)1.1:
2x(3+3)
=2x3+2x3
=6+6
=12

-

This is quite similar to a writing questions and answers in separate places; I'm a huge fan of the answers package, which is what I've used in the solution below.

Stepping the counter is a little clumsy (perhaps someone will have suggestions for improvements), but I think it does what you want.

\documentclass{article}

\usepackage{lipsum}     % for sample text
\usepackage{amsmath}    % for mathematical environments
\usepackage{etoolbox}   % for \AtBeginEnvironment (and a lot more)

% very useful during de-bugging!
%\usepackage[left]{showlabels}
%\showlabels{hypertarget}

% appendix file
\Opensolutionfile{appendixmaterial}
\Newassociation{appmat}{appMAT}{appendixmaterial}

% setup hypertargets for equations
\AtBeginEnvironment{equation}{%
\stepcounter{equation}%
\hypertarget{q:myref\theequation}{}%
\Writetofile{appendixmaterial}{\protect\hypertarget{a:myref\theequation}{}}%
\Writetofile{appendixmaterial}{\protect\label{a:myref\theequation}{}}%
}

% command to link to the appendix
details of equation \hyperlink{a:myref\theequation}{\theequation} (see page \pageref{a:myref\theequation})}

\begin{document}

\lipsum[1]
2\cdot (3+3)=12 \begin{appmat} \begin{align*} 2\cdot (3+3) & =2\cdot 3+2\cdot 3 \\ &=6+6 \\ & =12 \\ \end{align*} \end{appmat}
2\cdot (5+5)=12 \begin{appmat} \begin{align*} 2\cdot (5+5) & =2\cdot 5+2\cdot 5 \\ &=10+10 \\ & =20 \\ \end{align*} \end{appmat}

% close solution file
\Closesolutionfile{appendixmaterial}

% renew the solution environment so that it hyperlinks back to
% the question
\renewenvironment{appMAT}[1]{%
\vskip .5cm plus 2cm minus 0.1cm%
}%
{%
}%

\clearpage
\section{Appendix}
% input the file if it exists
\IfFileExists{appendixmaterial.tex}{\input{appendixmaterial.tex}}{}
\end{document}


For another example of this kind of thing, have a look at Adding another answer hyperlinked to the question itself and the link within.

-
Thank you, it helped a a lot! Just one minor thing: is there a way to get the destination page of the hyperlink? In a document to be printed it should be: "Details: see page x(link)" –  Pedro May 24 '12 at 5:05
@Pedro yes, for sure! I've updated the code –  cmhughes May 24 '12 at 15:42

Inspired on the above answer. I tweaked somethings like the stepping counter and added a conditional so in the appendix solutions are separated by chappter. It is not perfect but works as intended. Thank you @cmhughes.

    \documentclass{book}
\usepackage{lipsum}     % for sample text
\usepackage{amsmath}    % for mathematical environments
\usepackage{etoolbox}   % for \AtBeginEnvironment (and a lot more)
\usepackage{ifthen} %for comparison

% appendix file
\Opensolutionfile{equation_details}
\Writetofile{equation_details}{\protect\chapter{Equation details}}
\Newassociation{eqdet}{eqDET}{equation_details}

\newcommand{\details}{
\raggedright{
\scriptsize{
\textbf{Details:} see \autopageref{details_:\theequation}\\
\vskip .3cm
}
}
}

%raised target
\makeatletter
\makeatother

\newcounter{tempchap}
\setcounter{tempchap}{0}

% setup hypertargets for equations
\AtBeginEnvironment{eqdet}{%
\nop{equation_:\theequation}{}%
\ifthenelse{\equal{\value{tempchap}}{\value{chapter}}}
{}
{\Writetofile{equation_details}{\protect\section*{\thechapter}}
\setcounter{tempchap}{\value{chapter}}
}
}

% renew the solution environment so that it hyperlinks back to
% the question
\renewenvironment{eqDET}[1]{%
\label{details_:#1}
}
{%
}%

\begin{document}

\chapter{First Chapter}

\lipsum[1]
2\cdot (3+3)=12 \begin{eqdet} \begin{align*} 2\cdot (3+3) & =2\cdot 3+2\cdot 3\\ &=6+6\\ & =12\\ \end{align*} \end{eqdet}
\details

\lipsum[1]
3\cdot (4+4)=24 \begin{eqdet} \begin{align*} 3\cdot (4+4) & =3\cdot 4+3\cdot4\\ &=12+12\\ & =24\\ \end{align*} \end{eqdet}
\details

\chapter{Second Chapter}

\lipsum[1]
2\cdot (3+3)=12 \begin{eqdet} \begin{align*} 2\cdot (3+3) & =2\cdot 3+2\cdot 3\\ &=6+6\\ & =12\\ \end{align*} \end{eqdet}
\details

\lipsum[1]
3\cdot (4+4)=24 \begin{eqdet} \begin{align*} 3\cdot (4+4) & =3\cdot 4+3\cdot4\\ &=12+12\\ & =24\\ \end{align*} \end{eqdet}
\details

\Closesolutionfile{equation_details}

\appendix

% input the file if it exists
\IfFileExists{equation_details.tex}{\input{equation_details.tex}}{}
\end{document}

-
You're welcome :) if my answer did the job, please click on the green check mark so that this question is marked as, 'answered' –  cmhughes May 25 '12 at 2:41