From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/114142 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: fv leung via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Conditional text appearing in a fixed vertical space Date: Thu, 13 Jan 2022 08:49:29 +0800 Message-ID: References: <01B8D3B3-7CB7-4C67-B9C1-C515F2115F2E@comcast.net> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============9068965923921828798==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33335"; mail-complaints-to="usenet@ciao.gmane.io" Cc: fv leung To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Jan 13 01:50:22 2022 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7oJp-0008Qs-Ny for gctc-ntg-context-518@m.gmane-mx.org; Thu, 13 Jan 2022 01:50:21 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 583E12867D4; Thu, 13 Jan 2022 01:49:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GDbMhNQDOpVU; Thu, 13 Jan 2022 01:49:46 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0338428394A; Thu, 13 Jan 2022 01:49:46 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id A411128394A for ; Thu, 13 Jan 2022 01:49:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BQngeHXiULnh for ; Thu, 13 Jan 2022 01:49:43 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.170; helo=mail-vk1-f170.google.com; envelope-from=fvleung@gmail.com; receiver= Original-Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id D9503280895 for ; Thu, 13 Jan 2022 01:49:42 +0100 (CET) Original-Received: by mail-vk1-f170.google.com with SMTP id m57so2803606vkf.9 for ; Wed, 12 Jan 2022 16:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=v0eLjq2NM3j+6leA8dOiI7wclvqkKKnU21h84fFtXQc=; b=c6zwKMacgzNVTkw6/VGeQHE5CZlqkduFseM5kCIcAkoklyJ4nXJOL1bfA+6b78z4Sz jgYMzNG3Kp7j/ARHn87xmSVgAV4VUTVrEvBP7t/0+1U4eQKMY3ZAIkUkVys+zbMR4jMp w8P8LulqzsevX+gXptIYjERxU7w7DSnlSq1LJKyhj1Ld+Vq+E0proVDILsKdiwrQ0g0x zItcSO96ceO6KOEV+K/NgtFhdYl3wa9HEmJRfR7fU+YVzRnCg1weNJKv21t6alDwoBJQ l7a6j/AWMKZY8PTijA45NdhVf/m71+pKnoE8H4AFfCjTPKPtmp2Ahsqrs5VQmL3/x7j7 CWNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=v0eLjq2NM3j+6leA8dOiI7wclvqkKKnU21h84fFtXQc=; b=7smRSKmyOYq2ZWl0agBkwEMn/DgZAj97F5+4aTlYW6/YCGpa5UNFdLnnYkSem9tV67 KyLsky6EY4fBiJwR5V+bB7B+lF2LjZGe6Q9xrEz6LaSleHidXeO89s3B83RnjAyxbzs1 gBI3q1oVnvJRGRXzlY5Od6zVew7cMHnQWOAua0iybmO/zaV1uAqVpSW9p+magpIiq2bp pE7gZan7G/58V4HuXIUKyaAT7nlEwSGS7sWDsCO5XL34G6bIRZknogoBzI5BEXSKbOw0 gPDJl3Vrt3Q/UaMpvv8Gv+7g4Eiwh0qAlg0n9xDPA9YhXN0Y8h1HpYszALy4UVrTSyeq PfEQ== X-Gm-Message-State: AOAM533alQOCW6tAJR1qQnV6WihGUDowAD1IPp8Z7acNQ1c3UIyRCT56 h2zy95dkmgwyR+Jqs2N4qz23HLNAQ/BQHpzBZYdnW7OxX9iZ/w== X-Google-Smtp-Source: ABdhPJyoP1Z1IJxtOoFcJv2uXgWC+n+Q5Y7ZzC+tl2ET62Bi8aSaaI7C42id73ppfrAyAmGn0KJmqXzpqf8vDcKLWmI= X-Received: by 2002:a1f:a6d7:: with SMTP id p206mr1306956vke.31.1642034980682; Wed, 12 Jan 2022 16:49:40 -0800 (PST) In-Reply-To: <01B8D3B3-7CB7-4C67-B9C1-C515F2115F2E@comcast.net> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:114142 Archived-At: --===============9068965923921828798== Content-Type: multipart/alternative; boundary="000000000000bb821105d56c0f89" --000000000000bb821105d56c0f89 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable You can also consider using viewerlayer: \setupinteraction[state=3Dstart] \defineviewerlayer[solution] \setupcolors[state=3Dstart] \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 =E6=96=BC 2022=E5=B9=B41=E6=9C= =8812=E6=97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8B=E5=8D=8811:30=E5=AF=AB=E9=81=93= =EF=BC=9A > 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 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 =E2=80=9Csolution=E2= =80=9D mode is > enabled. I am struggling to get a vertical space for the solution which i= s > the same whether or not the solution is printed. Different problems requi= re > 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 framedtex= t > doesn't break across pages. So, if you have long answers, a different > mechanism is needed. > > > > \definemode[solution][no] > > > > \doifmodeelse{solution} > > {\defineframedtext[solution][empty=3Dno]} > > {\defineframedtext[solution][empty=3Dyes]} > > > > % Doesn't work. Why? > > % > \expanded{\defineframedtext[solution][empty=3D\doifmodeelse{solution}{no}= {yes}]} > > > > \setupframedtext > > [solution] > > [ > > spacebefore=3Dmedium, > > spaceafter=3Dmedium, > > width=3Dbroad, > > foregroundstyle=3D\rm\it, > > loffset=3D2em, > > roffset=3D2em, > > indentnext=3Dno, > > ] > > > > > > \starttext > > > > Sample question. Always show answer. > > > > \startsolution[height=3D1in, empty=3Dno] > > Alotta wood! > > \stopsolution > > > > > > How much wood? > > > > \startsolution[height=3D1in] > > 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 > > _________________________________________________________________________= __________ > --000000000000bb821105d56c0f89 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You can also consider using viewerlayer:


