I have exercises with answers. I can put each exercise in a subsection
and each answer in a subsubsection (using the default style sheet).
I'd like to tag the answer heading cell (i.e., the subsubsection
styled cell) and use the tag to suppress outputting of the answers
(i.e., of all the material in that subsubsection, not just in the
heading), so that I can create a PDF of the exercises only.
I feel sure this can be done simply, but I don't see how to do it.
Suggestions?
> I have exercises with answers. I can put each exercise in a subsection
> and each answer in a subsubsection (using the default style sheet).
> I'd like to tag the answer heading cell (i.e., the subsubsection
> styled cell) and use the tag to suppress outputting of the answers
> (i.e., of all the material in that subsubsection, not just in the
> heading), so that I can create a PDF of the exercises only.
> I feel sure this can be done simply, but I don't see how to do it.
> Suggestions?
> Thanks,
> Alan Isaac
You should be able to just do
Cell->Cell Properties-> and uncheck the Open property to close
the cells in question.
(select all the cells you want closed before hand with the mouse)
Later on, you can Open them again doing the reverse of the above.
I have exercises with answers. I can put each exercise in a subsection
and each answer in a subsubsection (using the default style sheet).
I'd like to tag the answer heading cell (i.e., the subsubsection
styled cell) and use the tag to suppress outputting of the answers
(i.e., of all the material in that subsubsection, not just in the
heading), so that I can create a PDF of the exercises only.
I feel sure this can be done simply, but I don't see how to do it.
Suggestions?
Thanks,
Alan Isaac
Hi, Alan,
Recently here there was a discussion on making slides. Please have a look into my reply to this discussion: Re: Using Mathematica to create slides<http://forums.wolfram.com/mathgroup/archive/2012/Jan/msg00285.html>, of 13.01.2012. Approaches to hide executable code described there you may like to apply to your case hiding answers. In addition you may have the answers in a separate file and connect the files with hyperlinks.
Further, the "Presentations" package of David Park has routines that may seem you attractive for your purposes. One of them, for example, enables you to keep answers together with the tasks document, but in an invisible form (all located in one closed technical Section). They may only become visible appearing in a separate window upon demand (after clicking a button) in the Mathematica environment. They are not visible when one reads a pdf file. Probably the Presentations package has also other approaches.
I reckon you have a notebook with text cells, input cells and output cells, and you would like to produce a PDF document without the output cells? If that is the case, double-click the cell-bracket of each of the cells you would like to hide. This will not delete the cell, but simply hide it. Then you can File|SaveAs|PDF the notebook. If you need to show the hidden cells again, double-click their outer cell brackets (the ones with an arrow-like end).
-Tomas
> Date: Mon, 23 Jan 2012 02:58:44 -0500
> From: alan.is...@gmail.com
> Subject: exercises: suppress printing of answers
> To: mathgr...@smc.vnet.net
> I have exercises with answers. I can put each exercise in a subsection
> and each answer in a subsubsection (using the default style sheet).
> I'd like to tag the answer heading cell (i.e., the subsubsection
> styled cell) and use the tag to suppress outputting of the answers
> (i.e., of all the material in that subsubsection, not just in the
> heading), so that I can create a PDF of the exercises only.
> I feel sure this can be done simply, but I don't see how to do it.
> Suggestions?
Thanks for all the interesting suggestions.
More than one was usable, but I'd still
be interested in learning how to programmatically
close all subsections labelled with a specific tag.
Button[Style["Close the window", 16, Blue], NotebookClose[]]
}], WindowTitle -> "Problem 1: the answer",
WindowSize -> {500, 500}]]
In the end of your notebook with the problems make a Section "Answers". Copy-paste the above code into any input cell of this Section. Enter the text of the answer you wish into the Text cells and any formula into the Expression cells. Add more Text and Expression cells, if necessary. Mark the cell with this code as the "Initialization cell" (Menu/Cell/Cell Properties/Initialization cell). Execute this cell. A button entitled "Get answer : Nr.1" will appear. Copy-paste this button into the end of the text of your problem. Collapse the whole Section "Answers" around the Section cell, or close the cells with the answers (Menu/Cell/Cell Properties and uncheck "Open"), or the both. Save the notebook. Done. You will only need to execute any operation as soon as the notebook is first open. I use for these purposes the function DateString[] that I place in the very beginning of each notebook. The answers will appear only upon pressing the corresponding button. They will never be seen in the pdf document.