* recursion in a table
@ 2022-05-01 18:43 Henning Hraban Ramm via ntg-context
2022-05-02 0:30 ` Aditya Mahajan via ntg-context
0 siblings, 1 reply; 3+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2022-05-01 18:43 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Henning Hraban Ramm
Hi,
I was playing with the example from
https://wiki.contextgarden.net/Scaling_Rotating_Mirroring_Clipping#Location_parameter
and tried to put it in a tabulate:
\useMPlibrary[dum]
\setupexternalfigures[width=3em,height=2em,frame=on,]
%\def\TXT{\ruledhbox{\bf(XyX)}}
\def\TXT{\externalfigure[pic]}
\starttabulate[|l|l|l|l|l|l|]
\NC\NC normal\NC depth\NC fit\NC broad\NC high\NC\NR
\HL
\dostepwiserecurse{0}{359}{45}{%
%\expanded{\setuprotate[rotation=\recurselevel]}
\NC{\expanded{\recurselevel}˚}%
\NC{\ruledhbox{X\rotate[location=normal,rotation=\recurselevel]{\TXT}X}}%
\NC{\ruledhbox{X\rotate[location=depth,rotation=\recurselevel]
{\TXT}X}}%
\NC{\ruledhbox{X\rotate[location=fit,rotation=\recurselevel]
{\TXT}X}}%
\NC{\ruledhbox{X\rotate[location=broad,rotation=\recurselevel]
{\TXT}X}}%
\NC{\ruledhbox{X\rotate[location=high,rotation=\recurselevel]
{\TXT}X}}%
\NC\NR}
% \HL % error
\stoptabulate
This works, but \recurselevel is always 0. I know I must expand it (like
in the original example), but I can’t make it work within the tabulation.
In the first column, \expanded{\recurselevel} stays 0, and
rotation=\expanded{\recurselevel} gives an error, while the \setuprotate
line has no effect (if I remove "rotation=\recurselevel", of course).
How would that work?
Also, \HL doesn’t work at the end, and the second line of the error
message makes no sense:
"""
I expect to see \noalign only after the \cr of an alignment.
Proceed, and I'll ignore this case.
mtx-context | fatal error: return code: 1
"""
Hraban
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: recursion in a table
2022-05-01 18:43 recursion in a table Henning Hraban Ramm via ntg-context
@ 2022-05-02 0:30 ` Aditya Mahajan via ntg-context
2022-05-02 7:16 ` Hans Hagen via ntg-context
0 siblings, 1 reply; 3+ messages in thread
From: Aditya Mahajan via ntg-context @ 2022-05-02 0:30 UTC (permalink / raw)
To: Henning Hraban Ramm via ntg-context; +Cc: Aditya Mahajan
[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]
On Sun, 1 May 2022, Henning Hraban Ramm via ntg-context wrote:
> Hi,
> I was playing with the example from
> https://wiki.contextgarden.net/Scaling_Rotating_Mirroring_Clipping#Location_parameter
> and tried to put it in a tabulate:
>
>
> \useMPlibrary[dum]
> \setupexternalfigures[width=3em,height=2em,frame=on,]
>
> %\def\TXT{\ruledhbox{\bf(XyX)}}
> \def\TXT{\externalfigure[pic]}
>
> \starttabulate[|l|l|l|l|l|l|]
> \NC\NC normal\NC depth\NC fit\NC broad\NC high\NC\NR
> \HL
> \dostepwiserecurse{0}{359}{45}{%
> %\expanded{\setuprotate[rotation=\recurselevel]}
> \NC{\expanded{\recurselevel}˚}%
Untested, but I think that you might need:
\expanded{\NC \recurselevel \noexpand\NC ... }
> This works, but \recurselevel is always 0. I know I must expand it (like
> in the original example), but I can’t make it work within the tabulation.
> In the first column, \expanded{\recurselevel} stays 0, and
> rotation=\expanded{\recurselevel} gives an error, while the \setuprotate
> line has no effect (if I remove "rotation=\recurselevel", of course).
>
> How would that work?
Remind me of a more-than-a-decade-old discussion on the mailing list, summarized here:
https://adityam.github.io/context-blog/post/tex-programming/
> Also, \HL doesn’t work at the end, and the second line of the error
> message makes no sense:
I find that in such cases, using Lua (CLD) is the simplest solution
Aditya
[-- 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: recursion in a table
2022-05-02 0:30 ` Aditya Mahajan via ntg-context
@ 2022-05-02 7:16 ` Hans Hagen via ntg-context
0 siblings, 0 replies; 3+ messages in thread
From: Hans Hagen via ntg-context @ 2022-05-02 7:16 UTC (permalink / raw)
To: Aditya Mahajan via ntg-context; +Cc: Hans Hagen
On 5/2/2022 2:30 AM, Aditya Mahajan via ntg-context wrote:
> \expanded{\NC \recurselevel \noexpand\NC ... }
There is no need for \noexpand before \NC. Even \NR is protected. In
MKIV there are some more sensitive ones like \FR but in LMTX these are
defined as \noaligned which permits them being protected too (the
engine's alignments scanners have some lookahead properties that cna
otherwise interfere).
\starttabulate[||]
\NC \infofont\meaningasis \NC \NC \NR
\NC \infofont\meaningasis \NR \NC \NR
\NC \infofont\meaningasis \HL \NC \NR
\NC \infofont\meaningasis \FL \NC \NR
\stoptabulate
> Remind me of a more-than-a-decade-old discussion on the mailing list, summarized here:
>
> https://adityam.github.io/context-blog/post/tex-programming/
>
>> Also, \HL doesn’t work at the end, and the second line of the error
>> message makes no sense:
As you're not afraid of low level code:
\starttext
\starttabulate[|r|c|]
\NC $T$ \NC what \NC \NR
\HL
\expandedloop 0 359 45 {
\NC \number\currentloopiterator ˚ \NC \NC \NR
}
\stoptabulate
\stoptext
So, you can play with:
\expandedloop
\unexpandedloop
\localcontrolledloop
\quitloop
\currentloopiterator
\currentloopnesting
\lastloopiterator
if you want a challenge for a new blog post.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-02 7:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-01 18:43 recursion in a table Henning Hraban Ramm via ntg-context
2022-05-02 0:30 ` Aditya Mahajan via ntg-context
2022-05-02 7:16 ` Hans Hagen via ntg-context
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).