Anonymous 2257
I use \usepackage[nosolutionfiles]{answers} in this code.

\documentclass[12pt,a4paper]{book}
\usepackage{amsthm,amsfonts,amssymb,amsmath}
\newif\ifsolutions
\solutionstrue

\newtheoremstyle{foo}%
{}{}%
{}{}%
{\bfseries}{:}%
{ }%
{\thmname{#1}\thmnumber{ \textcolor{blue}{#2.}}\thmnote{ (#3)}}

\theoremstyle{foo}

\newtheorem{ex}{%
\hypertarget{sol:\theex}{}}[chapter]
\Newassociation{sol}{Soln}{ans}
\renewenvironment{Soln}[1]{\par\bigskip\noindent{\bfseries \hypertarget{ex:#1}{}%

\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}



After Exercise 1.1 is 1.1. How to change 1.1 into Solution like this

and

I do not want to show solutions like this
![image.png](/image?hash=0e4621a966d265a26ed00cd697c657cdc6a16a77ac77158f07d1a9f9291717e4)
samcarter
The appearance of the solution is defined in the Soln environment in your code. To add the word "Solution", you can modify it like this:


\renewenvironment{Soln}[1]{%
\par\bigskip\noindent%
{%
\bfseries%
\hypertarget{ex:#1}{}%
}%
}


To control the position of the solution (below the exercise or at the end of the document), you can toggle on/off the nosolutionfiles package option and show the solutions at the end depending on this option:


\documentclass[12pt,a4paper]{book}
\usepackage{amsthm,amsfonts,amssymb,amsmath}
\usepackage[
%  nosolutionfiles % comment or uncomment thus line

\newtheoremstyle{foo}%
{}{}%
{}{}%
{\bfseries}{:}%
{ }%
{\thmname{#1}\thmnumber{ \textcolor{blue}{#2.}}\thmnote{ (#3)}}

\theoremstyle{foo}

\newtheorem{ex}{%
\hypertarget{sol:\theex}{}}[chapter]
\Newassociation{sol}{Soln}{ans}
\renewenvironment{Soln}[1]{\par\bigskip\noindent{\bfseries \hypertarget{ex:#1}{}%
#1
\else
Solution

\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}

![Screenshot 2022-01-10 at 10.25.17.png](/image?hash=2b5511d28be4436045899caf0fe2ad19ad4e33dc528eae2d68422fc9dfc1b7e8)