Section with answers created automaticallyHow to place all proofs automatically in appendix?setting section number, etc with counterDifferent numbering scheme per chapterCommon numbering with ntheoremthmbox with normal font and section numberingA simple section exercise sectionLaTeX beamer: pagenumbering appendixNumbering of newtheoremMixed section numbering accross subsectionsSidenotes with makeatletter/addtoreset begin with note 0, not 1Using answers with tasks
Do sorcerers' subtle spells require a skill check to be unseen?
What is the intuitive meaning of having a linear relationship between the logs of two variables?
Go Pregnant or Go Home
How to Reset Passwords on Multiple Websites Easily?
How does the UK government determine the size of a mandate?
Lay out the Carpet
System.debug(JSON.Serialize(o)) Not longer shows full string
How do I find the solutions of the following equation?
How to write papers efficiently when English isn't my first language?
India just shot down a satellite from the ground. At what altitude range is the resulting debris field?
Why are there no referendums in the US?
Sequence of Tenses: Translating the subjunctive
Short story about space worker geeks who zone out by 'listening' to radiation from stars
Why not increase contact surface when reentering the atmosphere?
How does Loki do this?
Increase performance creating Mandelbrot set in python
Is expanding the research of a group into machine learning as a PhD student risky?
How did Arya survive the stabbing?
Failed to fetch jessie backports repository
Proof of work - lottery approach
What is the opposite of 'gravitas'?
Avoiding estate tax by giving multiple gifts
Do the temporary hit points from Reckless Abandon stack if I make multiple attacks on my turn?
Was Spock the First Vulcan in Starfleet?
Section with answers created automatically
How to place all proofs automatically in appendix?setting section number, etc with counterDifferent numbering scheme per chapterCommon numbering with ntheoremthmbox with normal font and section numberingA simple section exercise sectionLaTeX beamer: pagenumbering appendixNumbering of newtheoremMixed section numbering accross subsectionsSidenotes with makeatletter/addtoreset begin with note 0, not 1Using answers with tasks
My question is quite similar to this one, but I think a slightly different approach is needed.
I have a document with a lot of exercices and I'd like to add aswers and hints to them in a certain section.
I don't want to do this manually, since, if I add an exercice, I'll have to make that the answers and hints keep the right order. Also, it's possible that not all exercices have an answer and a hint with them, so the numbering of answers and hints should be completely dependent of the numbering of exercices.
I.e, things like
1. Some hint for exercice 1
2. Some hint for exercice 2
4. Some hint for exercice 4
99. Some hint for exercice 99
should be possible.
For example:
documentclass[12pt,a4paper]article
usepackage[dutch]babel
usepackageamsthm
newtheoremexExercice
newtheoremans % Abbreviation for answer. No text needed because I just want numbers with the answers next to them.
newtheoremhi % Same here.
begindocument
sectionAlgebra
beginexWhat is $1+3$?endex
beginhiFirst consider $1+0$, $1+1$, $1+2$ and try to find a pattern.endhi
beginansIt's $4$!endans
sectionGrammar
setcounterex0 % So the counter is set to zero when a new section begins.
beginexThe first letter of the alphabet?endex
%No hint given here
beginansAendans
section*Answers
subsectionSection Algebra
%Answer should be here, but of course it isn't.
subsectionSection Grammar
%Same.
section*Hints
subsectionSection Algebra
%Hint here.
subsectionSection Grammar
% No hint because I didn't ask Latex to do so.
enddocument
So in fact I need some magicCommandThatPutsAnswersAndHintsSomewhereElse
. If there's more then one answer in a section, I'd like them to be numbered like theorems.
As you may have noticed in the example, I want the answers and hints in a subsection that refers to their section.
numbering theorems
|
show 2 more comments
My question is quite similar to this one, but I think a slightly different approach is needed.
I have a document with a lot of exercices and I'd like to add aswers and hints to them in a certain section.
I don't want to do this manually, since, if I add an exercice, I'll have to make that the answers and hints keep the right order. Also, it's possible that not all exercices have an answer and a hint with them, so the numbering of answers and hints should be completely dependent of the numbering of exercices.
I.e, things like
1. Some hint for exercice 1
2. Some hint for exercice 2
4. Some hint for exercice 4
99. Some hint for exercice 99
should be possible.
For example:
documentclass[12pt,a4paper]article
usepackage[dutch]babel
usepackageamsthm
newtheoremexExercice
newtheoremans % Abbreviation for answer. No text needed because I just want numbers with the answers next to them.
newtheoremhi % Same here.
begindocument
sectionAlgebra
beginexWhat is $1+3$?endex
beginhiFirst consider $1+0$, $1+1$, $1+2$ and try to find a pattern.endhi
beginansIt's $4$!endans
sectionGrammar
setcounterex0 % So the counter is set to zero when a new section begins.
beginexThe first letter of the alphabet?endex
%No hint given here
beginansAendans
section*Answers
subsectionSection Algebra
%Answer should be here, but of course it isn't.
subsectionSection Grammar
%Same.
section*Hints
subsectionSection Algebra
%Hint here.
subsectionSection Grammar
% No hint because I didn't ask Latex to do so.
enddocument
So in fact I need some magicCommandThatPutsAnswersAndHintsSomewhereElse
. If there's more then one answer in a section, I'd like them to be numbered like theorems.
As you may have noticed in the example, I want the answers and hints in a subsection that refers to their section.
numbering theorems
3
I've done this for my book. I could show you the code (email me if you want) but basically: to output answers to somewhere else I used the answers package and to refer to things in the main text from the answers file I used the xr package. (Also, there is a counter giving the current exercise number and you can define the environment ans to start with textbfthat counter so your answer file is not just taking the answer numbers in ascending order.)
– Jim Hefferon
Aug 21 '13 at 11:31
@JimHefferon that sounds useful - and also suggests a possible solution for non-broken hyperref endnotes...
– Joe Corneli
Aug 21 '13 at 13:18
@JimHefferon thanks, I'll first try myself to fix it using answers and xr, and I'll report back when I have some results.
– rabota
Aug 21 '13 at 15:26
@JimHefferon I'm just wondering: what exactly did you need the xr package for? It seems like I can freely refer to labels in the main text from the answers. When I refer from the main text to the answers, it seems that the answers are simply numbered continuously, but the number that is displayed is the same as the corresponding exercise. For example if I number the answers per sections like 1.1, 1.2, 2.1, 2.2 the answers are 'labeled' 1, 2, 3, 4 while the displayed numbering is really 1.1, 1.2, 2.1, 2.2.
– rabota
Jun 25 '14 at 13:01
I allow for something more complicated that sequentially numbered exercises. For instance, I allow for the publication of a list of answers of the questions that are checkmarked. (I also number the exercises in sequence with the theorems.)
– Jim Hefferon
Jun 25 '14 at 19:54
|
show 2 more comments
My question is quite similar to this one, but I think a slightly different approach is needed.
I have a document with a lot of exercices and I'd like to add aswers and hints to them in a certain section.
I don't want to do this manually, since, if I add an exercice, I'll have to make that the answers and hints keep the right order. Also, it's possible that not all exercices have an answer and a hint with them, so the numbering of answers and hints should be completely dependent of the numbering of exercices.
I.e, things like
1. Some hint for exercice 1
2. Some hint for exercice 2
4. Some hint for exercice 4
99. Some hint for exercice 99
should be possible.
For example:
documentclass[12pt,a4paper]article
usepackage[dutch]babel
usepackageamsthm
newtheoremexExercice
newtheoremans % Abbreviation for answer. No text needed because I just want numbers with the answers next to them.
newtheoremhi % Same here.
begindocument
sectionAlgebra
beginexWhat is $1+3$?endex
beginhiFirst consider $1+0$, $1+1$, $1+2$ and try to find a pattern.endhi
beginansIt's $4$!endans
sectionGrammar
setcounterex0 % So the counter is set to zero when a new section begins.
beginexThe first letter of the alphabet?endex
%No hint given here
beginansAendans
section*Answers
subsectionSection Algebra
%Answer should be here, but of course it isn't.
subsectionSection Grammar
%Same.
section*Hints
subsectionSection Algebra
%Hint here.
subsectionSection Grammar
% No hint because I didn't ask Latex to do so.
enddocument
So in fact I need some magicCommandThatPutsAnswersAndHintsSomewhereElse
. If there's more then one answer in a section, I'd like them to be numbered like theorems.
As you may have noticed in the example, I want the answers and hints in a subsection that refers to their section.
numbering theorems
My question is quite similar to this one, but I think a slightly different approach is needed.
I have a document with a lot of exercices and I'd like to add aswers and hints to them in a certain section.
I don't want to do this manually, since, if I add an exercice, I'll have to make that the answers and hints keep the right order. Also, it's possible that not all exercices have an answer and a hint with them, so the numbering of answers and hints should be completely dependent of the numbering of exercices.
I.e, things like
1. Some hint for exercice 1
2. Some hint for exercice 2
4. Some hint for exercice 4
99. Some hint for exercice 99
should be possible.
For example:
documentclass[12pt,a4paper]article
usepackage[dutch]babel
usepackageamsthm
newtheoremexExercice
newtheoremans % Abbreviation for answer. No text needed because I just want numbers with the answers next to them.
newtheoremhi % Same here.
begindocument
sectionAlgebra
beginexWhat is $1+3$?endex
beginhiFirst consider $1+0$, $1+1$, $1+2$ and try to find a pattern.endhi
beginansIt's $4$!endans
sectionGrammar
setcounterex0 % So the counter is set to zero when a new section begins.
beginexThe first letter of the alphabet?endex
%No hint given here
beginansAendans
section*Answers
subsectionSection Algebra
%Answer should be here, but of course it isn't.
subsectionSection Grammar
%Same.
section*Hints
subsectionSection Algebra
%Hint here.
subsectionSection Grammar
% No hint because I didn't ask Latex to do so.
enddocument
So in fact I need some magicCommandThatPutsAnswersAndHintsSomewhereElse
. If there's more then one answer in a section, I'd like them to be numbered like theorems.
As you may have noticed in the example, I want the answers and hints in a subsection that refers to their section.
numbering theorems
numbering theorems
edited Apr 13 '17 at 12:34
Community♦
1
1
asked Aug 21 '13 at 10:48
rabotarabota
619715
619715
3
I've done this for my book. I could show you the code (email me if you want) but basically: to output answers to somewhere else I used the answers package and to refer to things in the main text from the answers file I used the xr package. (Also, there is a counter giving the current exercise number and you can define the environment ans to start with textbfthat counter so your answer file is not just taking the answer numbers in ascending order.)
– Jim Hefferon
Aug 21 '13 at 11:31
@JimHefferon that sounds useful - and also suggests a possible solution for non-broken hyperref endnotes...
– Joe Corneli
Aug 21 '13 at 13:18
@JimHefferon thanks, I'll first try myself to fix it using answers and xr, and I'll report back when I have some results.
– rabota
Aug 21 '13 at 15:26
@JimHefferon I'm just wondering: what exactly did you need the xr package for? It seems like I can freely refer to labels in the main text from the answers. When I refer from the main text to the answers, it seems that the answers are simply numbered continuously, but the number that is displayed is the same as the corresponding exercise. For example if I number the answers per sections like 1.1, 1.2, 2.1, 2.2 the answers are 'labeled' 1, 2, 3, 4 while the displayed numbering is really 1.1, 1.2, 2.1, 2.2.
– rabota
Jun 25 '14 at 13:01
I allow for something more complicated that sequentially numbered exercises. For instance, I allow for the publication of a list of answers of the questions that are checkmarked. (I also number the exercises in sequence with the theorems.)
– Jim Hefferon
Jun 25 '14 at 19:54
|
show 2 more comments
3
I've done this for my book. I could show you the code (email me if you want) but basically: to output answers to somewhere else I used the answers package and to refer to things in the main text from the answers file I used the xr package. (Also, there is a counter giving the current exercise number and you can define the environment ans to start with textbfthat counter so your answer file is not just taking the answer numbers in ascending order.)
– Jim Hefferon
Aug 21 '13 at 11:31
@JimHefferon that sounds useful - and also suggests a possible solution for non-broken hyperref endnotes...
– Joe Corneli
Aug 21 '13 at 13:18
@JimHefferon thanks, I'll first try myself to fix it using answers and xr, and I'll report back when I have some results.
– rabota
Aug 21 '13 at 15:26
@JimHefferon I'm just wondering: what exactly did you need the xr package for? It seems like I can freely refer to labels in the main text from the answers. When I refer from the main text to the answers, it seems that the answers are simply numbered continuously, but the number that is displayed is the same as the corresponding exercise. For example if I number the answers per sections like 1.1, 1.2, 2.1, 2.2 the answers are 'labeled' 1, 2, 3, 4 while the displayed numbering is really 1.1, 1.2, 2.1, 2.2.
– rabota
Jun 25 '14 at 13:01
I allow for something more complicated that sequentially numbered exercises. For instance, I allow for the publication of a list of answers of the questions that are checkmarked. (I also number the exercises in sequence with the theorems.)
– Jim Hefferon
Jun 25 '14 at 19:54
3
3
I've done this for my book. I could show you the code (email me if you want) but basically: to output answers to somewhere else I used the answers package and to refer to things in the main text from the answers file I used the xr package. (Also, there is a counter giving the current exercise number and you can define the environment ans to start with textbfthat counter so your answer file is not just taking the answer numbers in ascending order.)
– Jim Hefferon
Aug 21 '13 at 11:31
I've done this for my book. I could show you the code (email me if you want) but basically: to output answers to somewhere else I used the answers package and to refer to things in the main text from the answers file I used the xr package. (Also, there is a counter giving the current exercise number and you can define the environment ans to start with textbfthat counter so your answer file is not just taking the answer numbers in ascending order.)
– Jim Hefferon
Aug 21 '13 at 11:31
@JimHefferon that sounds useful - and also suggests a possible solution for non-broken hyperref endnotes...
– Joe Corneli
Aug 21 '13 at 13:18
@JimHefferon that sounds useful - and also suggests a possible solution for non-broken hyperref endnotes...
– Joe Corneli
Aug 21 '13 at 13:18
@JimHefferon thanks, I'll first try myself to fix it using answers and xr, and I'll report back when I have some results.
– rabota
Aug 21 '13 at 15:26
@JimHefferon thanks, I'll first try myself to fix it using answers and xr, and I'll report back when I have some results.
– rabota
Aug 21 '13 at 15:26
@JimHefferon I'm just wondering: what exactly did you need the xr package for? It seems like I can freely refer to labels in the main text from the answers. When I refer from the main text to the answers, it seems that the answers are simply numbered continuously, but the number that is displayed is the same as the corresponding exercise. For example if I number the answers per sections like 1.1, 1.2, 2.1, 2.2 the answers are 'labeled' 1, 2, 3, 4 while the displayed numbering is really 1.1, 1.2, 2.1, 2.2.
– rabota
Jun 25 '14 at 13:01
@JimHefferon I'm just wondering: what exactly did you need the xr package for? It seems like I can freely refer to labels in the main text from the answers. When I refer from the main text to the answers, it seems that the answers are simply numbered continuously, but the number that is displayed is the same as the corresponding exercise. For example if I number the answers per sections like 1.1, 1.2, 2.1, 2.2 the answers are 'labeled' 1, 2, 3, 4 while the displayed numbering is really 1.1, 1.2, 2.1, 2.2.
– rabota
Jun 25 '14 at 13:01
I allow for something more complicated that sequentially numbered exercises. For instance, I allow for the publication of a list of answers of the questions that are checkmarked. (I also number the exercises in sequence with the theorems.)
– Jim Hefferon
Jun 25 '14 at 19:54
I allow for something more complicated that sequentially numbered exercises. For instance, I allow for the publication of a list of answers of the questions that are checkmarked. (I also number the exercises in sequence with the theorems.)
– Jim Hefferon
Jun 25 '14 at 19:54
|
show 2 more comments
1 Answer
1
active
oldest
votes
I face the same issue as you do. I create my exercises lists with two features: I can print it with the answers (for students) or with the solutions (for me; in this case, the answers disappear).
I will show you here pieces of my code (it is too huge and, believe me, is not worth to paste it as a whole here). So, let's start...
I created the commands problem
where I state the problem and answer
where I store the answer to each problem, as well as the environment solution
where I store the solution to the problem (with the argument, I can set the number of columns to arrange the solution in order to make it more compact):
%-> Defining COUNTERS:
newcounterproblem
%-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
newcommandproblem%
parbigskip
refstepcounterproblem
noindenttextbfptype mnumber.theproblem
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
letthefootnoterelax %... suppresses the footnote numbering
footnotetextbfptype mnumber.theproblem- #1%
newififcols
%-> Defining the environment for the SOLUTIONS:
newenvironmentsolution[1]%
setlengthparindent0cm
vspace-2.5mm
textbffootnotesize Solution:par
vspace-3mm
footnotesize
ifnum #1 > 1
colstrue
beginmulticols#1
fi
%
ifcols
endmulticols
fi
colsfalse
Lattar on, I create the Boolean ifshowans
for which showanstrue
can be commented out whenever I want to hide the solution and show the answer (in case I want to prin material for the students). Otherwise, it will print the solution and hide the answers:
%-> Defining the MATERIAL TYPE:
newififshowans
showanstrue
ifshowans
renewcommandanswer[1]
else
letsolutioncomment
letendsolutionendcomment
fi
Up to here, you can observe that in my case, I preferred to show the solutions in the footnotes. Since you want to display them at the end of the document, you should modify the answer
command to something like this:
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
lettheendnoterelax %... suppresses the endnote numbering
endnotetextbfptype mnumber.theproblem- #1%
I hope this helps you.
add a comment |
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',
autoActivateHeartbeat: false,
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%2f129364%2fsection-with-answers-created-automatically%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I face the same issue as you do. I create my exercises lists with two features: I can print it with the answers (for students) or with the solutions (for me; in this case, the answers disappear).
I will show you here pieces of my code (it is too huge and, believe me, is not worth to paste it as a whole here). So, let's start...
I created the commands problem
where I state the problem and answer
where I store the answer to each problem, as well as the environment solution
where I store the solution to the problem (with the argument, I can set the number of columns to arrange the solution in order to make it more compact):
%-> Defining COUNTERS:
newcounterproblem
%-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
newcommandproblem%
parbigskip
refstepcounterproblem
noindenttextbfptype mnumber.theproblem
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
letthefootnoterelax %... suppresses the footnote numbering
footnotetextbfptype mnumber.theproblem- #1%
newififcols
%-> Defining the environment for the SOLUTIONS:
newenvironmentsolution[1]%
setlengthparindent0cm
vspace-2.5mm
textbffootnotesize Solution:par
vspace-3mm
footnotesize
ifnum #1 > 1
colstrue
beginmulticols#1
fi
%
ifcols
endmulticols
fi
colsfalse
Lattar on, I create the Boolean ifshowans
for which showanstrue
can be commented out whenever I want to hide the solution and show the answer (in case I want to prin material for the students). Otherwise, it will print the solution and hide the answers:
%-> Defining the MATERIAL TYPE:
newififshowans
showanstrue
ifshowans
renewcommandanswer[1]
else
letsolutioncomment
letendsolutionendcomment
fi
Up to here, you can observe that in my case, I preferred to show the solutions in the footnotes. Since you want to display them at the end of the document, you should modify the answer
command to something like this:
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
lettheendnoterelax %... suppresses the endnote numbering
endnotetextbfptype mnumber.theproblem- #1%
I hope this helps you.
add a comment |
I face the same issue as you do. I create my exercises lists with two features: I can print it with the answers (for students) or with the solutions (for me; in this case, the answers disappear).
I will show you here pieces of my code (it is too huge and, believe me, is not worth to paste it as a whole here). So, let's start...
I created the commands problem
where I state the problem and answer
where I store the answer to each problem, as well as the environment solution
where I store the solution to the problem (with the argument, I can set the number of columns to arrange the solution in order to make it more compact):
%-> Defining COUNTERS:
newcounterproblem
%-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
newcommandproblem%
parbigskip
refstepcounterproblem
noindenttextbfptype mnumber.theproblem
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
letthefootnoterelax %... suppresses the footnote numbering
footnotetextbfptype mnumber.theproblem- #1%
newififcols
%-> Defining the environment for the SOLUTIONS:
newenvironmentsolution[1]%
setlengthparindent0cm
vspace-2.5mm
textbffootnotesize Solution:par
vspace-3mm
footnotesize
ifnum #1 > 1
colstrue
beginmulticols#1
fi
%
ifcols
endmulticols
fi
colsfalse
Lattar on, I create the Boolean ifshowans
for which showanstrue
can be commented out whenever I want to hide the solution and show the answer (in case I want to prin material for the students). Otherwise, it will print the solution and hide the answers:
%-> Defining the MATERIAL TYPE:
newififshowans
showanstrue
ifshowans
renewcommandanswer[1]
else
letsolutioncomment
letendsolutionendcomment
fi
Up to here, you can observe that in my case, I preferred to show the solutions in the footnotes. Since you want to display them at the end of the document, you should modify the answer
command to something like this:
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
lettheendnoterelax %... suppresses the endnote numbering
endnotetextbfptype mnumber.theproblem- #1%
I hope this helps you.
add a comment |
I face the same issue as you do. I create my exercises lists with two features: I can print it with the answers (for students) or with the solutions (for me; in this case, the answers disappear).
I will show you here pieces of my code (it is too huge and, believe me, is not worth to paste it as a whole here). So, let's start...
I created the commands problem
where I state the problem and answer
where I store the answer to each problem, as well as the environment solution
where I store the solution to the problem (with the argument, I can set the number of columns to arrange the solution in order to make it more compact):
%-> Defining COUNTERS:
newcounterproblem
%-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
newcommandproblem%
parbigskip
refstepcounterproblem
noindenttextbfptype mnumber.theproblem
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
letthefootnoterelax %... suppresses the footnote numbering
footnotetextbfptype mnumber.theproblem- #1%
newififcols
%-> Defining the environment for the SOLUTIONS:
newenvironmentsolution[1]%
setlengthparindent0cm
vspace-2.5mm
textbffootnotesize Solution:par
vspace-3mm
footnotesize
ifnum #1 > 1
colstrue
beginmulticols#1
fi
%
ifcols
endmulticols
fi
colsfalse
Lattar on, I create the Boolean ifshowans
for which showanstrue
can be commented out whenever I want to hide the solution and show the answer (in case I want to prin material for the students). Otherwise, it will print the solution and hide the answers:
%-> Defining the MATERIAL TYPE:
newififshowans
showanstrue
ifshowans
renewcommandanswer[1]
else
letsolutioncomment
letendsolutionendcomment
fi
Up to here, you can observe that in my case, I preferred to show the solutions in the footnotes. Since you want to display them at the end of the document, you should modify the answer
command to something like this:
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
lettheendnoterelax %... suppresses the endnote numbering
endnotetextbfptype mnumber.theproblem- #1%
I hope this helps you.
I face the same issue as you do. I create my exercises lists with two features: I can print it with the answers (for students) or with the solutions (for me; in this case, the answers disappear).
I will show you here pieces of my code (it is too huge and, believe me, is not worth to paste it as a whole here). So, let's start...
I created the commands problem
where I state the problem and answer
where I store the answer to each problem, as well as the environment solution
where I store the solution to the problem (with the argument, I can set the number of columns to arrange the solution in order to make it more compact):
%-> Defining COUNTERS:
newcounterproblem
%-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
newcommandproblem%
parbigskip
refstepcounterproblem
noindenttextbfptype mnumber.theproblem
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
letthefootnoterelax %... suppresses the footnote numbering
footnotetextbfptype mnumber.theproblem- #1%
newififcols
%-> Defining the environment for the SOLUTIONS:
newenvironmentsolution[1]%
setlengthparindent0cm
vspace-2.5mm
textbffootnotesize Solution:par
vspace-3mm
footnotesize
ifnum #1 > 1
colstrue
beginmulticols#1
fi
%
ifcols
endmulticols
fi
colsfalse
Lattar on, I create the Boolean ifshowans
for which showanstrue
can be commented out whenever I want to hide the solution and show the answer (in case I want to prin material for the students). Otherwise, it will print the solution and hide the answers:
%-> Defining the MATERIAL TYPE:
newififshowans
showanstrue
ifshowans
renewcommandanswer[1]
else
letsolutioncomment
letendsolutionendcomment
fi
Up to here, you can observe that in my case, I preferred to show the solutions in the footnotes. Since you want to display them at the end of the document, you should modify the answer
command to something like this:
%-> Defining the environment for the ANSWERS to QUESTIONS
newcommandanswer[1]%
lettheendnoterelax %... suppresses the endnote numbering
endnotetextbfptype mnumber.theproblem- #1%
I hope this helps you.
answered 3 mins ago
BrasilBrasil
4142412
4142412
add a comment |
add a comment |
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.
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%2f129364%2fsection-with-answers-created-automatically%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
3
I've done this for my book. I could show you the code (email me if you want) but basically: to output answers to somewhere else I used the answers package and to refer to things in the main text from the answers file I used the xr package. (Also, there is a counter giving the current exercise number and you can define the environment ans to start with textbfthat counter so your answer file is not just taking the answer numbers in ascending order.)
– Jim Hefferon
Aug 21 '13 at 11:31
@JimHefferon that sounds useful - and also suggests a possible solution for non-broken hyperref endnotes...
– Joe Corneli
Aug 21 '13 at 13:18
@JimHefferon thanks, I'll first try myself to fix it using answers and xr, and I'll report back when I have some results.
– rabota
Aug 21 '13 at 15:26
@JimHefferon I'm just wondering: what exactly did you need the xr package for? It seems like I can freely refer to labels in the main text from the answers. When I refer from the main text to the answers, it seems that the answers are simply numbered continuously, but the number that is displayed is the same as the corresponding exercise. For example if I number the answers per sections like 1.1, 1.2, 2.1, 2.2 the answers are 'labeled' 1, 2, 3, 4 while the displayed numbering is really 1.1, 1.2, 2.1, 2.2.
– rabota
Jun 25 '14 at 13:01
I allow for something more complicated that sequentially numbered exercises. For instance, I allow for the publication of a list of answers of the questions that are checkmarked. (I also number the exercises in sequence with the theorems.)
– Jim Hefferon
Jun 25 '14 at 19:54