연습문제를 사용하여 하위 질문에서 줄바꿈을 어떻게 억제할 수 있나요?

연습문제를 사용하여 하위 질문에서 줄바꿈을 어떻게 억제할 수 있나요?

하위 질문에 대한 답변은 짧은 경우가 많습니다. a) 2, b) -15, c) 21 주어진 하위 질문에 대해 줄 바꿈을 강제로 적용하려면 어떻게 해야 합니까? MWE 팔로우

%
%--------------------------------------------------------------------------------------------------------- %
\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}{16.8pt}

\renewcounter{Exercise}[chapter] % Reset counter every chapter
\renewcounter{Answer}[chapter] %
\newcounter{Problem}[chapter] %
%
\def\AnswerName{\par{Answers to questions on chapter}} %
%
\begin{document}

\begin{Exercise}[label={E1},name={Exercises on chapter},counter={Problem}]
  \Question{What is the symbol for iron?}
  \Question{What is the symbol for hydrogen?}
\end{Exercise}

\begin{Exercise}[label={E2},name={Exercises on chapter},counter={Problem}]
  \Question{What is the symbol for iron?}
  \Question{For hydrogen, state the following:}
        \subQuestion{the valency?} \subQuestion{the atomic number?} \subQuestion{the density?}
\end{Exercise}

  \begin{Answer}[ref={E1}]
    \Question{Fe}     
  \Question{H} 
  \end{Answer}

  \begin{Answer}[ref={E2}]
  \Question{Fe}
    \Question{}
    \subQuestion{2}
    \subQuestion{1 - Want this answer to follow on same line as (a)}
    \subQuestion{small - and this answer, too}
  \end{Answer}

\shipoutAnswer

\end{document}

답변1

나는 연습 패키지에 익숙하지 않지만 문서에서 같은 줄에 대한 답변을 지원하는 내용을 찾지 못했습니다. 그러므로 나는 \subQuestionOnSameLine이 목적을 위해 새로운 명령을 정의했습니다 .

새 줄에 하위 질문을 배치하는 명령은 \itemin 입니다 \@subQuestionHeader. 나는 기본적으로 the 없이 대신 a \@subQuestionHeader@noItem의 출력인 새 명령을 정의했습니다 .\show\@subQuestionHeader\item\hspace

\subQuestionOnSameLine단순히 \@subQuestionHeader로 대체한 \@subQuestionHeader@noItem다음 일반 을 실행합니다 \subQuestion.

\@subQuestionHeader그룹이 끝나는 질문이 끝나면 재설정됩니다. 그때까지는 모두가 \subQuestion처럼 행동할 것입니다 \subQuestionOnSameLine. a 뒤의 새 줄에 하위 질문을 배치하려면 \subQuestionOnSameLine를 사용할 수 있습니다 \subQuestionOnNewLine.

각 질문의 첫 번째 하위 질문은 항상 일반 이어야 하며 \subQuestion절대 가 아니어야 합니다 \subQuestionOnSameLine.

\documentclass{book}
% ------ packages ------
\usepackage[fleqn]{amsmath}
\usepackage{amsthm,amssymb}
\usepackage[paperwidth=170mm,paperheight=240mm,textwidth=132mm,driver=none,lmargin=25mm,vmargin=20mm,showframe,showcrop]{geometry}
\usepackage[a4,frame,center]{crop}
\usepackage[lastexercise,answerdelayed]{exercise}

% ------ \subQuestionOnSameLine ------
\makeatletter
\let \@subQuestionHeader@original=\@subQuestionHeader
\newcommand{\@subQuestionHeader@noItem}{%
    \hspace{1cm}%
    \begingroup
        \@getsubQuestionInfo
        \subQuestionHeaderDifficulty
        \subQuestionNB
    \endgroup
    \begingroup
        \@getsubQuestionInfo
        \subQuestionHeaderTitle
    \endgroup%
    \ignorespaces
}%

\newcommand{\subQuestionOnSameLine}{%
    \let \@subQuestionHeader=\@subQuestionHeader@noItem
    \subQuestion
}
\newcommand{\subQuestionOnNewLine}{%
    \let \@subQuestionHeader=\@subQuestionHeader@original
    \subQuestion
}
\makeatother

% ------ layout ------
\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}{16.8pt}

\renewcounter{Exercise}[chapter] % Reset counter every chapter
\renewcounter{Answer}[chapter]
\newcounter{Problem}[chapter]

\def\AnswerName{\par{Answers to questions on chapter}}


% ------ document ------
\begin{document}

\begin{Exercise}[label={E1},name={Exercises on chapter},counter={Problem}]
    \Question{What is the symbol for iron?}
    \Question{What is the symbol for hydrogen?}
\end{Exercise}

\begin{Exercise}[label={E2},name={Exercises on chapter},counter={Problem}]
    \Question{What is the symbol for iron?}
    \Question{For hydrogen, state the following:}
        \subQuestion{the valency} \subQuestion{the atomic number} \subQuestion{the density}
\end{Exercise}

\begin{Answer}[ref={E1}]
    \Question{Fe}
    \Question{H}
\end{Answer}


\begin{Answer}[ref={E2}]
    \Question{Fe}
    \Question{}
        \subQuestion{answer to~a}
        \subQuestionOnSameLine{answer to~b}
        \subQuestionOnSameLine{answer to~c}
\end{Answer}

\shipoutAnswer

\end{document}

스크린샷

관련 정보