ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* What is a better way to do this macro?
@ 2015-07-16 18:49 Idris Samawi Hamid ادريس سماوي حامد
  2015-07-16 19:03 ` Wolfgang Schuster
  0 siblings, 1 reply; 8+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد @ 2015-07-16 18:49 UTC (permalink / raw)
  To: ntg-context

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

Dear gang,

Consider the following (also attached):

=====choice-cs.tex====
\def\CHOICE#1#2{\leavevmode\vbox{\tabskip=0pt\everycr={}
                 \halign{\strut\hfil##\hfil\cr#1\cr#2\cr}}}

\setuppagenumber[state=stop]
\setupwhitespace[big]

\starttext
(One~* Two~* Three~* Four) is even.

(\CHOICE{x}{One}~* \CHOICE{1}{Two}~* \CHOICE{x}{Three}~* \CHOICE{2}{Four})  
is even.
\stoptext
======================

What is best way to define the \CHOICE macro without low-level TeX  
commands, only high-level ConTeXt commands? Thanks in advance and

Best wishes
Idris
-- 
Idris Samawi Hamid
Professor of Philosophy
Colorado State University
Fort Collins, CO 80523

[-- Attachment #2: choice-cs.pdf --]
[-- Type: application/pdf, Size: 6622 bytes --]

[-- Attachment #3: choice-cs.tex --]
[-- Type: application/x-tex, Size: 324 bytes --]

[-- Attachment #4: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What is a better way to do this macro?
  2015-07-16 18:49 What is a better way to do this macro? Idris Samawi Hamid ادريس سماوي حامد
@ 2015-07-16 19:03 ` Wolfgang Schuster
  2015-07-16 19:16   ` Idris Samawi Hamid ادريس سماوي حامد
  2015-07-16 20:09   ` Idris Samawi Hamid ادريس سماوي حامد
  0 siblings, 2 replies; 8+ messages in thread
From: Wolfgang Schuster @ 2015-07-16 19:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