\setupinteraction[state=3Dstart]

\defineviewerlayer[solution]<= br>
\setupcolors[state=3Dstart]
\usecolors[xwi]
\definecolor[keyCo= lor][1.0(maroon)]

\starttext

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

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

Gavin via ntg-contex= t <ntg-context@ntg.nl> =E6= =96=BC 2022=E5=B9=B41=E6=9C=8812=E6=97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8B=E5= =8D=8811:30=E5=AF=AB=E9=81=93=EF=BC=9A
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 frame= dtext 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 st= yle defined in the example below, and only appear if the =E2=80=9Csolution= =E2=80=9D 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. Differen= t problems require different amounts of space, so this should be an argumen= t or key-value.
>
> This is how I would do it: piggyback on framedtext. Note that framedte= xt doesn't break across pages. So, if you have long answers, a differen= t mechanism is needed.
>
> \definemode[solution][no]
>
> \doifmodeelse{solution}
>=C2=A0 {\defineframedtext[solution][empty=3Dno]}
>=C2=A0 {\defineframedtext[solution][empty=3Dyes]}
>
> % Doesn't work. Why?
> % \expanded{\defineframedtext[solution][empty=3D\doifmodeelse{solution= }{no}{yes}]}
>
> \setupframedtext
>=C2=A0 [solution]
>=C2=A0 [
>=C2=A0 =C2=A0 spacebefore=3Dmedium,
>=C2=A0 =C2=A0 spaceafter=3Dmedium,
>=C2=A0 =C2=A0 width=3Dbroad,
>=C2=A0 =C2=A0 foregroundstyle=3D\rm\it,
>=C2=A0 =C2=A0 loffset=3D2em,
>=C2=A0 =C2=A0 roffset=3D2em,
>=C2=A0 =C2=A0 indentnext=3Dno,
>=C2=A0 ]
>
>
> \starttext
>
> Sample question. Always show answer.
>
> \startsolution[height=3D1in, empty=3Dno]
>=C2=A0 Alotta wood!
> \stopsolution
>
>
> How much wood?
>
> \startsolution[height=3D1in]
>=C2=A0 Alotta wood!
> \stopsolution
>
> You don't need to specify the height:
>
> \startsolution
>=C2=A0 \input ward
> \stopsolution
>
> No more questions.
> \stoptext

___________________________________________________________________________= ________
If your question is of interest to others as well, please add an entry to t= he Wiki!

maillist : ntg-cont= ext@ntg.nl / http://www.ntg.nl/mailman/listinfo/nt= g-context
webpage=C2=A0 : http://www.pragma-ade.nl / http://context.aanhet.net=
archive=C2=A0 : https://bitbucket.org/phg/context-m= irror/commits/
wiki=C2=A0 =C2=A0 =C2=A0: http://contextgarden.net
___________________________________________________________________________= ________
--000000000000bb821105d56c0f89-- --===============9068965923921828798== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============9068965923921828798==--