Section with answers created automaticallyHow to place all proofs automatically in appendix?setting section...

How does buying out courses with grant money work?

Is this apparent Class Action settlement a spam message?

Is this version of a gravity generator feasible?

How do we know the LHC results are robust?

How to Reset Passwords on Multiple Websites Easily?

How to pronounce the slash sign

How to run a prison with the smallest amount of guards?

What happens if you roll doubles 3 times then land on "Go to jail?"

Trouble understanding the speech of overseas colleagues

Is expanding the research of a group into machine learning as a PhD student risky?

Anatomically Correct Strange Women In Ponds Distributing Swords

Is the destination of a commercial flight important for the pilot?

How do I find the solutions of the following equation?

What is the intuitive meaning of having a linear relationship between the logs of two variables?

Large drywall patch supports

Escape a backup date in a file name

Unreliable Magic - Is it worth it?

Are student evaluations of teaching assistants read by others in the faculty?

How can a function with a hole (removable discontinuity) equal a function with no hole?

Term for the "extreme-extension" version of a straw man fallacy?

Where does the Z80 processor start executing from?

Do the temporary hit points from Reckless Abandon stack if I make multiple attacks on my turn?

How does the UK government determine the size of a mandate?

Detecting if an element is found inside a container



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













4















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}
usepackage{amsthm}

newtheorem{ex}{Exercice}
newtheorem{ans}{} % Abbreviation for answer. No text needed because I just want numbers with the answers next to them.
newtheorem{hi}{} % Same here.

begin{document}

section{Algebra}
begin{ex}What is $1+3$?end{ex}
begin{hi}First consider $1+0$, $1+1$, $1+2$ and try to find a pattern.end{hi}
begin{ans}It's $4$!end{ans}

section{Grammar}
setcounter{ex}{0} % So the counter is set to zero when a new section begins.

begin{ex}The first letter of the alphabet?end{ex}
%No hint given here
begin{ans}Aend{ans}

section*{Answers}
subsection{Section Algebra}
%Answer should be here, but of course it isn't.

subsection{Section Grammar}
%Same.

section*{Hints}
subsection{Section Algebra}
%Hint here.

subsection{Section Grammar}
% No hint because I didn't ask Latex to do so.

end{document}


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.










share|improve this question




















  • 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 textbf{that 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
















4















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}
usepackage{amsthm}

newtheorem{ex}{Exercice}
newtheorem{ans}{} % Abbreviation for answer. No text needed because I just want numbers with the answers next to them.
newtheorem{hi}{} % Same here.

begin{document}

section{Algebra}
begin{ex}What is $1+3$?end{ex}
begin{hi}First consider $1+0$, $1+1$, $1+2$ and try to find a pattern.end{hi}
begin{ans}It's $4$!end{ans}

section{Grammar}
setcounter{ex}{0} % So the counter is set to zero when a new section begins.

begin{ex}The first letter of the alphabet?end{ex}
%No hint given here
begin{ans}Aend{ans}

section*{Answers}
subsection{Section Algebra}
%Answer should be here, but of course it isn't.

subsection{Section Grammar}
%Same.

section*{Hints}
subsection{Section Algebra}
%Hint here.

subsection{Section Grammar}
% No hint because I didn't ask Latex to do so.

end{document}


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.










share|improve this question




















  • 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 textbf{that 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














4












4








4


0






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}
usepackage{amsthm}

newtheorem{ex}{Exercice}
newtheorem{ans}{} % Abbreviation for answer. No text needed because I just want numbers with the answers next to them.
newtheorem{hi}{} % Same here.

begin{document}

section{Algebra}
begin{ex}What is $1+3$?end{ex}
begin{hi}First consider $1+0$, $1+1$, $1+2$ and try to find a pattern.end{hi}
begin{ans}It's $4$!end{ans}

section{Grammar}
setcounter{ex}{0} % So the counter is set to zero when a new section begins.

begin{ex}The first letter of the alphabet?end{ex}
%No hint given here
begin{ans}Aend{ans}

section*{Answers}
subsection{Section Algebra}
%Answer should be here, but of course it isn't.

subsection{Section Grammar}
%Same.

section*{Hints}
subsection{Section Algebra}
%Hint here.

subsection{Section Grammar}
% No hint because I didn't ask Latex to do so.

end{document}


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.










share|improve this question
















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}
usepackage{amsthm}

newtheorem{ex}{Exercice}
newtheorem{ans}{} % Abbreviation for answer. No text needed because I just want numbers with the answers next to them.
newtheorem{hi}{} % Same here.

begin{document}

section{Algebra}
begin{ex}What is $1+3$?end{ex}
begin{hi}First consider $1+0$, $1+1$, $1+2$ and try to find a pattern.end{hi}
begin{ans}It's $4$!end{ans}

section{Grammar}
setcounter{ex}{0} % So the counter is set to zero when a new section begins.

begin{ex}The first letter of the alphabet?end{ex}
%No hint given here
begin{ans}Aend{ans}

section*{Answers}
subsection{Section Algebra}
%Answer should be here, but of course it isn't.

subsection{Section Grammar}
%Same.

section*{Hints}
subsection{Section Algebra}
%Hint here.

subsection{Section Grammar}
% No hint because I didn't ask Latex to do so.

