
연습문제와 패키지의 답변 헤더도 exercise
같은 방식으로 재정의했습니다.
연습 헤더 뒤에는 답 헤더 번호 뒤에 약간의 공간이 정확하게 남아 있습니다.
물론 답변 헤더의 정의에 수동으로 넣을 수도 있는데, 패키지의 버그인지 아니면 제가 잘못한 것인지 궁금합니다.
\documentclass{book}
\usepackage{amsmath}
\usepackage[lastexercise]{exercise}
\setlength{\ExerciseSkipBefore}{\baselineskip}
\setlength{\ExerciseSkipAfter}{1\baselineskip}
\setlength{\AnswerSkipBefore}{0\baselineskip}
\setlength{\AnswerSkipAfter}{1.2\baselineskip}
\renewcounter{Exercise}[chapter]
\renewcommand{\ExerciseHeader}{\noindent\bfseries\ExerciseName\ \thechapter.\ExerciseHeaderNB.}
\renewcommand{\AnswerName}{Solution}
\renewcommand{\AnswerHeader}{\noindent\bfseries\AnswerName\ \thechapter.\ExerciseHeaderNB.}
\begin{document}
\chapter{My first chapter}
\section{Problems}
\begin{Exercise}
Text of the 1st problem
\end{Exercise}
\begin{Answer}
Text of the solution of the 1st problem
\end{Answer}
\begin{Exercise}
Text of the 2nd problem
\end{Exercise}
\begin{Answer}
Text of the solution of the 2nd problem
\end{Answer}
\begin{Exercise}
Text of the 3rd problem
\end{Exercise}
\begin{Answer}
Text of the solution of the 3rd problem
\end{Answer}
\end{document}
답변1
\@@@ExeEnv
답은 and 의 정의에 있습니다 .\@@@AnswerEnv
% exercise.sty, line 365:
\newcommand{\@@@ExeEnv}{%
\pagebreak[1]\vskip\ExerciseSkipBefore
\@QuestionLevel1
\refstepExecounter
\begingroup\@getExerciseInfo\ExerciseHeader
\addcontentsline{\ext@exercise}{\toc@exercise}{\ExerciseName\
\theExercise\ \expandafter{\itshape \ExerciseTitle}\hspace{.66em}}
\endgroup\AtBeginExercise}
% exercise.sty, line 656:
\newcommand{\@@@AnswerEnv}{%
\pagebreak[1]\vskip\AnswerSkipBefore\@QuestionLevel1
\begingroup\@getAnswerInfo\AnswerHeader\endgroup\AtBeginAnswer}
보시다시피 371번째 줄에는 보호되지 않은 줄 끝이 있는데, 이것이 “연습 1.1” 이후에 공간을 생성하는 것입니다.
\documentclass{book}
\usepackage{amsmath}
\usepackage[lastexercise]{exercise}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@@@ExeEnv}{ \endgroup}{\endgroup}{}{} % remove the wrong space
\makeatother
\setlength{\ExerciseSkipBefore}{\baselineskip}
\setlength{\ExerciseSkipAfter}{1\baselineskip}
\setlength{\AnswerSkipBefore}{0\baselineskip}
\setlength{\AnswerSkipAfter}{1.2\baselineskip}
\renewcounter{Exercise}[chapter]
\renewcommand{\ExerciseHeader}{%
\noindent\bfseries\ExerciseName\ \thechapter.\ExerciseHeaderNB. %
}
\renewcommand{\AnswerName}{Solution}
\renewcommand{\AnswerHeader}{%
\noindent\bfseries\AnswerName\ \thechapter.\ExerciseHeaderNB. %
}
\begin{document}
\chapter{My first chapter}
\section{Problems}
\begin{Exercise}
Text of the 1st problem
\end{Exercise}
\begin{Answer}
Text of the solution of the 1st problem
\end{Answer}
\begin{Exercise}
Text of the 2nd problem
\end{Exercise}
\begin{Answer}
Text of the solution of the 2nd problem
\end{Answer}
\begin{Exercise}
Text of the 3rd problem
\end{Exercise}
\begin{Answer}
Text of the solution of the 3rd problem
\end{Answer}
\end{document}
답변2
나에게는 버그인 것 같다. 정의 끝에 공백 추가
\renewcommand{\AnswerHeader}{\noindent\bfseries\AnswerName\ \thechapter.\ExerciseHeaderNB. }
% ^^^
해결 방법으로 문제를 해결합니다. 제 생각에는 \xspace
패키지의 솔루션 헤더 텍스트 정의에 누락된 것 같습니다 .
문서에서 찾을 수 있습니다.
\newcommand{\AnswerHeader}{\medskip\centerline{\textbf{Answer of \ExerciseName\ \ExerciseHeaderNB}\smallskip}}
나에게는 놀라운 일이다\smallskip
끝에 가 있습니다 .
MWE:
\documentclass{book}
\usepackage{amsmath}
\usepackage[lastexercise]{exercise}
\setlength{\ExerciseSkipBefore}{\baselineskip}
\setlength{\ExerciseSkipAfter}{1\baselineskip}
\setlength{\AnswerSkipBefore}{0\baselineskip}
\setlength{\AnswerSkipAfter}{1.2\baselineskip}
\renewcounter{Exercise}[chapter]
\renewcommand{\ExerciseHeader}{\noindent\bfseries\ExerciseName\ \thechapter.\ExerciseHeaderNB.}
\renewcommand{\AnswerName}{Solution}
\renewcommand{\AnswerHeader}{\noindent\bfseries\AnswerName\ \thechapter.\ExerciseHeaderNB. }
\begin{document}
\chapter{My first chapter}
\section{Problems}
\begin{Exercise}
Text of the 1st problem
\end{Exercise}
\begin{Answer}
Text of the solution of the 1st problem
\end{Answer}
\begin{Exercise}
Text of the 2nd problem
\end{Exercise}
\begin{Answer}
Text of the solution of the 2nd problem
\end{Answer}
\begin{Exercise}
Text of the 3rd problem
\end{Exercise}
\begin{Answer}
Text of the solution of the 3rd problem
\end{Answer}
\end{document}
결과: