Las respuestas a las subpreguntas suelen ser breves: a) 2, b) -15, c) 21 ¿Cómo puedo forzar un salto de línea sin saltos de línea para una subpregunta determinada? MWE sigue
%
%--------------------------------------------------------------------------------------------------------- %
\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}
Respuesta1
No estoy familiarizado con el paquete de ejercicios pero no encontré nada en la documentación que respalde tener respuestas en la misma línea. Por eso he definido un nuevo comando \subQuestionOnSameLine
para este propósito.
El comando responsable de colocar una subpregunta en una nueva línea es \item
in \@subQuestionHeader
. He definido un nuevo comando \@subQuestionHeader@noItem
que es básicamente solo la salida de \show\@subQuestionHeader
sin \item
pero \hspace
en su lugar.
\subQuestionOnSameLine
simplemente reemplaza \@subQuestionHeader
con \@subQuestionHeader@noItem
y luego ejecuta el normal \subQuestion
.
\@subQuestionHeader
se reinicia al final de la pregunta donde termina el grupo. Hasta entonces todos \subQuestion
se comportarán como \subQuestionOnSameLine
. Si desea colocar una subpregunta en una nueva línea después de a, \subQuestionOnSameLine
puede usar \subQuestionOnNewLine
.
Tenga en cuenta que la primera subpregunta de cada pregunta siempre debe ser normal \subQuestion
, nunca \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}