Re: exercises: suppress printing of answers

• To: mathgroup at smc.vnet.net
• Subject: [mg124619] Re: exercises: suppress printing of answers
• From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
• Date: Fri, 27 Jan 2012 06:07:42 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```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.

Thanks!

Alan

Hi, Alain,

TextCell[],

TextCell[

Style["This is some text with the answer to problem 1", 14],

"Output"],

TextCell[Style["containing display formulas and plain text:", 14],

"Output"],

ExpressionCell[

Style["\!\(\*SubsuperscriptBox[\(\[Integral]\), \(a\), \(b\)]\)x\

\[DifferentialD]x=\!\(\*FractionBox[\(1\), \

\(2\)]\)(\!\(\*SuperscriptBox[\(b\), \

\(2\)]\)-\!\(\*SuperscriptBox[\(a\), \(2\)]\))", Italic, 22],

"Output"],

TextCell[Style["This is some more text ", 14], "Output"],

ExpressionCell[

Style["\!\(\*SuperscriptBox[\(x\), \

\(2\)]\)+\!\(\*SuperscriptBox[\(y\), \

\(2\)]\)=\!\(\*SuperscriptBox[\(z\), \(2\)]\)", Italic, 22], "Output"],

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 se
e!
n in the pdf document.

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.

IEE S.A.

ZAE Weiergewan,

11, rue Edmond Reuter,

L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566

Office fax:       +352-2454-3566

mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at iee.lu<mailto:alexei.boulbitch at iee.lu>

```

• Prev by Date: Re: Probability
• Next by Date: Re: Mathematica 8 + OS X + McAfee = trouble; help?