2

I'm using the packages: hyperref and answers. I wanted to link the number of theorem with its proof, or numbers of exercises with their solutions, or numbers of problems with hints, etc. This is what I've got till now from snippets here and there (It almost do what I want except the number of problem is printed twice ):

    \documentclass{article}

\usepackage[english]{babel} 
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{answers}
\usepackage{color}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=blue,
    urlcolor=black
}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{blindtext}

\newtheorem{Thm}{Theorem}[section]

%Exercises and solutions
\newtheorem{Ex}[Thm]{\hyperlink{\theEx}{Exercise \theEx}}
\Newassociation{Sol}{Solution}{Answ}

\makeatletter % To adjust the final position of target
 \newcommand{\adj}[1]{\Hy@raisedlink{\hypertarget{#1}{}}}
\makeatother

\renewenvironment{Solution}[1]
  {\par\bigskip\noindent{\bfseries \adj{#1}{Answer #1}}  \par\bigskip}




\begin{document}
\section{This is a section}
\blindtext
\begin{Thm}
This is a theorem
\end{Thm}

\subsection{Exercises}

\Opensolutionfile{Answ}

\begin{Ex}
This is  the first exercise
\begin{Sol}
This is the solution to the first exercise
\end{Sol}
\end{Ex}


\begin{Ex}
This is  the second exercise
\begin{Sol}
This is the solution to the second exercise
\end{Sol}
\end{Ex}


\Closesolutionfile{Answ}

\Blindtext

\input{Answ}


\end{document}
2

1 Answer 1

2

One can redefine the plain style or define a new style with

\newtheoremstyle{plain}%
{}{}%
{\itshape}{}%
{\bfseries}{.}%
{ }%
{\hyperlink{\theEx}{\thmname{#1}\thmnumber{ #2}}\thmnote{ (#3)}}

Complete code

\documentclass{article}

\usepackage[english]{babel} 
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{answers}
\usepackage{color}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=blue,
    urlcolor=black
}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{blindtext}


\newtheoremstyle{plain}%
{}{}%
{\itshape}{}%
{\bfseries}{.}%
{ }%
{\hyperlink{\theEx}{\thmname{#1}\thmnumber{ #2}}\thmnote{ (#3)}}

\newtheorem{Thm}{Theorem}[section]

\newtheorem{Ex}[Thm]{Exercise}
\Newassociation{Sol}{Solution}{Answ}

\makeatletter % To adjust the final position of target
 \newcommand{\adj}[1]{\Hy@raisedlink{\hypertarget{#1}{}}}
\makeatother

\renewenvironment{Solution}[1]
  {\par\bigskip\noindent{\bfseries \adj{#1}{Answer #1}}  \par\bigskip}




\begin{document}
\section{This is a section}
\blindtext
\begin{Thm}
This is a theorem
\end{Thm}

\subsection{Exercises}

\Opensolutionfile{Answ}

\begin{Ex}
This is  the first exercise
\begin{Sol}
This is the solution to the first exercise
\end{Sol}
\end{Ex}


\begin{Ex}
This is  the second exercise
\begin{Sol}
This is the solution to the second exercise
\end{Sol}
\end{Ex}


\Closesolutionfile{Answ}

\Blindtext

\input{Answ}


\end{document}
1
  • It seems perfect to me. I don't have enough reputation though to upvote the answer but I'll do it later. You just saved my night, thank you.
    – sunny
    Aug 8, 2016 at 8:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .