Unwanted line break after beginning of solution environment in exam class
up vote
2
down vote
favorite
I generally like how the solution
environment behaves in the exam document class, but I have often found it useful to have a brief "answer" before a fully written out solution. I have accomplished this in the past with a simple answer
command that did most of what I wanted, but it was far from ideal. Thus, I thought it might be useful to define an answer
environment that behaved appropriately.
There are really two problems with what I have currently (in order of importance):
- The answer begins on a new line after "Solution:" and this looks awful. (I have tried a variety of things involving
nobreak
andnolinebreak
, but I cannot figure out why the answer appears on the right line for theproof
environment (why is there no line break here?) but on the wrong one for thesolution
environment.) - I would like to ensure equal vertical spacing between the text above and below the horizontal line following the answer provided within the
solution
environment (maybe this particular problem belongs in a new question if it's not an easy fix?).
Here is a picture describing the problem and a MWE that follows:
MWE:
documentclass{exam}
printanswers
usepackage{amsthm,amssymb,amsmath}
usepackage{etoolbox}
usepackage{lipsum}
newcommand{HRule}[1][medskipamount]{par
vspace*{dimexpr-parskip-baselineskip+#1}
noindentrule{linewidth}{0.2mm}par
vspace*{dimexpr-parskip-.5baselineskip+#1}}
makeatletter
newenvironment{answer}{par
pushQED{qed}%
normalfont topsep6p@@plus6p@relax
trivlist
itemignorespaces
}{%
popQEDendtrivlist@endpefalse
}
makeatother
AtBeginEnvironment{answer}{renewcommandqedsymbol{$blacklozenge$}}
AfterEndEnvironment{answer}{HRule}
makeatletter
newcommand*NoIndentAfterEnv[1]{%
AfterEndEnvironment{#1}{par@afterindentfalse@afterheading}}
makeatother
NoIndentAfterEnv{answer}
begin{document}
begin{proof}
begin{answer}
This is a short answer that currently appears on the ``correct'' line (i.e., no line break when beginning the answer environment immediately after the proof environment).
end{answer}
And here will appear a much longer solution as opposed to just an answer.
end{proof}
begin{solution}
begin{answer}
This is a short answer that currently appears on the ``wrong'' line (i.e., there is a line break when beginning the answer environment immediately after the solution environment).
end{answer}
lipsum[1-2]
end{solution}
end{document}
macros environments line-breaking rules exam
add a comment |
up vote
2
down vote
favorite
I generally like how the solution
environment behaves in the exam document class, but I have often found it useful to have a brief "answer" before a fully written out solution. I have accomplished this in the past with a simple answer
command that did most of what I wanted, but it was far from ideal. Thus, I thought it might be useful to define an answer
environment that behaved appropriately.
There are really two problems with what I have currently (in order of importance):
- The answer begins on a new line after "Solution:" and this looks awful. (I have tried a variety of things involving
nobreak
andnolinebreak
, but I cannot figure out why the answer appears on the right line for theproof
environment (why is there no line break here?) but on the wrong one for thesolution
environment.) - I would like to ensure equal vertical spacing between the text above and below the horizontal line following the answer provided within the
solution
environment (maybe this particular problem belongs in a new question if it's not an easy fix?).
Here is a picture describing the problem and a MWE that follows:
MWE:
documentclass{exam}
printanswers
usepackage{amsthm,amssymb,amsmath}
usepackage{etoolbox}
usepackage{lipsum}
newcommand{HRule}[1][medskipamount]{par
vspace*{dimexpr-parskip-baselineskip+#1}
noindentrule{linewidth}{0.2mm}par
vspace*{dimexpr-parskip-.5baselineskip+#1}}
makeatletter
newenvironment{answer}{par
pushQED{qed}%
normalfont topsep6p@@plus6p@relax
trivlist
itemignorespaces
}{%
popQEDendtrivlist@endpefalse
}
makeatother
AtBeginEnvironment{answer}{renewcommandqedsymbol{$blacklozenge$}}
AfterEndEnvironment{answer}{HRule}
makeatletter
newcommand*NoIndentAfterEnv[1]{%
AfterEndEnvironment{#1}{par@afterindentfalse@afterheading}}
makeatother
NoIndentAfterEnv{answer}
begin{document}
begin{proof}
begin{answer}
This is a short answer that currently appears on the ``correct'' line (i.e., no line break when beginning the answer environment immediately after the proof environment).
end{answer}
And here will appear a much longer solution as opposed to just an answer.
end{proof}
begin{solution}
begin{answer}
This is a short answer that currently appears on the ``wrong'' line (i.e., there is a line break when beginning the answer environment immediately after the solution environment).
end{answer}
lipsum[1-2]
end{solution}
end{document}
macros environments line-breaking rules exam
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I generally like how the solution
environment behaves in the exam document class, but I have often found it useful to have a brief "answer" before a fully written out solution. I have accomplished this in the past with a simple answer
command that did most of what I wanted, but it was far from ideal. Thus, I thought it might be useful to define an answer
environment that behaved appropriately.
There are really two problems with what I have currently (in order of importance):
- The answer begins on a new line after "Solution:" and this looks awful. (I have tried a variety of things involving
nobreak
andnolinebreak
, but I cannot figure out why the answer appears on the right line for theproof
environment (why is there no line break here?) but on the wrong one for thesolution
environment.) - I would like to ensure equal vertical spacing between the text above and below the horizontal line following the answer provided within the
solution
environment (maybe this particular problem belongs in a new question if it's not an easy fix?).
Here is a picture describing the problem and a MWE that follows:
MWE:
documentclass{exam}
printanswers
usepackage{amsthm,amssymb,amsmath}
usepackage{etoolbox}
usepackage{lipsum}
newcommand{HRule}[1][medskipamount]{par
vspace*{dimexpr-parskip-baselineskip+#1}
noindentrule{linewidth}{0.2mm}par
vspace*{dimexpr-parskip-.5baselineskip+#1}}
makeatletter
newenvironment{answer}{par
pushQED{qed}%
normalfont topsep6p@@plus6p@relax
trivlist
itemignorespaces
}{%
popQEDendtrivlist@endpefalse
}
makeatother
AtBeginEnvironment{answer}{renewcommandqedsymbol{$blacklozenge$}}
AfterEndEnvironment{answer}{HRule}
makeatletter
newcommand*NoIndentAfterEnv[1]{%
AfterEndEnvironment{#1}{par@afterindentfalse@afterheading}}
makeatother
NoIndentAfterEnv{answer}
begin{document}
begin{proof}
begin{answer}
This is a short answer that currently appears on the ``correct'' line (i.e., no line break when beginning the answer environment immediately after the proof environment).
end{answer}
And here will appear a much longer solution as opposed to just an answer.
end{proof}
begin{solution}
begin{answer}
This is a short answer that currently appears on the ``wrong'' line (i.e., there is a line break when beginning the answer environment immediately after the solution environment).
end{answer}
lipsum[1-2]
end{solution}
end{document}
macros environments line-breaking rules exam
I generally like how the solution
environment behaves in the exam document class, but I have often found it useful to have a brief "answer" before a fully written out solution. I have accomplished this in the past with a simple answer
command that did most of what I wanted, but it was far from ideal. Thus, I thought it might be useful to define an answer
environment that behaved appropriately.
There are really two problems with what I have currently (in order of importance):
- The answer begins on a new line after "Solution:" and this looks awful. (I have tried a variety of things involving
nobreak
andnolinebreak
, but I cannot figure out why the answer appears on the right line for theproof
environment (why is there no line break here?) but on the wrong one for thesolution
environment.) - I would like to ensure equal vertical spacing between the text above and below the horizontal line following the answer provided within the
solution
environment (maybe this particular problem belongs in a new question if it's not an easy fix?).
Here is a picture describing the problem and a MWE that follows:
MWE:
documentclass{exam}
printanswers
usepackage{amsthm,amssymb,amsmath}
usepackage{etoolbox}
usepackage{lipsum}
newcommand{HRule}[1][medskipamount]{par
vspace*{dimexpr-parskip-baselineskip+#1}
noindentrule{linewidth}{0.2mm}par
vspace*{dimexpr-parskip-.5baselineskip+#1}}
makeatletter
newenvironment{answer}{par
pushQED{qed}%
normalfont topsep6p@@plus6p@relax
trivlist
itemignorespaces
}{%
popQEDendtrivlist@endpefalse
}
makeatother
AtBeginEnvironment{answer}{renewcommandqedsymbol{$blacklozenge$}}
AfterEndEnvironment{answer}{HRule}
makeatletter
newcommand*NoIndentAfterEnv[1]{%
AfterEndEnvironment{#1}{par@afterindentfalse@afterheading}}
makeatother
NoIndentAfterEnv{answer}
begin{document}
begin{proof}
begin{answer}
This is a short answer that currently appears on the ``correct'' line (i.e., no line break when beginning the answer environment immediately after the proof environment).
end{answer}
And here will appear a much longer solution as opposed to just an answer.
end{proof}
begin{solution}
begin{answer}
This is a short answer that currently appears on the ``wrong'' line (i.e., there is a line break when beginning the answer environment immediately after the solution environment).
end{answer}
lipsum[1-2]
end{solution}
end{document}
macros environments line-breaking rules exam
macros environments line-breaking rules exam
asked 2 hours ago
Daniel W. Farlow
5061823
5061823
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f466272%2funwanted-line-break-after-beginning-of-solution-environment-in-exam-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f466272%2funwanted-line-break-after-beginning-of-solution-environment-in-exam-class%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown