I'm using the answers package for an exercises book. I would like to create clickable hyperlinks (in the generated pdf file) from the exercise to the corresponding solution and back from the solution to the exercise.

Here is my ex (exercise) environment:

\documentclass[12pt, openany]{extbook}
\usepackage[frenchb]{babel}
\usepackage{slashbox}
\usepackage{graphicx}
\usepackage{amsmath,amssymb,amstext}
\usepackage[latin1]{inputenc}
\usepackage[OT1]{fontenc}
\usepackage{fancybox}
\usepackage{a4wide}
\usepackage{rotating}
\usepackage{epic}
\usepackage{fancyvrb}
\usepackage{thmbox}
\newcounter{moncompteur}
\newtheorem[M]{exc}[moncompteur]{ \textbf{Exercise}}{}
\newenvironment{ex}{\begin{exc}\normalfont}{\end{exc}}
\Newassociation{sol}{Soln}{corr}
\renewenvironment{Soln}[1]{\par\bigskip\noindent {\bfseries Solution  of exercise #1}\quad}{}

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, then they are marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Also, You can use backticks  to mark your inline code‌​. –  Gonzalo Medina Aug 25 '11 at 19:07
Thanks, you were faster than me. I was editing! –  Brownian Aug 25 '11 at 19:10

You can use the \hyperlink, \hypertarget mechanism provided by the hyperref package. A little example:

\documentclass[12pt,a4paper]{article}
\usepackage{amsthm}
\usepackage{hyperref}

\newcounter{moncompteur}
\theoremstyle{definition}
\newtheorem{ex}{%
\Newassociation{sol}{Soln}{corr}
\renewenvironment{Soln}[1]
{\par\bigskip}

\begin{document}
\Opensolutionfile{corr}[ans1]
\section{Problems}
\begin{ex}
First exercise.
\begin{sol}
First solution.
\end{sol}
\end{ex}

\begin{ex}
Second exercise.
\begin{sol}
Second solution.
\end{sol}
\end{ex}
\Closesolutionfile{corr}
\section{Solutions}
\input{ans1}
\end{document}


Note that I modified the definition of the ex theorem-like structure using \theoremstyle{definition} from the amsthm package and removed the counter moncompteur.

-
Thanks a lot: you made my day (I went back to my definition of ex in order to use thmbox). –  Brownian Aug 25 '11 at 19:54

Add hyperref's \phantomsection to your definition of the Soln environment:

\renewenvironment{Soln}[1]{\par\bigskip\noindent\phantomsection {\bfseries Solution  of exercise #1}\quad}{}


Now, in your document, using \hyperref[<reference>]{<text>} will jump you to the appropriate hyperlink/label given for the solution. For example, try the following:

\begin{document}
\begin{ex}
Here is an exercise. Solution is \hyperref[sol:first]{here}. \label{ex:first}
\end{ex}

\begin{ex}
Here is another exercise. Solution is \hyperref[sol:second]{here}. \label{ex:second}
\end{ex}

\newpage

\begin{Soln}{\ref{ex:first}}
Here is the solution. \label{sol:first}
\end{Soln}

\begin{Soln}{\ref{ex:second}}
Here is the solution. \label{sol:second}
\end{Soln}
`
-