end{document}


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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 textbf{that 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





    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 textbf{that 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 textbf{that 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 textbf{that 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










1 Answer
1






active

oldest

votes


















0














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:
newcounter{problem}

%-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
newcommand{problem}{%
parbigskip
refstepcounter{problem}
noindenttextbf{ptype mnumber.theproblem}
}

%-> Defining the environment for the ANSWERS to QUESTIONS
newcommand{answer}[1]{%
letthefootnoterelax %... suppresses the footnote numbering
footnote{textbf{ptype mnumber.theproblem-} #1}%
}

newififcols

%-> Defining the environment for the SOLUTIONS:
newenvironment{solution}[1]{%
setlength{parindent}{0cm}
vspace{-2.5mm}
textbf{footnotesize Solution:}par
vspace{-3mm}
footnotesize
ifnum #1 > 1
colstrue
begin{multicols}{#1}
fi
}{%
ifcols
end{multicols}
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
newcommand{answer}[1]{%
lettheendnoterelax %... suppresses the endnote numbering
endnote{textbf{ptype mnumber.theproblem-} #1}%
}


I hope this helps you.





share























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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:
    newcounter{problem}

    %-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
    newcommand{problem}{%
    parbigskip
    refstepcounter{problem}
    noindenttextbf{ptype mnumber.theproblem}
    }

    %-> Defining the environment for the ANSWERS to QUESTIONS
    newcommand{answer}[1]{%
    letthefootnoterelax %... suppresses the footnote numbering
    footnote{textbf{ptype mnumber.theproblem-} #1}%
    }

    newififcols

    %-> Defining the environment for the SOLUTIONS:
    newenvironment{solution}[1]{%
    setlength{parindent}{0cm}
    vspace{-2.5mm}
    textbf{footnotesize Solution:}par
    vspace{-3mm}
    footnotesize
    ifnum #1 > 1
    colstrue
    begin{multicols}{#1}
    fi
    }{%
    ifcols
    end{multicols}
    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
    newcommand{answer}[1]{%
    lettheendnoterelax %... suppresses the endnote numbering
    endnote{textbf{ptype mnumber.theproblem-} #1}%
    }


    I hope this helps you.





    share




























      0














      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:
      newcounter{problem}

      %-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
      newcommand{problem}{%
      parbigskip
      refstepcounter{problem}
      noindenttextbf{ptype mnumber.theproblem}
      }

      %-> Defining the environment for the ANSWERS to QUESTIONS
      newcommand{answer}[1]{%
      letthefootnoterelax %... suppresses the footnote numbering
      footnote{textbf{ptype mnumber.theproblem-} #1}%
      }

      newififcols

      %-> Defining the environment for the SOLUTIONS:
      newenvironment{solution}[1]{%
      setlength{parindent}{0cm}
      vspace{-2.5mm}
      textbf{footnotesize Solution:}par
      vspace{-3mm}
      footnotesize
      ifnum #1 > 1
      colstrue
      begin{multicols}{#1}
      fi
      }{%
      ifcols
      end{multicols}
      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
      newcommand{answer}[1]{%
      lettheendnoterelax %... suppresses the endnote numbering
      endnote{textbf{ptype mnumber.theproblem-} #1}%
      }


      I hope this helps you.





      share


























        0












        0








        0







        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:
        newcounter{problem}

        %-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
        newcommand{problem}{%
        parbigskip
        refstepcounter{problem}
        noindenttextbf{ptype mnumber.theproblem}
        }

        %-> Defining the environment for the ANSWERS to QUESTIONS
        newcommand{answer}[1]{%
        letthefootnoterelax %... suppresses the footnote numbering
        footnote{textbf{ptype mnumber.theproblem-} #1}%
        }

        newififcols

        %-> Defining the environment for the SOLUTIONS:
        newenvironment{solution}[1]{%
        setlength{parindent}{0cm}
        vspace{-2.5mm}
        textbf{footnotesize Solution:}par
        vspace{-3mm}
        footnotesize
        ifnum #1 > 1
        colstrue
        begin{multicols}{#1}
        fi
        }{%
        ifcols
        end{multicols}
        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
        newcommand{answer}[1]{%
        lettheendnoterelax %... suppresses the endnote numbering
        endnote{textbf{ptype mnumber.theproblem-} #1}%
        }


        I hope this helps you.





        share













        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:
        newcounter{problem}

        %-> Defining the numbered environment for QUESTIONS, TESTS, EXERCISES, PROBLEMS, and CHALLENGES:
        newcommand{problem}{%
        parbigskip
        refstepcounter{problem}
        noindenttextbf{ptype mnumber.theproblem}
        }

        %-> Defining the environment for the ANSWERS to QUESTIONS
        newcommand{answer}[1]{%
        letthefootnoterelax %... suppresses the footnote numbering
        footnote{textbf{ptype mnumber.theproblem-} #1}%
        }

        newififcols

        %-> Defining the environment for the SOLUTIONS:
        newenvironment{solution}[1]{%
        setlength{parindent}{0cm}
        vspace{-2.5mm}
        textbf{footnotesize Solution:}par
        vspace{-3mm}
        footnotesize
        ifnum #1 > 1
        colstrue
        begin{multicols}{#1}
        fi
        }{%
        ifcols
        end{multicols}
        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
        newcommand{answer}[1]{%
        lettheendnoterelax %... suppresses the endnote numbering
        endnote{textbf{ptype mnumber.theproblem-} #1}%
        }


        I hope this helps you.






        share











        share


        share










        answered 3 mins ago









        BrasilBrasil

        4142412




        4142412






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Paper upload error, “Upload failed: The top margin is 0.715 in on page 3, which is below the required...

            Emraan Hashmi Filmografia | Linki zewnętrzne | Menu nawigacyjneGulshan GroverGulshan...

            How can I write this formula?newline and italics added with leqWhy does widehat behave differently if I...