From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/114132 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fabrice L via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Conditional text appearing in a fixed vertical space Date: Tue, 11 Jan 2022 18:13:55 -0500 Message-ID: References: <88738524-afbc-6f9b-2e6b-604fa1351955@xs4all.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Content-Type: multipart/mixed; boundary="===============3472786708905748102==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="926"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Fabrice L To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Jan 12 00:14:36 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 1n7QLb-000Acs-EY for gctc-ntg-context-518@m.gmane-mx.org; Wed, 12 Jan 2022 00:14:35 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id ACFF72890DD; Wed, 12 Jan 2022 00:14:07 +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 OHV5LyCsI1Zm; Wed, 12 Jan 2022 00:14:05 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id A47A2286F78; Wed, 12 Jan 2022 00:14:05 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 2BF5F286F78 for ; Wed, 12 Jan 2022 00:14:04 +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 E4a_uDAO6VnJ for ; Wed, 12 Jan 2022 00:14:02 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.160.180; helo=mail-qt1-f180.google.com; envelope-from=fabrice.alpha@gmail.com; receiver= Original-Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (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 3D9BE280211 for ; Wed, 12 Jan 2022 00:14:02 +0100 (CET) Original-Received: by mail-qt1-f180.google.com with SMTP id i8so1116227qtw.0 for ; Tue, 11 Jan 2022 15:14:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=126MmDLKrnUnI8b1Gc55cgppQZwIUmaPDCMMgeLIfEY=; b=EPjZlP8hhQFmoIg38aA++0BX6miELkE8irG/mL/+ieXyuunfwhFkDMF8EfSTSzG6xe 6byA+eGfuvihjDurh01FCwROOZuue3YU28zUBcdb5Zw8lqvbdBE6zIhXt/xyRiHnMaov v+UIIuxFzSZfN+1gzXHeX6TJ4uAsOf5LThD5lexH/c9+LTEobnYvCcuUET67kIvUGqRH qgkYkTAopEd/eZr1JnW/yZ3u1t2DTWG8rTOADpe7lzwHDcwiEq5nn4dbhMnP2an67G7o ZS95BVc8v2gaxa0a2u0urhYSyIgQXh1V0H3K/5OOEJqANoRr4Qm9PonKQXDVpbQGGxF2 Hi3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=126MmDLKrnUnI8b1Gc55cgppQZwIUmaPDCMMgeLIfEY=; b=yVhkTgvGMJ/Ow+tKZ93IKPPUvYGPSHfKtE89JzJjYf/QJ9kxa0dtsYatrI6f/NZRp5 Ag2HtMdQIYEgbPzNg6kc+WAO96uzLtC7sZJVUfVH+ehSoBhc8zGQrkZegGvp/X8OjdvA vpEGueWNGWVnFw0MmnhSYbiv0/iGSVVkvUieW1EJXcvjdO2XodUKZJ427S3lqFo8w0Gz A9yTGMTsJYRw7ILg9Z7nMcwSXF65pqQlD2z4D7Z5jCFfZdY1Adt0Gpi93lTzw9EQfTXb lgQ/Hrs5xfSR8jgfyC3yfew358s8lVF9VxwRtUBfzTLFXNqgilTAeU83WUitZ1VnPVG4 zDrw== X-Gm-Message-State: AOAM53121gtasaJI8yYx58e/xdZ80TYr7P130EJGGhifTmMmj9DDMkNk ZPUtihfCWa++txxqllzh4A1Ynwy8tPE= X-Google-Smtp-Source: ABdhPJw171Ld7mokQNt7uoN8sF15g9j3m7dGHfOVhE7o6m7kjYi2942RgEiLmbHJb6mmRjAVUSthGg== X-Received: by 2002:a05:622a:30b:: with SMTP id q11mr5756880qtw.529.1641942837062; Tue, 11 Jan 2022 15:13:57 -0800 (PST) Original-Received: from smtpclient.apple ([38.74.28.141]) by smtp.gmail.com with ESMTPSA id bq41sm7305515qkb.32.2022.01.11.15.13.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jan 2022 15:13:56 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3693.40.0.1.81) 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:114132 Archived-At: --===============3472786708905748102== Content-Type: multipart/alternative; boundary="Apple-Mail=_ED06952D-EA5C-4204-9D80-00B135AF2804" --Apple-Mail=_ED06952D-EA5C-4204-9D80-00B135AF2804 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 11 janv. 2022 =C3=A0 17:56, Gavin via ntg-context = a =C3=A9crit : >=20 > Thanks Hans! This is great. I made a slight change to add an = additional feature. By moving the =E2=80=9Cmysolution=E2=80=9D = definition out of \startmode[solution], I can now use mysolution in = either mode. I=E2=80=99d use this if I want to give my solution to one = of the problems, as an example, on the handout. >=20 > -Gavin I have similar problem for my courses. The solution I use, different = than the one offered, is to write in a =C2=AB special =C2=BB color the = text I want to hide from the students. This permits me to have hidden = texts in figures for exemple. Also, I do not calculate space required, = this is automated ! Here is MWE : \enablemode[solution] \doifmode{solution}{ \definecolor[solcolor][magenta] }=20 \doifnotmode{solution}{ \definecolor[solcolor][white] }=20 \definedescription[solution] [color=3Dsolcolor] \starttext How many roads? \startcolor[solcolor] Professor note.\stopcolor \startsolution 42 roads. \stopsolution How much wood? \startsolution Alotta wood! \stopsolution No more questions. \stoptext So the color used when solutions are hidden are white on white, we can = not see the text; but of course, if you change the background, you see = the hidden text. So there is another step to the process (I usually do = this only once a term); open the file in Acrobat, and find the option to = delete hidden text. The text for which the color is the same as the = background is really deleted. You can try to select the text in any pdf = view/editor, the text is gone ! =20 Fabrice. >=20 >=20 > % \enablemode[solution] >=20 > % Define "mysolution=E2=80=9D for use independent of solution mode. > \definenarrower[mysolution] > [before=3D\blank\it, > after=3D\blank] >=20 > % If in solution mode, define "solution" to use "mysolution" > \startmode[solution] > \tolerant\protected\def\startsolution[#1]% > {\startmysolution} > \protected\def\stopsolution > {\stopmysolution} > \stopmode >=20 > % If NOT in solution mode, define "solution" to produce a blank space > \startnotmode[solution] > \tolerant\protected\def\startsolution[#1]% > {\doifelsenothing{#1}{\blank[1in]}{\blank[#1]} > \gobbleuntil\stopsolution} > \protected\def\stopsolution > {} > \stopnotmode >=20 >=20 > \starttext >=20 > How many roads? > \startsolution > 42 roads. > \stopsolution >=20 > How much wood? > \startsolution[1.5in] > Alotta wood! > \stopsolution >=20 > No more questions. >=20 > \stoptext >=20 >=20 >> On Jan 11, 2022, at 1:13 PM, Hans Hagen wrote: >>=20 >> On 1/11/2022 8:50 PM, 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 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. >>> In the example below, the first solution has the desired behavior. = The second solution has the syntax I=E2=80=99d like, but it doesn=E2=80=99= t make the space without a solution. >>> Any ideas would be welcome! I am still pretty new to ConTeXt, so I = struggle mixing things like the plain tex \vbox and ConTeXt = \start=E2=80=A6\stop concepts. >>> Thanks, >>> Gavin >>> \definemode[solution][yes] % yes to enable solutions, no to disable >>> \definebuffer [solution] % Captures solution in a buffer that isn't = used >>> \startmode[solution] % If in solution mode, redefine = \startsolution...\stopsolution >>> \definedelimitedtext[solution][ % Solution italic and indented >>> spacebefore=3Dmedium, >>> spaceafter=3Dmedium, >>> style=3D\rm\it, >>> leftmargin=3Dstandard, % Indents block on the left >>> rightmargin=3Dyes, % Indents block on the right >>> indentnext=3Dno, >>> before=3D\vbox to 1in\bgroup, >>> after=3D\egroup, >>> ] >>> \stopmode >>> \starttext >>> How many roads? (The 1-inch space below appears whether or not it = contains a solution.) >>> \vbox to 1in{% >>> \startsolution >>> 42 roads. >>> \stopsolution >>> } >>> How much wood? (I would like to define solution so this to behaves = like the previous question.) >>> \startsolution[1in] >>> Alotta wood! >>> \stopsolution >>> No more questions. >>> \stoptext >> a mix between big and low level >>=20 >> % \enablemode[solution] >>=20 >> \startmode[solution] % If in solution mode, redefine = \startsolution...\stopsolution >>=20 >> \definenarrower >> [mysolution] >> [before=3D\blank, >> after=3D\blank] >>=20 >> \tolerant\protected\def\startsolution[#1]% >> {\startmysolution >> \it} >>=20 >> \protected\def\stopsolution >> {\stopmysolution} >>=20 >> \stopmode >>=20 >> \startnotmode[solution] % If in solution mode, redefine = \startsolution...\stopsolution >>=20 >> \tolerant\protected\def\startsolution[#1]% >> {\doifelsenothing{#1}{\blank[2.5cm]}{\blank[#1]} >> \gobbleuntil\stopsolution} >>=20 >> \protected\def\stopsolution >> {} >>=20 >> \stopnotmode >>=20 >> \starttext >>=20 >> How many roads? (The 1-inch space below appears whether or not it = contains a solution.) >>=20 >> \startsolution >> 42 roads. >> \stopsolution >>=20 >> How much wood? (I would like to define solution so this to behaves = like the previous question.) >>=20 >> \startsolution[1in] >> Alotta wood! >> \stopsolution >>=20 >> No more questions. >> \stoptext >>=20 >> much nicer is to use the blocks mechanism (but i need to check if we = can do the 2in there) >>=20 >> Hans >>=20 >> ----------------------------------------------------------------- >> Hans Hagen | PRAGMA ADE >> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands >> tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl >> ----------------------------------------------------------------- >=20 > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_ED06952D-EA5C-4204-9D80-00B135AF2804 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 11 janv. 2022 =C3=A0 17:56, Gavin via ntg-context <ntg-context@ntg.nl> = a =C3=A9crit :

Thanks Hans! This is great. I made a slight = change to add an additional feature. By moving the =E2=80=9Cmysolution=E2=80= =9D definition out of \startmode[solution], I can now use mysolution in = either mode. I=E2=80=99d use this if I want to give my solution to one = of the problems, as an example, on the handout.

-Gavin


I have similar problem = for my courses. The solution I use, different than the = one offered, is = to write in a =C2=AB special =C2=BB color the = text I want to hide from the students. This permits me to have = hidden texts in figures for exemple. Also, I do not calculate space = required, this is automated !  Here is MWE :

\enablemode[solution]

\doifmode{solution}{
= \definecolor[solcolor][magenta]
\doifnotmode{s= olution}{
= \definecolor[solcolor][white]
\definedescripti= on[solution]
    [color=3Dsolcolor]

\starttext

How = many roads? \startcolor[solcolor] Professor = note.\stopcolor
 \startsolution
   42 = roads.
 \stopsolution

How much = wood?
 \startsolution
   Alotta = wood!
 \stopsolution

No= more questions.

\stoptext

So the color used when = solutions are hidden are white on white, we can not see the text; =  but of course, if you change the background, you see the hidden = text. So there is another step to the process (I usually do this only = once a term); open the file in Acrobat, and find the option to delete = hidden text. The text for which the color is the same as the background = is really deleted. You can try to select the text in any pdf = view/editor, the text is gone !  

Fabrice.




% \enablemode[solution]

% Define "mysolution=E2=80=9D for use independent of solution = mode.
\definenarrower[mysolution]
=  [before=3D\blank\it,
  after=3D\blank]

% If in solution mode, define "solution" to = use "mysolution"
\startmode[solution]
=   \tolerant\protected\def\startsolution[#1]%
=     {\startmysolution}
=   \protected\def\stopsolution
=     {\stopmysolution}
\stopmode

% If NOT in solution mode, define "solution" = to produce a blank space
\startnotmode[solution]
  \tolerant\protected\def\startsolution[#1]%
=     {\doifelsenothing{#1}{\blank[1in]}{\blank[#1]}
     \gobbleuntil\stopsolution}
  \protected\def\stopsolution
=     {}
\stopnotmode


\starttext

How = many roads?
 \startsolution
=    42 roads.
 \stopsolution

How much wood?
=  \startsolution[1.5in]
   Alotta = wood!
 \stopsolution

No = more questions.

\stoptext


On Jan = 11, 2022, at 1:13 PM, Hans Hagen <j.hagen@xs4all.nl> wrote:

On 1/11/2022 8:50 PM, 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 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.
In the = example below, the first solution has the desired behavior. The second = solution has the syntax I=E2=80=99d like, but it doesn=E2=80=99t make = the space without a solution.
Any ideas would be welcome! = I am still pretty new to ConTeXt, so I struggle mixing things like the = plain tex \vbox and ConTeXt \start=E2=80=A6\stop concepts.
Thanks,
Gavin
\definemode[solution][yes] % yes to enable solutions, no to = disable
\definebuffer  [solution] % Captures solution = in a buffer that isn't used
\startmode[solution] % If in = solution mode, redefine \startsolution...\stopsolution
\definedelimitedtext[solution][ % Solution italic and = indented
 spacebefore=3Dmedium,
=  spaceafter=3Dmedium,
 style=3D\rm\it,
 leftmargin=3Dstandard, % Indents block on the left
 rightmargin=3Dyes, % Indents block on the right
 indentnext=3Dno,
 before=3D\vbox = to 1in\bgroup,
 after=3D\egroup,
]
\stopmode
\starttext
How many = roads? (The 1-inch space below appears whether or not it contains a = solution.)
\vbox to 1in{%
=  \startsolution
   42 roads.
 \stopsolution
}
How much = wood? (I would like to define solution so this to behaves like the = previous question.)
\startsolution[1in]
=  Alotta wood!
\stopsolution
No more = questions.
\stoptext
a mix = between big and low level

% = \enablemode[solution]

\startmode[solution] = % If in solution mode, redefine \startsolution...\stopsolution

  \definenarrower
=     [mysolution]
=     [before=3D\blank,
=      after=3D\blank]

  \tolerant\protected\def\startsolution[#1]%
    {\startmysolution
=      \it}

=   \protected\def\stopsolution
=     {\stopmysolution}

\stopmode

\startnotmode[solution] = % If in solution mode, redefine \startsolution...\stopsolution

=   \tolerant\protected\def\startsolution[#1]%
=     {\doifelsenothing{#1}{\blank[2.5cm]}{\blank[#1]} =      \gobbleuntil\stopsolution}
  \protected\def\stopsolution
=     {}

\stopnotmode

\starttext

How = many roads? (The 1-inch space below appears whether or not it contains a = solution.)

\startsolution
=   42 roads.
\stopsolution

How much wood? (I would like to define solution so this to = behaves like the previous question.)

\startsolution[1in]
  Alotta = wood!
\stopsolution

No more = questions.
\stoptext

much = nicer is to use the blocks mechanism (but i need to check if we can do = the 2in there)

Hans

---------------------------------------------------------------= --
=             &n= bsp;           &nbs= p;            =    Hans Hagen | PRAGMA ADE
=             Ri= dderstraat 27 | 8061 GH Hasselt | The Netherlands
=      tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
---------------------------------------------------------------= --

_______________________________________________________________= ____________________
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
_______________________________________________________________= ____________________

= --Apple-Mail=_ED06952D-EA5C-4204-9D80-00B135AF2804-- --===============3472786708905748102== 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== --===============3472786708905748102==--