miller@cogsci.ucsd.EDU (Jeff Miller) (01/18/91)
Hello Texperts. I would like to make up a problem set with answers. Ideally, the answers should be next to the problems in the file, but should all print together at the end of the document. What I have in mind is a file like this: \problem{What is the capital of the US?} \answer{Washington, D. C.} \problem{What is 2+2?} \answer{4} that prints out like this: Problems: What is the capital of the US? What is 2+2? Answers: Washington, D. C. 4. Is this possible? Should I just write a little program to preprocess the file before I give it to Latex (seems crude, but easy). Thanks for any pointers you can give me. Jeff Miller Psychology, UCSD jomiller@ucsd.edu
eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (01/18/91)
miller@cogsci.ucsd.EDU (Jeff Miller) writes: >\problem{What is the capital of the US?} >\answer{Washington, D. C.} >\problem{What is 2+2?} >\answer{4} insert \printanswers here >that prints out like this: >Problems: >What is the capital of the US? >What is 2+2? >Answers: >Washington, D. C. >4. \newbox\answerscollect \setbox\answerscollect{\vbox{Answers:\par} \def\answer#1\par {\setbox\answerscollect= \vbox{\unvbox\answerscollect #1\par}} \def\printanswers{\unvbox\answerscollect} Add some bells and whistles. Victor.
hudson@ug.cs.dal.ca (Bruce Hudson) (01/18/91)
In article <1991Jan18.002152.5212@csrd.uiuc.edu> eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) writes: > >\newbox\answerscollect >\setbox\answerscollect{\vbox{Answers:\par} >\def\answer#1\par > {\setbox\answerscollect= > \vbox{\unvbox\answerscollect > #1\par}} >\def\printanswers{\unvbox\answerscollect} > I have a somewhat related question. When I needed something like this, this is pretty-much the solution I came up with. But I was collecting a series of tables so I checked to see if the next table would fit and added a pagebreak if it would not, with "\vfill\eject". For some reason, the vertical fill was being lost so that I would get an underfull vbox during output for each page of tables (except the last). Can someone tell me how to avoid these error messages? Thanks. -- Bruce A. Hudson | HUDSON@AC.DAL.CA UCIS, Facilities and Operations | HUDSON@DALAC (Bitnet) Dalhousie University | HUDSON@DALCS (UUCP) Halifax, Nova Scotia, Canada |
adrian@mti.mti.com (Adrian McCarthy) (01/19/91)
In article <252@cogsci.ucsd.EDU> miller@cogsci.ucsd.EDU (Jeff Miller) writes: >Hello Texperts. I would like to make up a problem set with answers. >Ideally, the answers should be next to the problems in the file, >but should all print together at the end of the document. Knuth did just that in the TeXbook. It's all explained in Appendix E: Example Formats, p. 422. The basic idea is to have all of your answers written out to a file, then at the appropriate place near the end, you close the file and \input it into the document. Aid. (adrian@gonzo.mti.com)