[NTG-context] Conditional text appearing in a fixed vertical space

Gavin gavinpublic at comcast.net
Wed Jan 12 16:30:06 CET 2022

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 <adityam at 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,
>    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