ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jeong Dal <haksan@me.com>
To: "list ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl
	ntg-context@ntg.nl" <ntg-context@ntg.nl>
Subject: MetaFun: how to check the number of arguments
Date: Tue, 15 Jan 2019 06:44:04 +0900	[thread overview]
Message-ID: <46C8F3BF-728C-42E7-8048-487027F825BD@me.com> (raw)
In-Reply-To: <mailman.1.1547463601.11666.ntg-context@ntg.nl>

Dear all,

In the following sample, it draws squares with label which is given.

I’d like to know how to check the number of elements in the second argument?
If it is 0, then I just draw grids only.

Thank you for reading.
Best regards,

Dalyoung

********
\startbuffer[defs]
def drawGridF (expr nb) (text s) = 
	p := unitsquare scaled wu;
	n:= 0;
	for m = s:
		i:= n mod nb;
		j:= n div nb;
		pic := image (draw p; label(textext(m), center p); );
		draw pic shifted (i*wu, j*wu);
		n:= n+ 1;
	endfor;
enddef;
\stopbuffer

\startbuffer[3x3b]
wu := \MPvar{width};
drawGridF (3)  (1,2,3,0,1, 1,4,5,8);
\stopbuffer

\starttext
\setupMPvariables[width=30pt]
\processMPbuffer[defs,3x3b]
\stoptext

