ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: fv leung via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: fv leung <fvleung@gmail.com>
Subject: Re: Conditional text appearing in a fixed vertical space
Date: Thu, 13 Jan 2022 08:49:29 +0800	[thread overview]
Message-ID: <CAN-yaTm7k5wmhhLCExnLR_3e9KZpi37qq+GOMjp3=Crc=uT8Nw@mail.gmail.com> (raw)
In-Reply-To: <01B8D3B3-7CB7-4C67-B9C1-C515F2115F2E@comcast.net>


[-- Attachment #1.1: Type: text/plain, Size: 3047 bytes --]

You can also consider using viewerlayer:


\setupinteraction[state=start]

\defineviewerlayer[solution]

\setupcolors[state=start]
\usecolors[xwi]
\definecolor[keyColor][1.0(maroon)]

\starttext

\startitemize[n]
  \but[ToggleLayer{solution}]
  \samplefile{tufte}
  \blank[big]
  \startviewerlayer[solution]
    \keyColor
    \samplefile{knuth}
  \stopviewerlayer
\stopitemize

\stoptext

I print the file with the solution layer off to a 'clean' file for students.

Gavin via ntg-context <ntg-context@ntg.nl> 於 2022年1月12日 週三 下午11:30寫道:

> 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@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
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 4292 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

      reply	other threads:[~2022-01-13  0:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11 19:50 Gavin via ntg-context
2022-01-11 20:13 ` Hans Hagen via ntg-context
2022-01-11 22:56   ` Gavin via ntg-context
2022-01-11 23:13     ` Fabrice L via ntg-context
2022-01-11 23:44 ` Aditya Mahajan via ntg-context
2022-01-12 15:30   ` Gavin via ntg-context
2022-01-13  0:49     ` fv leung via ntg-context [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN-yaTm7k5wmhhLCExnLR_3e9KZpi37qq+GOMjp3=Crc=uT8Nw@mail.gmail.com' \
    --to=ntg-context@ntg.nl \
    --cc=fvleung@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).