EDIT
within \documentclass[12pt]{book}
I want to create chapter-wise exercises and put all the solutions (with or without hints) at the end of the book.
I want to do this in simple and non-tedious way like: For the input of the questions, I just want to add \question
for each question and similar for answer, but all the answer should come at the end of the book.
I need the Exercises No as 1.1, 1.2, …, 2.1, 2.2, ….
Problem Nos as 1, 2, 3, …
The answer should include page No of the exercise as given in the attached jpg file.
Exercise style:
Solution type:
A MWE is as follows (I also don't know how to write solution in chapter 2 as problems are written within \begin{minipage} \end{minipage}
. Suppose all solutions are: This is a solution Ex No.)
\documentclass[12pt,openany,twoside]{book}
\usepackage{fouriernc}
\usepackage[thmmarks,standard,thref]{ntheorem}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{answers}
\theoremseparator{.}
\theorembodyfont{\upshape}
\newtheorem{pro}{Problem}[chapter]
\Newassociation{loigiai}{Answer}{loigiaichung}
\begin{document}
\chapter{Firist }
\thispagestyle{empty}
\Opensolutionfile{loigiaichung}[pro]
In problem 1-3, determine whether the given differential equation is separable
\begin{pro}
$\frac{dy}{dx}-\sin{(x+y)}=0$
\begin{loigiai}
This is a solution of Ex 1
\end{loigiai}
\end{pro}
\begin{pro}
$\frac{dy}{dx}=4y^2-3y+1$
\begin{loigiai}
This is a solution of Ex 2
\end{loigiai}
\end{pro}
\begin{pro}
$\frac{ds}{dt}=t\ln{(s^{2t})}+8t^2$
\begin{loigiai}
This is a solution Ex 3
\end{loigiai}
\end{pro}
In problem 4-6, solve the equation
\begin{pro}
$\frac{dx}{dt}=3xt^2$
\begin{loigiai}
This is a solution Ex 4
\end{loigiai}
\end{pro}
\begin{pro}
$y^{-1}dy+ye^{\cos{x}}\sin{x}dx=0$
\begin{loigiai}
This is a solution Ex 5
\end{loigiai}
\end{pro}
\begin{pro}
$(x+xy^2)dx+ye^{\cos{x}}\sin{x}dx=0$
\begin{loigiai}
This is a solution Ex 5
\end{loigiai}
\end{pro}
\begin{pro}
$\frac{dy}{dt} = \frac{y}{t+1} + 4t^2 + 4t$, $\quad$ $y(1) = 10$
\begin{loigiai}
This is a solution Ex 6
\end{loigiai}
\end{pro}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Second }
\thispagestyle{empty}
\begin{pro}
Eight systems of differential equations and five direction fields are given below. Determine the system that corresponds to each direction field and sketch the solution curves that correspond to the initial conditions $(x_0, y_0) = (0,1)$ and $(x_0, y_0) = (1,-1)$.
\begin{minipage}{.25\textwidth}
$(i)$\begin{align*}
\frac{dx}{dt} & = -x \\
\frac{dy}{dt} & = y-1\end{align*}
\end{minipage}
\begin{minipage}{.25\textwidth}
$(ii)$\begin{align*}
\frac{dx}{dt} & = x^2 - 1 \\
\frac{dy}{dt} & = y\end{align*}
\end{minipage}
\begin{minipage}{.25\textwidth}
$(iii)$\begin{align*}
\frac{dx}{dt} & = x+2y \\
\frac{dy}{dt} & = -y\end{align*}
\end{minipage}
\begin{minipage}{.25\textwidth}
$(iv)$\begin{align*}
\frac{dx}{dt} & = 2x \\
\frac{dy}{dt} & = y\end{align*}
\end{minipage}
\begin{minipage}{.25\textwidth}
$(v)$\begin{align*}
\frac{dx}{dt} & = x \\
\frac{dy}{dt} & = 2y\end{align*}
\end{minipage}
\begin{minipage}{.25\textwidth}
$(vi)$\begin{align*}
\frac{dx}{dt} & = x-1 \\
\frac{dy}{dt} & = -y\end{align*}
\end{minipage}
\begin{minipage}{.25\textwidth}
$(vii)$\begin{align*}
\frac{dx}{dt} & = x^2-1 \\
\frac{dy}{dt} & = -y\end{align*}
\end{minipage}
\begin{minipage}{.25\textwidth}
$(viii)$\begin{align*}
\frac{dx}{dt} & = x- 2y \\
\frac{dy}{dt} & = -y\end{align*}
\end{minipage}
\end{pro}
\chapter{Answer to all problems}
\thispagestyle{empty}
\Closesolutionfile{loigiaichung}
\section{This is solution}
\input{pro}
\end{document}
Best Answer
Here is a solution with
exercise
package.Its option
answerdelayed
allows you to print the answer where you want with\shipoutAnswer
.lastexercise
means that if you don't put anything as answer reference, theAnswer
environment is referred to the previous exercise. However, I have also put\begin{Answer}[ref={...}]
, in this way you can move the code for the answers where you want, but you have to keep the order. For how I have created the code for the first answer of the chapter (to printCHAPTER ...
in the final list), you also have to write it within the relative chapter.Moreover, To have
CHAPTER ...
printed in the final answer list, you have to set\setboolean{firstanswerofthechapter}{true}
at the beginning and\setboolean{firstanswerofthechapter}{false}
at the end of the first answer of a chapter (maybe there's a smarter way to do it but it's above my level of knowledge).Eventually, if you need horizontal lists you have to use
tasks
environment, otherwise, the ordinary\Question
is enough I put an example of both in my MWE.Edit: I've changed the numbering as required by the OP in their comment.
If you want the roman numbers to begin from i. in the second question, just remove the
[resume=true]
option.Second edit: To have the list of the second exercise correctly aligned, you have to use
aligned
instead ofalign*
. Since these are systems, maybe it's better to put a curly bracket before, like here in Ex. 2.2:Third edit: In the original post I wrote
counter-format={tsk[r].}
as an option of thetasks
package. But, since October 2019, that option is deprecated. Hence, the current version haslabel=\roman*.
.Thanks to EthanAlvaree for pointing it out.