Anonymous 2257
In this code
```
\documentclass[12pt,a4paper]{book}
\usepackage{amsthm,amsfonts,amssymb,amsmath}
\usepackage{answers}
\newif\ifsolutions
\solutionstrue
\theoremstyle{definition}
\newtheorem{ex}{%
\hyperlink{ex:\theex}{Exercise}%
\hypertarget{sol:\theex}{}}[chapter]
\Newassociation{sol}{Soln}{ans}
\renewenvironment{Soln}[1]{\par\bigskip\noindent{\bfseries \hypertarget{ex:#1}{}%
\hyperlink{sol:#1}{ #1}}\quad}
\usepackage[linkcolor=blue,colorlinks=true,unicode,bookmarksnumbered]{hyperref}
\begin{document}
\chapter{Try}
\Opensolutionfile{ans}[ans1]
\begin{ex}
First exercise
\begin{sol}
First solution.
\end{sol}
\end{ex}
\clearpage
\begin{ex}
Second exercise
\begin{sol}
Second solution.
\end{sol}
\end{ex}
\clearpage
\Closesolutionfile{ans}
\ifsolutions
\section{Solutions}
\input{ans1}
\fi
\end{document}
```
How to color number of Exercises?

Top Answer
samcarter
You could define a new theorem style:
```
\documentclass[12pt,a4paper]{book}
\usepackage{amsthm,amsfonts,amssymb,amsmath}
\usepackage{answers}
\newif\ifsolutions
\solutionstrue
\newtheoremstyle{foo}%
{}{}%
{}{}%
{\bfseries}{:}%
{ }%
{\thmname{#1}\thmnumber{ \textcolor{blue}{#2.}}\thmnote{ (#3)}}
\theoremstyle{foo}
\newtheorem{ex}{%
\hyperlink{ex:\theex}{Exercise}%
\hypertarget{sol:\theex}{}}[chapter]
\Newassociation{sol}{Soln}{ans}
\renewenvironment{Soln}[1]{\par\bigskip\noindent{\bfseries \hypertarget{ex:#1}{}%
\hyperlink{sol:#1}{ #1}}\quad}
\usepackage[linkcolor=blue,colorlinks=true,unicode,bookmarksnumbered]{hyperref}
\begin{document}
\chapter{Try}
\Opensolutionfile{ans}[ans1]
\begin{ex}[Quack]
First exercise
\begin{sol}
First solution.
\end{sol}
\end{ex}
\clearpage
\begin{ex}
Second exercise
\begin{sol}
Second solution.
\end{sol}
\end{ex}
\clearpage
\Closesolutionfile{ans}
\ifsolutions
\section{Solutions}
\input{ans1}
\fi
\end{document}
```
