Como as quebras de linha podem ser suprimidas nas subquestões usando o Exercício?

Como as quebras de linha podem ser suprimidas nas subquestões usando o Exercício?

As respostas às subperguntas costumam ser curtas: a) 2, b) -15, c) 21 Como posso forçar uma quebra de linha para qualquer subpergunta? MWE segue

%
%--------------------------------------------------------------------------------------------------------- %
\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}

Responder1

Não estou familiarizado com o pacote de exercícios mas não encontrei nada na documentação que ele suporte para ter respostas na mesma linha. Portanto defini um novo comando \subQuestionOnSameLinepara este propósito.

O comando responsável por colocar uma subquestão em uma nova linha é o \itemin \@subQuestionHeader. Eu defini um novo comando \@subQuestionHeader@noItemque é basicamente apenas a saída \show\@subQuestionHeadersem o \itemmas a \hspace.

\subQuestionOnSameLinesimplesmente substitui \@subQuestionHeaderpor \@subQuestionHeader@noIteme depois executa o normal \subQuestion.

\@subQuestionHeaderé redefinido no final da pergunta onde o grupo termina. Até então, todos \subQuestionse comportarão como \subQuestionOnSameLine. Se você quiser colocar uma subquestão em uma nova linha depois de a \subQuestionOnSameLinevocê pode usar \subQuestionOnNewLine.

Observe que a primeira subquestão de cada pergunta deve ser sempre normal \subQuestion, nunca a \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}

captura de tela

informação relacionada