ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Benjamin Buchmuller via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Benjamin Buchmuller <benjamin.buchmuller@gmail.com>
Subject: Re: Title for tabulate
Date: Tue, 14 Dec 2021 18:16:46 +0100	[thread overview]
Message-ID: <9E746D45-83E5-4467-BA12-099618920E54@gmail.com> (raw)

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
___________________________________________________________________________________

             reply	other threads:[~2021-12-14 17:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 17:16 Benjamin Buchmuller via ntg-context [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2021-11-28  8:15 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9E746D45-83E5-4467-BA12-099618920E54@gmail.com \
    --to=ntg-context@ntg.nl \
    --cc=benjamin.buchmuller@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).