* Title for tabulate @ 2021-11-28 8:15 Denis Maier via ntg-context 2021-11-28 11:40 ` Hans Hagen via ntg-context 0 siblings, 1 reply; 11+ messages in thread From: Denis Maier via ntg-context @ 2021-11-28 8:15 UTC (permalink / raw) To: ntg-context; +Cc: denis.maier [-- Attachment #1.1: Type: text/plain, Size: 1086 bytes --] Hi, when trying out different options for my last question regarding column spans I've tried out the the option regarding titles for the tabulate environment. Consider this example (adapted from the wiki): %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \setuppapersize[A6] \starttext \setuptabulate [ header=text, split=yes, title={Fenchurch St. Paul}, ] \starttabulate[|p|p|] \dorecurse{6}{ \NC Bells: \NC Tin tan din dan bim bam bom bo \NC\NR \HL \NC Name: \NC Tailor Paul \NC \NR \HL } \stoptabulate \stoptext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A couple of questions : - Is it possible to have the title be typeset only once? I.e., it should not repeat on each page. - How do you change the alignment of the title? (There's an align key, but that does change the alignment of the entries. Not of the title. There are headstyle and headcolor, but nothing about alignment. (\setupalign[middle] in headstyle doesn't do anything.) - How can you add bit more space after the title? Best, Denis [-- Attachment #1.2: Type: text/html, Size: 5016 bytes --] [-- 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] 11+ messages in thread
* Re: Title for tabulate 2021-11-28 8:15 Title for tabulate Denis Maier via ntg-context @ 2021-11-28 11:40 ` Hans Hagen via ntg-context 2021-11-28 12:22 ` Denis Maier via ntg-context 0 siblings, 1 reply; 11+ messages in thread From: Hans Hagen via ntg-context @ 2021-11-28 11:40 UTC (permalink / raw) To: Denis Maier via ntg-context; +Cc: Hans Hagen On 11/28/2021 9:15 AM, Denis Maier via ntg-context wrote: > A couple of questions : > > - Is it possible to have the title be typeset only once? I.e., it should > not repeat on each page. why not just use \subsubsubject{xxxxxxxx} ----------------------------------------------------------------- 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] 11+ messages in thread
* Re: Title for tabulate 2021-11-28 11:40 ` Hans Hagen via ntg-context @ 2021-11-28 12:22 ` Denis Maier via ntg-context 2021-11-28 13:26 ` Hans Hagen via ntg-context 0 siblings, 1 reply; 11+ messages in thread From: Denis Maier via ntg-context @ 2021-11-28 12:22 UTC (permalink / raw) To: ntg-context; +Cc: denis.maier > -----Ursprüngliche Nachricht----- > Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Hans Hagen > via ntg-context > Gesendet: Sonntag, 28. November 2021 12:40 > An: Denis Maier via ntg-context <ntg-context@ntg.nl> > Cc: Hans Hagen <j.hagen@xs4all.nl> > Betreff: Re: [NTG-context] Title for tabulate > > On 11/28/2021 9:15 AM, Denis Maier via ntg-context wrote: > > > A couple of questions : > > > > - Is it possible to have the title be typeset only once? I.e., it > > should not repeat on each page. > why not just use > > \subsubsubject{xxxxxxxx} That sounds like a neat solution. I'll investigate. Does that play nicely with structurelevels? I mean, let's say I'm somewhere higher, e.g. on chapter, the next level would be section. If I now invoke this subsubsubject manually, does that break the levels structure? Best, Denis > > ----------------------------------------------------------------- > 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 > __________________________________________________________ > _________________________ ___________________________________________________________________________________ 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] 11+ messages in thread
* Re: Title for tabulate 2021-11-28 12:22 ` Denis Maier via ntg-context @ 2021-11-28 13:26 ` Hans Hagen via ntg-context 2021-11-30 11:41 ` Denis Maier via ntg-context 0 siblings, 1 reply; 11+ messages in thread From: Hans Hagen via ntg-context @ 2021-11-28 13:26 UTC (permalink / raw) To: denis.maier, ntg-context; +Cc: Hans Hagen On 11/28/2021 1:22 PM, denis.maier@unibe.ch wrote: > >> -----Ursprüngliche Nachricht----- >> Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Hans Hagen >> via ntg-context >> Gesendet: Sonntag, 28. November 2021 12:40 >> An: Denis Maier via ntg-context <ntg-context@ntg.nl> >> Cc: Hans Hagen <j.hagen@xs4all.nl> >> Betreff: Re: [NTG-context] Title for tabulate >> >> On 11/28/2021 9:15 AM, Denis Maier via ntg-context wrote: >> >>> A couple of questions : >>> >>> - Is it possible to have the title be typeset only once? I.e., it >>> should not repeat on each page. >> why not just use >> >> \subsubsubject{xxxxxxxx} > > That sounds like a neat solution. I'll investigate. > Does that play nicely with structurelevels? I mean, let's say I'm somewhere higher, e.g. on chapter, the next level would be section. If I now invoke this subsubsubject manually, does that break the levels structure? often it's ok as subjects are unnumbered but you can play safe: \definehead[myownhead][subsubsubsubsubsubject] \myownhead you can then always go lower (more sub) if needed and using dedicated head commands is also cleaner 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] 11+ messages in thread
* Re: Title for tabulate 2021-11-28 13:26 ` Hans Hagen via ntg-context @ 2021-11-30 11:41 ` Denis Maier via ntg-context 0 siblings, 0 replies; 11+ messages in thread From: Denis Maier via ntg-context @ 2021-11-30 11:41 UTC (permalink / raw) To: j.hagen, ntg-context; +Cc: denis.maier > -----Ursprüngliche Nachricht----- > Von: Hans Hagen <j.hagen@xs4all.nl> > Gesendet: Sonntag, 28. November 2021 14:26 > An: Maier, Denis Christian (UB) <denis.maier@unibe.ch>; ntg- > context@ntg.nl > Betreff: Re: AW: [NTG-context] Title for tabulate > > On 11/28/2021 1:22 PM, denis.maier@unibe.ch wrote: > > > >> -----Ursprüngliche Nachricht----- > >> Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Hans > >> Hagen via ntg-context > >> Gesendet: Sonntag, 28. November 2021 12:40 > >> An: Denis Maier via ntg-context <ntg-context@ntg.nl> > >> Cc: Hans Hagen <j.hagen@xs4all.nl> > >> Betreff: Re: [NTG-context] Title for tabulate > >> > >> On 11/28/2021 9:15 AM, Denis Maier via ntg-context wrote: > >> > >>> A couple of questions : > >>> > >>> - Is it possible to have the title be typeset only once? I.e., it > >>> should not repeat on each page. > >> why not just use > >> > >> \subsubsubject{xxxxxxxx} > > > > That sounds like a neat solution. I'll investigate. > > Does that play nicely with structurelevels? I mean, let's say I'm somewhere > higher, e.g. on chapter, the next level would be section. If I now invoke this > subsubsubject manually, does that break the levels structure? > often it's ok as subjects are unnumbered but you can play safe: > > \definehead[myownhead][subsubsubsubsubsubject] > > \myownhead > > you can then always go lower (more sub) if needed > > and using dedicated head commands is also cleaner Ok, that's what I've done now, and doesn't seem to create any problems. Thanks for pointing me in the right direction. Denis ___________________________________________________________________________________ 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] 11+ messages in thread
* Re: Title for tabulate @ 2021-12-14 17:16 Benjamin Buchmuller via ntg-context 2021-12-14 18:16 ` Hans Hagen via ntg-context 0 siblings, 1 reply; 11+ messages in thread From: Benjamin Buchmuller via ntg-context @ 2021-12-14 17:16 UTC (permalink / raw) To: mailing list for ConTeXt users; +Cc: Benjamin Buchmuller Hi! I'd like to follow up on a problem that Denis came across recently with the titles argument in tabulate. (It's more a solution than a question, but any hints to improve the answer are welcome.) I wanted to use this argument for an easy specification of, well, a title for a "recipe". The advantage is that all information is held together and it's easy to use for people who are not (too) familiar with ConTeXt. So, in one file I can define all styles (which the end-user would not need to see): \definetabulate[recipe][|l|l|p|l|] \setuptabulate [recipe] [ bodyfont=small, distance=medium, before={\blank[back, small]}, header=text, headstyle=\bi, % this formats the "\BC" cells headcolor=red, % this formats the "\BC" cells ] \starttext And then use: \startrecipe[title={Whatever mixture 1}] \FL \NC Absolute \BC Stock \NC Ingredient \NC Final \NR \HL \NC 1 \NR \LL \stoprecipe \startrecipe[title={Whatever mixture 2}] \FL \BC Absolute \BC Stock \BC Ingredient \BC Final \NR \HL \NC 1 \NR \LL \stoprecipe \stoptext etc. However, I cannot change the way the title is styled (or spaced from the table) unless I do "title={\bi Some text.}". However, blank commands are also stripped off at this place. (I also don't get a clue from the source if there is any argument to spike-in some formatting.) So, if there is no easy way to access this one, we can work around: \definetabulate[recipetab][|l|l|p|l|] \setuptabulate [recipetab] [ bodyfont=small, distance=medium, before={\blank[back, small]}, % header=text, % THIS MUST NOT BE "text" headstyle=bold, headcolor=red, ] \define\startrecipe{\dodoubleempty\dostartrecipe} \long\def\dostartrecipe[#1][#2]#3\stoprecipe{% \iffirstargument {\bi #1}\blank[medium] \fi \ifsecondargument \startrecipetab[#2] #3 \stoprecipetab \else \startrecipetab #3 \stoprecipetab \fi } \startrecipe[Head 1] \FL \BC Absolute \BC Stock \BC Ingredient \BC Final \NR \HL \NC 1 \NR \LL \stoprecipe \startrecipe[Head 2][headcolor=blue] % pass on arguments to tabulate \FL \BC Absolute \BC Stock \BC Ingredient \BC Final \NR \HL \NC 1 \NR \LL \stoprecipe Small question though: Is there a ConTeXt way to "\long\def" or a simple way ("user interface") to filter a list of arguments for a specific key=val pair, e.g. to make a single optional argument with headertitle={Some header.}? Best Benjamin ___________________________________________________________________________________ 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] 11+ messages in thread
* Re: Title for tabulate 2021-12-14 17:16 Benjamin Buchmuller via ntg-context @ 2021-12-14 18:16 ` Hans Hagen via ntg-context 2021-12-16 10:39 ` Benjamin Buchmuller via ntg-context 0 siblings, 1 reply; 11+ messages in thread From: Hans Hagen via ntg-context @ 2021-12-14 18:16 UTC (permalink / raw) To: mailing list for ConTeXt users; +Cc: Hans Hagen, Benjamin Buchmuller On 12/14/2021 6:16 PM, Benjamin Buchmuller via ntg-context wrote: > Hi! > > I'd like to follow up on a problem that Denis came across recently with the titles argument in tabulate. (It's more a solution than a question, but any hints to improve the answer are welcome.) I wanted to use this argument for an easy specification of, well, a title for a "recipe". The advantage is that all information is held together and it's easy to use for people who are not (too) familiar with ConTeXt. > > So, in one file I can define all styles (which the end-user would not need to see): > > \definetabulate[recipe][|l|l|p|l|] > > \setuptabulate > [recipe] > [ > bodyfont=small, > distance=medium, > before={\blank[back, small]}, > header=text, > headstyle=\bi, % this formats the "\BC" cells > headcolor=red, % this formats the "\BC" cells > ] > > > \starttext > > And then use: > > \startrecipe[title={Whatever mixture 1}] > \FL > \NC Absolute \BC Stock \NC Ingredient \NC Final \NR > \HL > \NC 1 \NR > \LL > \stoprecipe > > \startrecipe[title={Whatever mixture 2}] > \FL > \BC Absolute \BC Stock \BC Ingredient \BC Final \NR > \HL > \NC 1 \NR > \LL > \stoprecipe > > \stoptext > > etc. > > However, I cannot change the way the title is styled (or spaced from the table) unless I do "title={\bi Some text.}". However, blank commands are also stripped off at this place. (I also don't get a clue from the source if there is any argument to spike-in some formatting.) > > So, if there is no easy way to access this one, we can work around: > > \definetabulate[recipetab][|l|l|p|l|] > > \setuptabulate > [recipetab] > [ > bodyfont=small, > distance=medium, > before={\blank[back, small]}, > % header=text, % THIS MUST NOT BE "text" > headstyle=bold, > headcolor=red, > ] > > \define\startrecipe{\dodoubleempty\dostartrecipe} > > \long\def\dostartrecipe[#1][#2]#3\stoprecipe{% > \iffirstargument > {\bi #1}\blank[medium] > \fi > \ifsecondargument > \startrecipetab[#2] > #3 > \stoprecipetab > \else > \startrecipetab > #3 > \stoprecipetab > \fi > } > > \startrecipe[Head 1] > \FL > \BC Absolute \BC Stock \BC Ingredient \BC Final \NR > \HL > \NC 1 \NR > \LL > \stoprecipe > > \startrecipe[Head 2][headcolor=blue] % pass on arguments to tabulate > \FL > \BC Absolute \BC Stock \BC Ingredient \BC Final \NR > \HL > \NC 1 \NR > \LL > \stoprecipe > > Small question though: Is there a ConTeXt way to "\long\def" or a simple way ("user interface") to filter a list of arguments for a specific key=val pair, e.g. to make a single optional argument with headertitle={Some header.}? context has no (need for) \long ... all is long (i mever saw a reason for using it) (1) use a proper head: \definehead[RecipeHead][subsubsubsubsubsubject] \setuphead [RecipeHead][style=bolditalic,after={\blank[medium]}] \definetabulate[recipetab][|l|l|p|l|] \setuptabulate [recipetab] [bodyfont=small, distance=medium, before={\blank[back, small]}, headstyle=bold, headcolor=red] here's a one-step lmtx solution: \let\stoprecipe\relax \tolerant\protected\def\startrecipe[#1]#*[#2]#3\stoprecipe {\ifcstok{#1}\emptytoks\else \RecipeHead{#1} \fi \ifcstok{#2}\emptytoks \startrecipetab#3\stoprecipetab \else \startrecipetab[#2]#3\stoprecipetab \fi} or just \tolerant\protected\def\startrecipe[#1]#*[#2]#3\stoprecipe {\ifempty{#1}\else \RecipeHead{#1} \fi \ifempty{#2}% \startrecipetab#3\stoprecipetab \else \startrecipetab[#2]#3\stoprecipetab \fi} and here's one that does what you ask (in the core i'd try to avoid grabbing too much arguments and if real core we'd make sure dummy parameters don;t interfere): \tolerant\protected\def\startrecipe[#1]#2\stoprecipe {\ifempty{#1}% \startrecipetab#2\stoprecipetab \orelse\ifhastok={#1}% \getdummyparameters[headtitle=,#1] \ifempty{\dummyparameter{headtitle}}\else \normalexpanded{\RecipeHead{\dummyparameter{headtitle}}} \fi \startrecipetab[#1]#2\stoprecipetab \else \RecipeHead{#1} \startrecipetab#2\stoprecipetab \fi} \startrecipe[headtitle={Head 3},headcolor=blue] % pass on arguments to tabulate \FL \BC Absolute \BC Stock \BC Ingredient \BC Final \NR \HL \NC 1 \NR \LL \stoprecipe Here's a variant: \def\theparameter#1#2% {\beginlocalcontrol \begingroup \getdummyparameters[#1=,#2]% \normalexpanded{\endgroup\endlocalcontrol\dummyparameter{#1}}} \tolerant\protected\def\startrecipe[#1]#2\stoprecipe {\ifempty{#1}% \startrecipetab#2\stoprecipetab \orelse\ifhastok={#1}% \edef\MyHeadTitle{\theparameter{headtitle}{#1}}% \ifempty\MyHeadTitle\else \normalexpanded{\RecipeHead{\MyHeadTitle}} \fi \startrecipetab[#1]#2\stoprecipetab \else \RecipeHead{#1} \startrecipetab#2\stoprecipetab \fi} or just \tolerant\protected\def\startrecipe[#1]#2\stoprecipe {\ifempty{#1}% \startrecipetab#2\stoprecipetab \else \edef\MyHeadTitle{\theparameter{headtitle}{#1}}% \ifempty\MyHeadTitle\else \normalexpanded{\RecipeHead{\MyHeadTitle}} \fi \startrecipetab[#1]#2\stoprecipetab \fi} or \tolerant\protected\def\startrecipe[#1]#2\stoprecipe {\ifempty{#1}% \startrecipetab#2\stoprecipetab \else \ifcstok{\theparameter{headtitle}{#1}}\emptytoks\else \normalexpanded{\RecipeHead{\theparameter{headtitle}{#1}}} \fi \startrecipetab[#1]#2\stoprecipetab \fi} or ... or ... or ... just play with it a bit till you have something that looks nice in code too 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] 11+ messages in thread
* Re: Title for tabulate 2021-12-14 18:16 ` Hans Hagen via ntg-context @ 2021-12-16 10:39 ` Benjamin Buchmuller via ntg-context 2021-12-16 11:46 ` Hans Hagen via ntg-context 0 siblings, 1 reply; 11+ messages in thread From: Benjamin Buchmuller via ntg-context @ 2021-12-16 10:39 UTC (permalink / raw) To: Hans Hagen; +Cc: Benjamin Buchmuller, mailing list for ConTeXt users Thanks again, Hans, for all the different approaches, very instructive! However, after playing around a bit, I do have a question that I can't work out: \getdummyparameters[headtitle=,#1] \ifempty{\dummyparameter{headtitle}} will never be true? See below in context: > On Dec 14, 2021, at 19:16, Hans Hagen <j.hagen@xs4all.nl> wrote: > > On 12/14/2021 6:16 PM, Benjamin Buchmuller via ntg-context wrote: >> Hi! >> I'd like to follow up on a problem that Denis came across recently with the titles argument in tabulate. (It's more a solution than a question, but any hints to improve the answer are welcome.) I wanted to use this argument for an easy specification of, well, a title for a "recipe". The advantage is that all information is held together and it's easy to use for people who are not (too) familiar with ConTeXt. >> So, in one file I can define all styles (which the end-user would not need to see): >> \definetabulate[recipe][|l|l|p|l|] >> \setuptabulate >> [recipe] >> [ >> bodyfont=small, >> distance=medium, >> before={\blank[back, small]}, >> header=text, >> headstyle=\bi, % this formats the "\BC" cells >> headcolor=red, % this formats the "\BC" cells >> ] >> \starttext >> And then use: >> \startrecipe[title={Whatever mixture 1}] >> \FL >> \NC Absolute \BC Stock \NC Ingredient \NC Final \NR >> \HL >> \NC 1 \NR >> \LL >> \stoprecipe >> \startrecipe[title={Whatever mixture 2}] >> \FL >> \BC Absolute \BC Stock \BC Ingredient \BC Final \NR >> \HL >> \NC 1 \NR >> \LL >> \stoprecipe >> \stoptext >> etc. >> However, I cannot change the way the title is styled (or spaced from the table) unless I do "title={\bi Some text.}". However, blank commands are also stripped off at this place. (I also don't get a clue from the source if there is any argument to spike-in some formatting.) >> So, if there is no easy way to access this one, we can work around: >> \definetabulate[recipetab][|l|l|p|l|] >> \setuptabulate >> [recipetab] >> [ >> bodyfont=small, >> distance=medium, >> before={\blank[back, small]}, >> % header=text, % THIS MUST NOT BE "text" >> headstyle=bold, >> headcolor=red, >> ] >> \define\startrecipe{\dodoubleempty\dostartrecipe} >> \long\def\dostartrecipe[#1][#2]#3\stoprecipe{% >> \iffirstargument >> {\bi #1}\blank[medium] >> \fi >> \ifsecondargument >> \startrecipetab[#2] >> #3 >> \stoprecipetab >> \else >> \startrecipetab >> #3 >> \stoprecipetab >> \fi >> } >> \startrecipe[Head 1] >> \FL >> \BC Absolute \BC Stock \BC Ingredient \BC Final \NR >> \HL >> \NC 1 \NR >> \LL >> \stoprecipe >> \startrecipe[Head 2][headcolor=blue] % pass on arguments to tabulate >> \FL >> \BC Absolute \BC Stock \BC Ingredient \BC Final \NR >> \HL >> \NC 1 \NR >> \LL >> \stoprecipe >> Small question though: Is there a ConTeXt way to "\long\def" or a simple way ("user interface") to filter a list of arguments for a specific key=val pair, e.g. to make a single optional argument with headertitle={Some header.}? > context has no (need for) \long ... all is long (i mever saw a reason for using it) > > (1) use a proper head: > > \definehead[RecipeHead][subsubsubsubsubsubject] > \setuphead [RecipeHead][style=bolditalic,after={\blank[medium]}] > > \definetabulate[recipetab][|l|l|p|l|] > > \setuptabulate > [recipetab] > [bodyfont=small, > distance=medium, > before={\blank[back, small]}, > headstyle=bold, > headcolor=red] > > here's a one-step lmtx solution: > > \let\stoprecipe\relax > > \tolerant\protected\def\startrecipe[#1]#*[#2]#3\stoprecipe > {\ifcstok{#1}\emptytoks\else > \RecipeHead{#1} > \fi > \ifcstok{#2}\emptytoks > \startrecipetab#3\stoprecipetab > \else > \startrecipetab[#2]#3\stoprecipetab > \fi} > > or just > > \tolerant\protected\def\startrecipe[#1]#*[#2]#3\stoprecipe > {\ifempty{#1}\else > \RecipeHead{#1} > \fi > \ifempty{#2}% > \startrecipetab#3\stoprecipetab > \else > \startrecipetab[#2]#3\stoprecipetab > \fi} > > > and here's one that does what you ask (in the core i'd try to avoid grabbing too much arguments and if real core we'd make sure dummy parameters don;t interfere): > > \tolerant\protected\def\startrecipe[#1]#2\stoprecipe > {\ifempty{#1}% > \startrecipetab#2\stoprecipetab > \orelse\ifhastok={#1}% > \getdummyparameters[headtitle=,#1] > \ifempty{\dummyparameter{headtitle}}\else > \normalexpanded{\RecipeHead{\dummyparameter{headtitle}}} > \fi > \startrecipetab[#1]#2\stoprecipetab > \else > \RecipeHead{#1} > \startrecipetab#2\stoprecipetab > \fi} > > \startrecipe[headtitle={Head 3},headcolor=blue] % pass on arguments to tabulate > \FL > \BC Absolute \BC Stock \BC Ingredient \BC Final \NR > \HL > \NC 1 \NR > \LL > \stoprecipe Consider: \startrecipe[headcolor=darkyellow] % pass on arguments to tabulate \FL \BC Absolute \BC Stock \BC Ingredient \BC Final \NR \HL \NC 1 \NR \LL \stoprecipe This leaves a blank header line instead of none. Complete example with XXXXX control: \definehead[RecipeHead][subsubsubsubsubsubject] \setuphead [RecipeHead][style=bolditalic,after={\blank[medium]}] \definetabulate[recipetab][|l|l|p|l|] \setuptabulate [recipetab] [bodyfont=small, distance=medium, before={\blank[back, small]}, headstyle=bold, headcolor=red] \let\stoprecipe\relax \tolerant\protected\def\startrecipe[#1]#2\stoprecipe {\ifempty{#1}% \startrecipetab#2\stoprecipetab \orelse\ifhastok={#1}% \getdummyparameters[headtitle=,#1] % this should make headtitle by default empty, but doesn't? \ifempty{\dummyparameter{headtitle}}XXXXX\else \normalexpanded{\RecipeHead{\dummyparameter{headtitle}YYYY}} \fi \startrecipetab[#1]#2\stoprecipetab \else \RecipeHead{#1} \startrecipetab#2\stoprecipetab \fi} some text \startrecipe[headtitle={Head 3},headcolor=blue] % pass on arguments to tabulate \FL \BC Absolute \BC Stock \BC Ingredient \BC Final \NR \HL \NC 1 \NR \LL \stoprecipe some text \startrecipe[headcolor=darkyellow] % pass on arguments to tabulate \FL \BC Absolute \BC Stock \BC Ingredient \BC Final \NR \HL \NC 1 \NR \LL \stoprecipe > > Here's a variant: > > \def\theparameter#1#2% > {\beginlocalcontrol > \begingroup > \getdummyparameters[#1=,#2]% > \normalexpanded{\endgroup\endlocalcontrol\dummyparameter{#1}}} > > \tolerant\protected\def\startrecipe[#1]#2\stoprecipe > {\ifempty{#1}% > \startrecipetab#2\stoprecipetab > \orelse\ifhastok={#1}% > \edef\MyHeadTitle{\theparameter{headtitle}{#1}}% > \ifempty\MyHeadTitle\else > \normalexpanded{\RecipeHead{\MyHeadTitle}} > \fi > \startrecipetab[#1]#2\stoprecipetab > \else > \RecipeHead{#1} > \startrecipetab#2\stoprecipetab > \fi} > > or just > > \tolerant\protected\def\startrecipe[#1]#2\stoprecipe > {\ifempty{#1}% > \startrecipetab#2\stoprecipetab > \else > \edef\MyHeadTitle{\theparameter{headtitle}{#1}}% > \ifempty\MyHeadTitle\else > \normalexpanded{\RecipeHead{\MyHeadTitle}} > \fi > \startrecipetab[#1]#2\stoprecipetab > \fi} > > or > > \tolerant\protected\def\startrecipe[#1]#2\stoprecipe > {\ifempty{#1}% > \startrecipetab#2\stoprecipetab > \else > \ifcstok{\theparameter{headtitle}{#1}}\emptytoks\else > \normalexpanded{\RecipeHead{\theparameter{headtitle}{#1}}} > \fi > \startrecipetab[#1]#2\stoprecipetab > \fi} > > or ... or ... or ... > > just play with it a bit till you have something that looks nice in code too > > 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] 11+ messages in thread
* Re: Title for tabulate 2021-12-16 10:39 ` Benjamin Buchmuller via ntg-context @ 2021-12-16 11:46 ` Hans Hagen via ntg-context 2021-12-17 7:25 ` Benjamin Buchmuller via ntg-context 0 siblings, 1 reply; 11+ messages in thread From: Hans Hagen via ntg-context @ 2021-12-16 11:46 UTC (permalink / raw) To: Benjamin Buchmuller; +Cc: Hans Hagen, mailing list for ConTeXt users On 12/16/2021 11:39 AM, Benjamin Buchmuller wrote: > Thanks again, Hans, for all the different approaches, very instructive! > > However, after playing around a bit, I do have a question that I can't work out: > > \getdummyparameters[headtitle=,#1] > > \ifempty{\dummyparameter{headtitle}} can you try \ifcstok{\dummyparameter{headtitle}}\emptytoks instead ----------------------------------------------------------------- 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] 11+ messages in thread
* Re: Title for tabulate 2021-12-16 11:46 ` Hans Hagen via ntg-context @ 2021-12-17 7:25 ` Benjamin Buchmuller via ntg-context 2021-12-17 8:24 ` Hans Hagen via ntg-context 0 siblings, 1 reply; 11+ messages in thread From: Benjamin Buchmuller via ntg-context @ 2021-12-17 7:25 UTC (permalink / raw) To: Hans Hagen; +Cc: Benjamin Buchmuller, mailing list for ConTeXt users Yes, this works! Thanks! I'll try to add a section on the Wiki. Is there a reason why the second approach works while the other doesn't? > On Dec 16, 2021, at 12:46, Hans Hagen <j.hagen@xs4all.nl> wrote: > > On 12/16/2021 11:39 AM, Benjamin Buchmuller wrote: >> Thanks again, Hans, for all the different approaches, very instructive! >> However, after playing around a bit, I do have a question that I can't work out: >> \getdummyparameters[headtitle=,#1] >> \ifempty{\dummyparameter{headtitle}} > can you try > > \ifcstok{\dummyparameter{headtitle}}\emptytoks > > instead > > ----------------------------------------------------------------- > 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] 11+ messages in thread
* Re: Title for tabulate 2021-12-17 7:25 ` Benjamin Buchmuller via ntg-context @ 2021-12-17 8:24 ` Hans Hagen via ntg-context 0 siblings, 0 replies; 11+ messages in thread From: Hans Hagen via ntg-context @ 2021-12-17 8:24 UTC (permalink / raw) To: Benjamin Buchmuller; +Cc: Hans Hagen, mailing list for ConTeXt users On 12/17/2021 8:25 AM, Benjamin Buchmuller wrote: > Yes, this works! Thanks! > > I'll try to add a section on the Wiki. Is there a reason why the second approach works while the other doesn't? expansion etc so just stick to what works 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] 11+ messages in thread
end of thread, other threads:[~2021-12-17 8:24 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-11-28 8:15 Title for tabulate Denis Maier via ntg-context 2021-11-28 11:40 ` Hans Hagen via ntg-context 2021-11-28 12:22 ` Denis Maier via ntg-context 2021-11-28 13:26 ` Hans Hagen via ntg-context 2021-11-30 11:41 ` Denis Maier via ntg-context 2021-12-14 17:16 Benjamin Buchmuller via ntg-context 2021-12-14 18:16 ` Hans Hagen via ntg-context 2021-12-16 10:39 ` Benjamin Buchmuller via ntg-context 2021-12-16 11:46 ` Hans Hagen via ntg-context 2021-12-17 7:25 ` Benjamin Buchmuller via ntg-context 2021-12-17 8:24 ` 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).