> 2019. 1. 14. 오후 8:00, ntg-context-request@ntg.nl 작성:
> 
> Send ntg-context mailing list submissions to
> 	ntg-context@ntg.nl
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://mailman.ntg.nl/mailman/listinfo/ntg-context
> or, via email, send a message with subject or body 'help' to
> 	ntg-context-request@ntg.nl
> 
> You can reach the person managing the list at
> 	ntg-context-owner@ntg.nl
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of ntg-context digest..."
> 
> 
> Today's Topics:
> 
>   1. Re: Manipulating the left blank page when chapter starts on
>      the right page (Wolfgang Schuster)
>   2. Re: Footnotes in float combinations missing in output
>      (Wolfgang Schuster)
>   3. Re: Manipulating the left blank page when chapter starts on
>      the right page (Jan U. Hasecke)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Sun, 13 Jan 2019 16:56:40 +0100
> From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
> To: mailing list for ConTeXt users <ntg-context@ntg.nl>, "Jan U.
> 	Hasecke" <juh+ntg-context@mailbox.org>
> Subject: Re: [NTG-context] Manipulating the left blank page when
> 	chapter starts on the right page
> Message-ID: <cad2dcf9-ce2c-203a-88c2-41315bd5f825@gmail.com>
> Content-Type: text/plain; charset=utf-8; format=flowed
> 
> Jan U. Hasecke schrieb am 12.01.19 um 22:08:
>> Hi Aditya,
>> 
>> Am 12.01.19 um 20:11 schrieb Aditya Mahajan:
>>> On Sat, 12 Jan 2019, Jan U. Hasecke wrote:
>>> 
>>>> Hi all,
>>>> 
>>>> in my document \startchapter and \starttitle starts a new chapter on the
>>>> right (odd) page. So sometimes, there is a blank even page just before a
>>>> new chapter.
>>>> 
>>>> I would like to manipulate this blank even page.
>>>> 
>>>> There are several things I would like to do, eg. having no headers and
>>>> footers, setting the background color to a named color, placing an image
>>>> or some graphics on the page.
>>>> 
>>>> Is there a way to define such a page, name it and call it in
>>>> \startchapter so that it is placed on the left side.
>>> See https://tex.stackexchange.com/q/457428/323
>> Thanks a lot, but I wasn't looking for a way to just delete page numbers
>> but to style the empty page in arbitrary ways.
>> 
>> Maybe it is better to do this manually.
>> 
>> I would let chapter open on even pages too and just insert a styled page
>> by hand.
> 
> Here is a example which shows how you can change the background color
> of a empty page before the chapter title.
> 
> \setuppagenumbering
>   [alternative=doublesided]
> 
> \startsetups [chapter:before]
>   \doifoddpageelse
>     {}
>     {\pushbackground[page]
>      \setupbackgrounds[page][background=color,backgroundcolor=black]
>      \page[empty,right]
>      \popbackground}
> \stopsetups
> 
> \setuphead
>   [chapter]
>   [page=yes,
>    before=\directsetup{chapter:before}]
> 
> \starttext
> 
> \startchapter[title={Knuth}]
> \dorecurse{10}{\samplefile{knuth}}
> \stopchapter
> 
> \startchapter[title={Zapf}]
> \dorecurse{10}{\samplefile{zapf}}
> \stopchapter
> 
> \startchapter[title={Ward}]
> \dorecurse{10}{\samplefile{ward}}
> \stopchapter
> 
> \stoptext
> 
> Wolfgang
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Sun, 13 Jan 2019 21:06:42 +0100
> From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
> To: mailing list for ConTeXt users <ntg-context@ntg.nl>, Lars
> 	<axteffekt@gmail.com>
> Subject: Re: [NTG-context] Footnotes in float combinations missing in
> 	output
> Message-ID: <e14cd1c5-400e-14bf-d8bf-a47ef28b6550@gmail.com>
> Content-Type: text/plain; charset=utf-8; format=flowed
> 
> Lars schrieb am 09.01.19 um 23:01:
>> Hi there, hi Hans,
>> 
>> I just want to let you know that footnotes insterted in 
>> float-combinations don't get rendered properly, i. e. only the last 
>> footnote is placed in the output. MWE:
>> 
>> \starttext
>>   \startplacefigure[title={OuterCap\footnote{Outer footnote}}]
>> 
>>     \startfloatcombination[nx=3]
>> \placefigure{Fnote1\footnote{Hello}}{\externalfigure[cow][width={.2\textwidth}]}
>> \placefigure{Fnote2\footnote{small}}{\externalfigure[cow][width={.2\textwidth}]}
>> \placefigure{Fnote3\footnote{world}}{\externalfigure[cow][width={.2\textwidth}]}
>>     \stopfloatcombination
>> 
>>   \stopplacefigure
>> \stoptext
> 
> Not very nice but the following works. You would have less problems with 
> local footnotes which are placed in the float block.
> 
> \starttext
> 
> \startpostponingnotes
>   \startplacefigure[title={...}]
>     ...
>   \stopplacefigure
> \stoppostponingnotes
> 
> \stoptext
> 
> Wolfgang
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Mon, 14 Jan 2019 08:39:45 +0100
> From: "Jan U. Hasecke" <juh+ntg-context@mailbox.org>
> To: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>, mailing
> 	list for ConTeXt users <ntg-context@ntg.nl>
> Subject: Re: [NTG-context] Manipulating the left blank page when
> 	chapter starts on the right page
> Message-ID: <d88401b5-1ada-6f97-ee9b-f0e8fe83cb45@mailbox.org>
> Content-Type: text/plain; charset=utf-8
> 
> 
> Am 13.01.19 um 16:56 schrieb Wolfgang Schuster:
> 
>> Here is a example which shows how you can change the background color
>> of a empty page before the chapter title.
>> 
>> \setuppagenumbering
>>   [alternative=doublesided]
>> 
>> \startsetups [chapter:before]
>>   \doifoddpageelse
>>     {}
>>     {\pushbackground[page]
>>      \setupbackgrounds[page][background=color,backgroundcolor=black]
>>      \page[empty,right]
>>      \popbackground}
>> \stopsetups
>> 
>> \setuphead
>>   [chapter]
>>   [page=yes,
>>    before=\directsetup{chapter:before}]
>> 
>> \starttext
>> 
>> \startchapter[title={Knuth}]
>> \dorecurse{10}{\samplefile{knuth}}
>> \stopchapter
>> 
>> \startchapter[title={Zapf}]
>> \dorecurse{10}{\samplefile{zapf}}
>> \stopchapter
>> 
>> \startchapter[title={Ward}]
>> \dorecurse{10}{\samplefile{ward}}
>> \stopchapter
>> 
>> \stoptext
> 
> Thanks a lot Wolfgang!
> 
> This was just the thing I was looking for. These setups seems to be the
> golden bullet in ConTeXt but I often have difficulties to understand the
> mechanism.
> 
> I'll try to wikify this later this week.
> 
> The push-pop-background pair is mentionend in x-setups-overview together
> with some other push-pop-pairs or push single commands. Are they
> documented somewhere?
> 
> juh
> 
> 
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> ___________________________________________________________________________________
> 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://tex.aanhet.net
> archive  : https://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 
> ------------------------------
> 
> End of ntg-context Digest, Vol 175, Issue 27
> ********************************************

___________________________________________________________________________________
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:[~2019-01-14 21:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1.1547463601.11666.ntg-context@ntg.nl>
2019-01-14 21:44 ` Jeong Dal [this message]
2019-01-15 17:04   ` Hans Hagen
2019-01-15 23:53     ` Jeong Dal
2019-01-16  8:35       ` Hans Hagen
2019-01-16 14:32         ` Jeong Dal

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=46C8F3BF-728C-42E7-8048-487027F825BD@me.com \
    --to=haksan@me.com \
    --cc=ntg-context@ntg.nl \
    /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).