Thanks Fabrice and Aditya! With three completely different approaches, I learned three times more than I was expecting. This has been a great help. I will probably use the framedtext method, but I learned something from each.
Gavin > On Jan 11, 2022, at 4:44 PM, Aditya Mahajan <adit...@umich.edu> wrote: > > On Tue, 11 Jan 2022, Gavin via ntg-context wrote: > >> Hello List, >> >> I am making problem sets for a physics class. Solutions use the style >> defined in the example below, and only appear if the “solution” mode is >> enabled. I am struggling to get a vertical space for the solution which is >> the same whether or not the solution is printed. Different problems require >> different amounts of space, so this should be an argument or key-value. > > This is how I would do it: piggyback on framedtext. Note that framedtext > doesn't break across pages. So, if you have long answers, a different > mechanism is needed. > > \definemode[solution][no] > > \doifmodeelse{solution} > {\defineframedtext[solution][empty=no]} > {\defineframedtext[solution][empty=yes]} > > % Doesn't work. Why? > % > \expanded{\defineframedtext[solution][empty=\doifmodeelse{solution}{no}{yes}]} > > \setupframedtext > [solution] > [ > spacebefore=medium, > spaceafter=medium, > width=broad, > foregroundstyle=\rm\it, > loffset=2em, > roffset=2em, > indentnext=no, > ] > > > \starttext > > Sample question. Always show answer. > > \startsolution[height=1in, empty=no] > Alotta wood! > \stopsolution > > > How much wood? > > \startsolution[height=1in] > Alotta wood! > \stopsolution > > You don't need to specify the height: > > \startsolution > \input ward > \stopsolution > > No more questions. > \stoptext ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________