* [NTG-context] issue when the encapsulation ‘startitem stopitem’ command is in another self-defined command
@ 2024-12-28 12:34 autumnus
2024-12-28 13:22 ` [NTG-context] " Wolfgang Schuster
0 siblings, 1 reply; 5+ messages in thread
From: autumnus @ 2024-12-28 12:34 UTC (permalink / raw)
To: ntg-context
hi,
I'm creating a command that can format multiple choice questions on my own.
I've done most of it at the moment.
But I want more, so I'm trying to create more versions of this command
that is already nearing completion.
So I'm using the following command to create a command with more possibilities.
I've noticed that ‘startitem stopitem’ isn't working.
Their location and serial number are anomalous.
%%%% Removed some unnecessary commands to show what the problem was.
% macros=mkvi
\starttext
\unprotect
\installnamespace {chitem}
\installcommandhandler \????chitem {chitem} \????chitem
\appendtoks
\setuevalue{\e!start\currentchitem}{\startnamedchitem [\currentchitem]}%
\setuevalue{\e!stop \currentchitem}{\stopnamedchitem}%
\to \everydefinechitem
\tolerant\protected\def\markedchoice#1{{\sym{@} \red sym : #1}}
\tolerant\protected\def\normalchoice#1{\startitem normal : #1\stopitem}
\tolerant\protected\def\\calc_maxwidth#1{}
%The longest option text is calculated by comparison to
% determine the number of columns that can be typeset
\tolerant\protected\def\startnamedchitem[#chitem]#*[#mark]#*[#option]#*#choice\stopnamedchitem%
{\begingroup
% \ifarguments 0\or :1\or +2\or =3\or !4\fi
\def\currentchitem{#chitem}%
\edef\p_correctmark{*}\edef\p_paramark{#mark}%
\calc_maxwidth{#choice}%
\ifx\p_paramark\p_correctmark
\markedchoice{#choice}%
\else
\normalchoice{#choice}%
\fi\endgroup}
\def\stopnamedchitem{}
\definechitem[chitem]
\protect
\startitemize[n,horizontal,two]%
% The process of calculating the number of formattable columns
% has been removed and the results of the calculations are used directly.
\startchitem xxx\stopchitem
\startchitem[*]correct choice\stopchitem
\startchitem xxx\stopchitem
\startchitem xxx\stopchitem
\stopitemize
\stoptext
%%%%%
thanks for any help,
autumnus
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* [NTG-context] Re: issue when the encapsulation ‘startitem stopitem’ command is in another self-defined command
2024-12-28 12:34 [NTG-context] issue when the encapsulation ‘startitem stopitem’ command is in another self-defined command autumnus
@ 2024-12-28 13:22 ` Wolfgang Schuster
2024-12-28 14:14 ` autumnus
2024-12-28 14:44 ` autumnus
0 siblings, 2 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2024-12-28 13:22 UTC (permalink / raw)
To: mailing list for ConTeXt users, autumnus
autumnus schrieb am 28.12.2024 um 13:34:
> hi,
>
> I'm creating a command that can format multiple choice questions on my own.
> I've done most of it at the moment.
> But I want more, so I'm trying to create more versions of this command
> that is already nearing completion.
> So I'm using the following command to create a command with more possibilities.
>
> I've noticed that ‘startitem stopitem’ isn't working.
You can't put the items in a group.
\starttext
before
\startitemize[n,horizontal,two]
\begingroup\startitem aaa\stopitem\endgroup
\begingroup\startitem bbb\stopitem\endgroup
\stopitemize
after
\stoptext
> Their location and serial number are anomalous.
>
> %%%% Removed some unnecessary commands to show what the problem was.
> % macros=mkvi
> \starttext
> \unprotect
> \installnamespace {chitem}
> \installcommandhandler \????chitem {chitem} \????chitem
>
> \appendtoks
> \setuevalue{\e!start\currentchitem}{\startnamedchitem [\currentchitem]}%
> \setuevalue{\e!stop \currentchitem}{\stopnamedchitem}%
> \to \everydefinechitem
>
> \tolerant\protected\def\markedchoice#1{{\sym{@} \red sym : #1}}
> \tolerant\protected\def\normalchoice#1{\startitem normal : #1\stopitem}
> \tolerant\protected\def\\calc_maxwidth#1{}
> %The longest option text is calculated by comparison to
> % determine the number of columns that can be typeset
>
> \tolerant\protected\def\startnamedchitem[#chitem]#*[#mark]#*[#option]#*#choice\stopnamedchitem%
You can't use \stopnamedchitem as delimiter for the environment,
what TeX has to see is the new \stopchitem command.
One method to achieve this is \grabuntil with a processing function.
\tolerant\protected\def\startnamedchitem[#1]#*[#2]#*[#3]%
{\begingroup
\edef\currentchitem{#1}%
\edef\m_mark{#2}%
\grabuntil{\e!stop\currentchitem}\process_chitem}
\def\process_chitem#1%
{\ifx\m_mark\wildcardsymbol
\aftergroup\markedchoice
\else
\aftergroup\normalchoice
\fi
\endgroup{#1}}
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* [NTG-context] Re: issue when the encapsulation ‘startitem stopitem’ command is in another self-defined command
2024-12-28 13:22 ` [NTG-context] " Wolfgang Schuster
@ 2024-12-28 14:14 ` autumnus
2024-12-28 14:44 ` autumnus
1 sibling, 0 replies; 5+ messages in thread
From: autumnus @ 2024-12-28 14:14 UTC (permalink / raw)
To: ntg-context
Thanks for the solution.
autumnus.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* [NTG-context] Re: issue when the encapsulation ‘startitem stopitem’ command is in another self-defined command
2024-12-28 13:22 ` [NTG-context] " Wolfgang Schuster
2024-12-28 14:14 ` autumnus
@ 2024-12-28 14:44 ` autumnus
2024-12-29 18:37 ` Wolfgang Schuster
1 sibling, 1 reply; 5+ messages in thread
From: autumnus @ 2024-12-28 14:44 UTC (permalink / raw)
To: ntg-context
hi, Wolfgang
Sorry, but after I tested it, it did output all the lists and their ordinal numbers.
However, if I used the horizontal parameter, it didn't go the way I expected.
The expected output
item 1 sym @
item 3 item 4
But the actual output is:
sym @
item 1 item 3
item 4
But if I remove the horizontal argument,
the list is laid out in the normal order:
item 1
sym @
item 3
item 4
What should I do with it?
thanks,
autumnus
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* [NTG-context] Re: issue when the encapsulation ‘startitem stopitem’ command is in another self-defined command
2024-12-28 14:44 ` autumnus
@ 2024-12-29 18:37 ` Wolfgang Schuster
0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2024-12-29 18:37 UTC (permalink / raw)
To: mailing list for ConTeXt users, autumnus
autumnus schrieb am 28.12.2024 um 15:44:
> hi, Wolfgang
>
> Sorry, but after I tested it, it did output all the lists and their ordinal numbers.
> However, if I used the horizontal parameter, it didn't go the way I expected.
>
> The expected output
> item 1 sym @
> item 3 item 4
>
> But the actual output is:
> sym @
> item 1 item 3
> item 4
>
> But if I remove the horizontal argument,
> the list is laid out in the normal order:
> item 1
> sym @
> item 3
> item 4
>
> What should I do with it?
When you use the "horizontal" or "random" option Context collects all
item entries enclosed
in a \startitem / \stopitem pair and flushes the collection at the end
of the itemize environment.
All normal entries which don't use them item-pair are placed as is
before the collected entries.
While there is a \startspecialitem / \stopspecialitem pair with a \sym
option, the entries aren't
collected at the moment.
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-29 18:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-28 12:34 [NTG-context] issue when the encapsulation ‘startitem stopitem’ command is in another self-defined command autumnus
2024-12-28 13:22 ` [NTG-context] " Wolfgang Schuster
2024-12-28 14:14 ` autumnus
2024-12-28 14:44 ` autumnus
2024-12-29 18:37 ` Wolfgang Schuster
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).