recursion in a table
Hi, I was playing with the example from https://wiki.contextgarden.net/Scaling_Rotating_Mirroring_Clipping#Location_... 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
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_... 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
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 -----------------------------------------------------------------
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Henning Hraban Ramm