1

I'm now use LaTex to write a mathematics problem solving book. It has some problems in the end of the chapter, and the last chapter is used to demonstrate the solution. But I don't know how to auto number the solutions for problems through the chapter, like Chapter 4, problem 4.1 (containing the solution)

I use gsm-l packages, a derived package of ams.

Here is the MWE

 \documentclass{gsm-l}
 \usepackage[papersize={160mm,240mm},inner=20mm, outer=15mm, vmargin=15mm]{geometry}
 \geometry{includeheadfoot}
 \usepackage{amssymb, amsmath}
 \setcounter{tocdepth}{2}
 \usepackage{pgf,tikz}
 \usetikzlibrary{arrows}
 \newtheorem{problem}{Problem}
 \numberwithin{problem}{chapter}
 \begin{document}
 \chapter{Introduction}
 \begin{problem}
 This is problem 1.1
 \end{problem}
 \chapter{Key to the exercises}
 I want to know how to auto list the problem number and the solution is behind it, 
 like : 

\noindent \textbf{Problem 1.1} 

The following is solution. 
\end{document}

Please help me. Thanks.

trequartista
  • 1,891
  • Using the simple example given in the answers package documentation, the only thing I did differently was to use the book class instead of article, and number exercises per chapter with \newtheorem{ex}{Exercise}[chapter]. – Mike Renfro Jul 06 '15 at 02:15
  • I think my question is sligtly different, I focus on gsm package only, and looking for the solution inside this package. For Mike Renfro comment, I want to auto number the solution, with the problem number, i.e Problem 4.1. Here is the solution. – trequartista Jul 06 '15 at 02:22
  • 1
    I think, the best thing to do here is for you to provide a MWE. – Gonzalo Medina Jul 06 '15 at 02:28
  • Does the answers package not work with the gsm-l class? I don't currently have a copy of the class to verify. – Mike Renfro Jul 06 '15 at 02:28
  • @GonzaloMedina A MWE is added – trequartista Jul 06 '15 at 02:55
  • 1
    As Mike Renfro mentioned. the answers package can be used: `\documentclass{gsm-l} \usepackage[papersize={160mm,240mm},inner=20mm, outer=15mm, vmargin=15mm]{geometry} \geometry{includeheadfoot} \usepackage{amssymb, amsmath} \usepackage{pgf,tikz} \usepackage{answers} \usetikzlibrary{arrows}

    \setcounter{tocdepth}{2}

    \Newassociation{sol}{Solution}{ans} \newtheorem{problem}{Problem} \numberwithin{problem}{chapter}

    \renewenvironment{Solution}[1] {\begin{trivlist}\item\relax \textbf{Solution to #1}} {\end{trivlist}}`

    `

    – Gonzalo Medina Jul 06 '15 at 03:08
  • 1
    And then `\begin{document} \Opensolutionfile{ans}[ans1] \chapter{Introduction} \begin{problem} This is problem 1.1 \begin{sol} The following is solution. \end{sol} \end{problem}

    \Closesolutionfile{ans} \chapter{Key to the exercises} I want to know how to auto list the problem number and the solution is behind it, like : \input{ans1} \end{document}`

    – Gonzalo Medina Jul 06 '15 at 03:08
  • Sorry about splitting the code in two comments, but it was too long for just one. – Gonzalo Medina Jul 06 '15 at 03:08
  • Or you can use \newcounter{answer}[chapter] and \renewcommand{\theanser}{\thechapter.\arabic{answer}} – John Kormylo Jul 06 '15 at 03:54

0 Answers0