> Idris Samawi Hamid ادريس سماوي حامد <mailto:Idris.Hamid@colostate.edu>
> 16. Juli 2015 20:49
> Dear gang,
>
> Consider the following (also attached):
>
> =====choice-cs.tex====
> \def\CHOICE#1#2{\leavevmode\vbox{\tabskip=0pt\everycr={}
>                 \halign{\strut\hfil##\hfil\cr#1\cr#2\cr}}}
>
> \setuppagenumber[state=stop]
> \setupwhitespace[big]
>
> \starttext
> (One~* Two~* Three~* Four) is even.
>
> (\CHOICE{x}{One}~* \CHOICE{1}{Two}~* \CHOICE{x}{Three}~* 
> \CHOICE{2}{Four}) is even.
> \stoptext
> ======================
>
> What is best way to define the \CHOICE macro without low-level TeX 
> commands, only high-level ConTeXt commands? Thanks in advance and
You can use the \framed command.

\define[2]\ChoiceOne
   
{\dontleavehmode\framed[frame=off,location=bottom,align=middle,offset=0pt]{#1\\#2}}

\defineframed[ChoiceTwo][frame=off,location=bottom,align=middle,offset=0pt]

\starttext

(\ChoiceOne{x}{One}~* \ChoiceOne{1}{Two}~* \ChoiceOne{x}{Three}~* 
\ChoiceOne{2}{Four}) is even.

(\ChoiceTwo{x\\One}~* \ChoiceTwo{1\\Two}~* \ChoiceTwo{x\\Three}~* 
\ChoiceTwo{2\\Four}) is even.

\stoptext

Wolfgang

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What is a better way to do this macro?
  2015-07-16 19:03 ` Wolfgang Schuster
@ 2015-07-16 19:16   ` Idris Samawi Hamid ادريس سماوي حامد
  2015-07-16 20:09   ` Idris Samawi Hamid ادريس سماوي حامد
  1 sibling, 0 replies; 8+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد @ 2015-07-16 19:16 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Wolfgang,

On Thu, 16 Jul 2015 13:03:15 -0600, Wolfgang Schuster  
<schuster.wolfgang@gmail.com> wrote:

> You can use the \framed command.
>
> \define[2]\ChoiceOne
> {\dontleavehmode\framed[frame=off,location=bottom,align=middle,offset=0pt]{#1\\#2}}
>
> \defineframed[ChoiceTwo][frame=off,location=bottom,align=middle,offset=0pt]
>
> \starttext
>
> (\ChoiceOne{x}{One}~* \ChoiceOne{1}{Two}~* \ChoiceOne{x}{Three}~*
> \ChoiceOne{2}{Four}) is even.
>
> (\ChoiceTwo{x\\One}~* \ChoiceTwo{1\\Two}~* \ChoiceTwo{x\\Three}~*
> \ChoiceTwo{2\\Four}) is even.
>
> \stoptext

Both examples are very instructive!! Thanks a million, Wolfgang, and

Best wishes
Idris
-- 
Idris Samawi Hamid
Professor of Philosophy
Colorado State University
Fort Collins, CO 80523
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What is a better way to do this macro?
  2015-07-16 19:03 ` Wolfgang Schuster
  2015-07-16 19:16   ` Idris Samawi Hamid ادريس سماوي حامد
@ 2015-07-16 20:09   ` Idris Samawi Hamid ادريس سماوي حامد
  2015-07-17  4:35     ` Wolfgang Schuster
  1 sibling, 1 reply; 8+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد @ 2015-07-16 20:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]

Hi Wolfgang, all,

Here is a new test file. Objective: To control the interlinespacing of the  
\\ command inside of \framed while keeping the bottom argument y of {x\\y}  
on the same baseline as the rest of the sentence. Look carefully at the  
examples in the attached pdf and see how the baselines moves when top is  
used to control \\.

A mixture of the parameters top and bottom does the trick, but the use of  
bottom is an ugly hack. Is there a better way? See below and attached

Best wishes
Idris

=====choice-cs-new2.tex=====
\setupinterlinespace[line=1.8em]
\setupwhitespace[big]

\defineframed[Choice][frame=off,location=bottom,align=middle,offset=0pt]

\defineframed[ChoiceTop][frame=off,location=bottom,align=middle,offset=0pt,top={\setupinterlinespace[line=1.2em]}]

\defineframed[ChoiceTopBottom][frame=off,location=bottom,align=middle,offset=0pt,top={\setupinterlinespace[line=1.2em]},bottom={\vskip.14em}]

  \starttext

(One~* Two~* Three~* Four) is even.

(\Choice{x\\One}~* \Choice{1\\Two}~* \Choice{x\\Three}~* \Choice{2\\Four})  
is even.

(\ChoiceTop{x\\One}~* \ChoiceTop{1\\Two}~* \ChoiceTop{x\\Three}~*  
\ChoiceTop{2\\Four}) is even.

(\ChoiceTopBottom{x\\One}~* \ChoiceTopBottom{1\\Two}~*  
\ChoiceTopBottom{x\\Three}~* \ChoiceTopBottom{2\\Four}) is even.
  \stoptext
============================
-- 
Idris Samawi Hamid
Professor of Philosophy
Colorado State University
Fort Collins, CO 80523

[-- Attachment #2: choice-cs-new2.pdf --]
[-- Type: application/pdf, Size: 6842 bytes --]

[-- Attachment #3: choice-cs-new2.tex --]
[-- Type: application/x-tex, Size: 772 bytes --]

[-- Attachment #4: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What is a better way to do this macro?
  2015-07-16 20:09   ` Idris Samawi Hamid ادريس سماوي حامد
@ 2015-07-17  4:35     ` Wolfgang Schuster
  2015-07-17 17:56       ` Idris Samawi Hamid ادريس سماوي حامد
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Schuster @ 2015-07-17  4:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

> Idris Samawi Hamid ادريس سماوي حامد <mailto:Idris.Hamid@colostate.edu>
> 16. Juli 2015 22:09
> Hi Wolfgang, all,
>
> Here is a new test file. Objective: To control the interlinespacing of 
> the \\ command inside of \framed while keeping the bottom argument y 
> of {x\\y} on the same baseline as the rest of the sentence. Look 
> carefully at the examples in the attached pdf and see how the 
> baselines moves when top is used to control \\.
>
> A mixture of the parameters top and bottom does the trick, but the use 
> of bottom is an ugly hack. Is there a better way? See below and attached
Use the foregroundstyle key to change the interlinespace.

Wolfgang

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What is a better way to do this macro?
  2015-07-17  4:35     ` Wolfgang Schuster
@ 2015-07-17 17:56       ` Idris Samawi Hamid ادريس سماوي حامد
  2015-07-17 18:07         ` Wolfgang Schuster
  0 siblings, 1 reply; 8+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد @ 2015-07-17 17:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, 16 Jul 2015 22:35:45 -0600, Wolfgang Schuster  
<schuster.wolfgang@gmail.com> wrote:

> Use the foregroundstyle key to change the interlinespace.

Works like a charm. Question: Should the wiki page be edited:

http://wiki.contextgarden.net/Command/setupframed

It has the equivalent of

foregroundstyle = <name>

Shouldn't that be changed to

foregroundstyle = <command>

Originally I looked for keys mapped to <command> so I tried bottom and top  
because and those are the only keys that are mapped to <command> in the  
description. Or am I missing something here?

Thanks, Wolfgang and

Best wishes
Idris
-- 
Idris Samawi Hamid
Professor of Philosophy
Colorado State University
Fort Collins, CO 80523
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What is a better way to do this macro?
  2015-07-17 17:56       ` Idris Samawi Hamid ادريس سماوي حامد
@ 2015-07-17 18:07         ` Wolfgang Schuster
  2015-07-17 21:01           ` Idris Samawi Hamid ادريس سماوي حامد
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Schuster @ 2015-07-17 18:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

> Idris Samawi Hamid ادريس سماوي حامد <mailto:Idris.Hamid@colostate.edu>
> 17. Juli 2015 19:56
> On Thu, 16 Jul 2015 22:35:45 -0600, Wolfgang Schuster 
> <schuster.wolfgang@gmail.com> wrote:
>
>
> Works like a charm. Question: Should the wiki page be edited:
>
> http://wiki.contextgarden.net/Command/setupframed
>
> It has the equivalent of
>
> foregroundstyle = <name>
>
> Shouldn't that be changed to
>
> foregroundstyle = <command>
>
> Originally I looked for keys mapped to <command> so I tried bottom and 
> top because and those are the only keys that are mapped to <command> 
> in the description. Or am I missing something here?

The foregroundstyle should list the same arguments as the style key from 
other commands/environments.

For a example look at the arguments for \setupdescriptions: 
http://wiki.contextgarden.net/Command/setupdescriptions

Wolfgang

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: What is a better way to do this macro?
  2015-07-17 18:07         ` Wolfgang Schuster
@ 2015-07-17 21:01           ` Idris Samawi Hamid ادريس سماوي حامد
  0 siblings, 0 replies; 8+ messages in thread
From: Idris Samawi Hamid ادريس سماوي حامد @ 2015-07-17 21:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, 17 Jul 2015 12:07:29 -0600, Wolfgang Schuster  
<schuster.wolfgang@gmail.com> wrote:

>> Idris Samawi Hamid ادريس سماوي حامد <mailto:Idris.Hamid@colostate.edu>
>> 17. Juli 2015 19:56
>> On Thu, 16 Jul 2015 22:35:45 -0600, Wolfgang Schuster
>> <schuster.wolfgang@gmail.com> wrote:
>>
>>
>> Works like a charm. Question: Should the wiki page be edited:
>>
>> http://wiki.contextgarden.net/Command/setupframed
>>
>> It has the equivalent of
>>
>> foregroundstyle = <name>
>>
>> Shouldn't that be changed to
>>
>> foregroundstyle = <command>
>>
>> Originally I looked for keys mapped to <command> so I tried bottom and
>> top because and those are the only keys that are mapped to <command>
>> in the description. Or am I missing something here?
>
> The foregroundstyle should list the same arguments as the style key from
> other commands/environments.
>
> For a example look at the arguments for \setupdescriptions:
> http://wiki.contextgarden.net/Command/setupdescriptions

Ah! Perhaps disambiguating would help unsuspecting users. So in  
\setupdescriptions we have things like

style = normal bold slanted boldslanted type cap small... command
[i.e. style = <name>|<command>]
color = <name>
before = <command>

So in the explanation of the foregroundstyle key we could have, e.g.

foregroundstyle	= <name|command>

making it clear that this key takes both a name and a command argument.  
Anyway, thanks kindly and

Best wishes
Idris
-- 
Idris Samawi Hamid
Professor of Philosophy
Colorado State University
Fort Collins, CO 80523
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-07-17 21:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-16 18:49 What is a better way to do this macro? Idris Samawi Hamid ادريس سماوي حامد
2015-07-16 19:03 ` Wolfgang Schuster
2015-07-16 19:16   ` Idris Samawi Hamid ادريس سماوي حامد
2015-07-16 20:09   ` Idris Samawi Hamid ادريس سماوي حامد
2015-07-17  4:35     ` Wolfgang Schuster
2015-07-17 17:56       ` Idris Samawi Hamid ادريس سماوي حامد
2015-07-17 18:07         ` Wolfgang Schuster
2015-07-17 21:01           ` Idris Samawi Hamid ادريس سماوي حامد

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).