请参阅第 56 至 60 行附近的注释以了解请求。
%
%--------------------------------------------------------------------------------------------------------- %
\documentclass{book}
%--------------------------------------------------------------------------------------------------------- %
%
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm,amssymb} %
\usepackage[paperwidth=170mm,paperheight=240mm,textwidth=132mm,driver=none,lmargin=25mm,vmargin=20mm,showframe,showcrop]{geometry} % verbose,showcrop,showframe=inner frame
\usepackage[a4,frame,center]{crop} % pageframe
\usepackage[lastexercise,answerdelayed]{exercise}
%
\setlength{\marginparsep}{0mm} %
%
\renewcommand{\subQuestionNB}{\alph{subQuestion}) }
\renewcommand{\AnswerHeader}{\medskip{\textbf{\AnswerName\ %
\ExerciseHeaderNB}\smallskip}}
\renewcommand{\ExerciseHeader}{\textbf{\quad\:\ExerciseName\;\ExerciseHeaderNB\ExerciseHeaderTitle\ExerciseHeaderOrigin} %
\par\nopagebreak\medskip}
\setlength{\subQuestionIndent}{26pt}
\renewcounter{Exercise}[chapter] % Reset counter every chapter
\renewcounter{Answer}[chapter] %
\newcounter{Problem}[chapter] %
%
\def\AnswerName{\par{Answers to questions on section}} %
%
\begin{document}
\chapter{\fontsize{11}{12}\selectfont{This header would already be present within the book}}\vspace{-36pt}
\begin{Exercise}[label={chap_01_sec_01},name={Exercises on section},counter={Problem}]
\Question{What is the symbol for iron?}
\Question{What is the symbol for hydrogen?}
\end{Exercise}
\begin{Exercise}[label={chap_01_sec_02},name={Exercises on section},counter={Problem}]
\Question{What is the symbol for lead?}
\Question{For hydrogen, state the atomic number}
\end{Exercise}
\chapter{\fontsize{11}{12}\selectfont{This header would already be present within the book}}\vspace{-36pt}
\begin{Exercise}[label={chap_02_sec_01},name={Exercises on section},counter={Problem}]
\Question{What is the symbol for copper?}
\Question{What is the form of oxygen?}
\end{Exercise}
\begin{Exercise}[label={chap_02_sec_02},name={Exercises on section},counter={Problem}]
\Question{What is the symbol for zinc?}
\Question{What is the form of zinc}
\end{Exercise}
%
% There are four sets of answers that follow
% The first two sets belong to chapter 1, the second two sets to chapter 2
%
% I want a chapter 1 header to go here
%
\begin{Answer}[ref={chap_01_sec_01}]
\Question{Fe=iron}
\Question{H}
\end{Answer}
\begin{Answer}[ref={chap_01_sec_02}]
\Question{Pb=lead}
\Question{1}
\end{Answer}
% and a chapter 2 header to go here
\begin{Answer}[ref={chap_02_sec_01}]
\Question{Cu=copper}
\Question{oxygen is a gas}
\end{Answer}
\begin{Answer}[ref={chap_02_sec_02}]
\Question{Zn=zinc}
\Question{zinc is a metal}
\end{Answer}
\shipoutAnswer
\end{document}
答案1
我创建了两个命令:
\answerheaderchap{\ref{chap:...}}
放在前章节的第一个答案与\ref{chap:...}
该章节的(当然,把相应的放在命令\label{chap:...}
后面\chapter
)\restoreanswerheader
放在后本章的第一个答案。
我还在答案列表之前插入了一个未编号的章节标题(如果您愿意)。
%
%--------------------------------------------------------------------------------------------------------- %
\documentclass{book}
%--------------------------------------------------------------------------------------------------------- %
%
\usepackage[fleqn]{amsmath} %
\usepackage{amsthm,amssymb} %
\usepackage[paperwidth=170mm,paperheight=240mm,textwidth=132mm,driver=none,lmargin=25mm,vmargin=20mm,showframe,showcrop]{geometry} % verbose,showcrop,showframe=inner frame
\usepackage[a4,frame,center]{crop} % pageframe
\usepackage[lastexercise,answerdelayed]{exercise}
%
\setlength{\marginparsep}{0mm} %
%
\renewcommand{\subQuestionNB}{\alph{subQuestion}) }
\renewcommand{\AnswerHeader}{\medskip{\textbf{\AnswerName\ %
\ExerciseHeaderNB}\smallskip}}
\renewcommand{\ExerciseHeader}{\textbf{\quad\:\ExerciseName\;\ExerciseHeaderNB\ExerciseHeaderTitle\ExerciseHeaderOrigin} %
\par\nopagebreak\medskip}
\setlength{\subQuestionIndent}{26pt}
\renewcounter{Exercise}[chapter] % Reset counter every chapter
\renewcounter{Answer}[chapter] %
\newcounter{Problem}[chapter] %
%
\def\AnswerName{\par{Answers to questions on section}} %
%
\newcommand{\answerheaderchap}[1]{\renewcommand{\AnswerHeader}{\textbf{Chapter #1}\smallskip
\textbf{\AnswerName\ \ExerciseHeaderNB}\smallskip}}
\newcommand{\restoreanswerheader}{\renewcommand{\AnswerHeader}{\textbf{\AnswerName\ \ExerciseHeaderNB}\smallskip}}
\begin{document}
\chapter{\fontsize{11}{12}\selectfont{This header would already be present within the book}}\label{chap:1}\vspace{-36pt}
\begin{Exercise}[label={chap_01_sec_01},name={Exercises on section},counter={Problem}]
\Question{What is the symbol for iron?}
\Question{What is the symbol for hydrogen?}
\end{Exercise}
\begin{Exercise}[label={chap_01_sec_02},name={Exercises on section},counter={Problem}]
\Question{What is the symbol for lead?}
\Question{For hydrogen, state the atomic number}
\end{Exercise}
\chapter{\fontsize{11}{12}\selectfont{This header would already be present within the book}}\label{chap:2}\vspace{-36pt}
\begin{Exercise}[label={chap_02_sec_01},name={Exercises on section},counter={Problem}]
\Question{What is the symbol for copper?}
\Question{What is the form of oxygen?}
\end{Exercise}
\begin{Exercise}[label={chap_02_sec_02},name={Exercises on section},counter={Problem}]
\Question{What is the symbol for zinc?}
\Question{What is the form of zinc}
\end{Exercise}
%
% There are four sets of answers that follow
% The first two sets belong to chapter 1, the second two sets to chapter 2
%
% I want a chapter 1 header to go here
%
\answerheaderchap{\ref{chap:1}}
\begin{Answer}[ref={chap_01_sec_01}]
\Question{Fe=iron}
\Question{H}
\end{Answer}
\restoreanswerheader
\begin{Answer}[ref={chap_01_sec_02}]
\Question{Pb=lead}
\Question{1}
\end{Answer}
% and a chapter 2 header to go here
\answerheaderchap{\ref{chap:2}}
\begin{Answer}[ref={chap_02_sec_01}]
\Question{Cu=copper}
\Question{oxygen is a gas}
\end{Answer}
\restoreanswerheader
\begin{Answer}[ref={chap_02_sec_02}]
\Question{Zn=zinc}
\Question{zinc is a metal}
\end{Answer}
\chapter*{\fontsize{11}{12}\selectfont{Solutions to the exercises}}
\shipoutAnswer
\end{document}
我希望这是您正在寻找的输出: