From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/113084 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adam Reviczky via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: combination with lua Date: Tue, 12 Oct 2021 17:18:39 +0100 Message-ID: References: <888b9d32-80e7-72b0-ba2b-0a30d650e200@xs4all.nl> <324a9138-379b-e5f4-09aa-d658b645e115@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0928618664198563355==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11815"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Adam Reviczky , mailing list for ConTeXt users To: Wolfgang Schuster Original-X-From: ntg-context-bounces@ntg.nl Tue Oct 12 18:19:32 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1maKV2-0002uv-5o for gctc-ntg-context-518@m.gmane-mx.org; Tue, 12 Oct 2021 18:19:32 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 99270287EC1; Tue, 12 Oct 2021 18:18:56 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9xmQrxK8z_6q; Tue, 12 Oct 2021 18:18:55 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 78FFE288906; Tue, 12 Oct 2021 18:18:54 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7E2C9287B96 for ; Tue, 12 Oct 2021 18:18:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nqR5TSyGjIYo for ; Tue, 12 Oct 2021 18:18:51 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.208.43; helo=mail-ed1-f43.google.com; envelope-from=reviczky@gmail.com; receiver= Original-Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 75C57280583 for ; Tue, 12 Oct 2021 18:18:51 +0200 (CEST) Original-Received: by mail-ed1-f43.google.com with SMTP id ec8so1618582edb.6 for ; Tue, 12 Oct 2021 09:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jYUnFFwhmtYceb20EHM8s7gXK/FNdQHe0BEayeuoeBs=; b=cc9bN+lmxo04CkN5FlyoFWyaA5I2eGuGuCpFa6CPkcd13WiCIexWfKb+bTMoKnHrGF dlYxeC4FXvkkNqF2nXuam8MZAWfskFQLaqBuDHaJqDeeQDqS18ad2/rD5SCscc9EISUw qw7r1sYovAgFKLmWJ8GGzjeqDzEIi6YWEld9K6rHqNXXdjbDjX0liJgkovGE9oZHQ+vx 7fiBPZhST1kY/UYdUquakHPQ7yACaB8lBnA9gv3zUfkYvP8yWKqQTNZ7dF7V/1PYm6NJ +QmWVfKfBHMPttXQjhZDDKotouxZ2g4xRH+p7c/Bf74j/2wnKWqJp87IpGlcq5a0jZea rKsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jYUnFFwhmtYceb20EHM8s7gXK/FNdQHe0BEayeuoeBs=; b=stuUTtgUM3MzxJg9+LjJ/LV46ZJ54aB5MDhb6XYZh8eW7lEI4VeAzhrAlDlF4tT2c6 udzhOfrQdXvcifYvTgOSMQo6tO9aFqJBqT0pq8hixTVcZTYPBAkjTmG0ToQ7e4KJ9pRE APMkeMz4JRc5LKaZlUynLwwdjN0q3uHIJAYSyflto/jyXXT1J7fabmRH+4t2Sv1vCbit zTnJRgDieEdnicLkM+HzqXTvyh4BgNnSQ5BIrm7Th2cxeap7kUgoNVLUIMKUO5Fq82qY YW0plxypjfYlfwD89Y1w9QQEaj2AeaGwdoRToAvtj9MHnfZaOxPt6JvJhJGH9dFC2rPg CVHQ== X-Gm-Message-State: AOAM532H6dGcFSdjulUAhrAnCs4fZh/OygbgMtUpiSoa4thTr/W79Mt0 nir0qrAw12KzpeYMjkY6py7V49dQI6fpzmHKz0p/AV55 X-Google-Smtp-Source: ABdhPJwGRPuafmaM382PLfNDcNKE9liCyPkEZRUCb/1onVPIl8jQmILQuFHvfGQz+btoVeFl9KkFXspJkBQTL0M/zxM= X-Received: by 2002:a50:d948:: with SMTP id u8mr1001104edj.306.1634055530780; Tue, 12 Oct 2021 09:18:50 -0700 (PDT) In-Reply-To: <324a9138-379b-e5f4-09aa-d658b645e115@gmail.com> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:113084 Archived-At: --===============0928618664198563355== Content-Type: multipart/alternative; boundary="000000000000749ec105ce2a33b3" --000000000000749ec105ce2a33b3 Content-Type: text/plain; charset="UTF-8" Thank you Hans and Wolfgang for the explanation! Adam On Tue, Oct 12, 2021 at 4:22 PM Wolfgang Schuster < wolfgang.schuster.lists@gmail.com> wrote: > Hans Hagen via ntg-context schrieb am 12.10.2021 um 14:12: > > On 10/11/2021 1:38 PM, Adam Reviczky via ntg-context wrote: > >> Hi, > >> > >> I am trying to use a combination figure with luacode (both with > >> latest MKIV and LMTX). > >> However, the figures do not line up in the grid of the combination. > >> > >> I get the correct result with examples 1 and 2 below, but example 3 > >> using lua functions for combination and externalfigure is what I > >> wanted to use in the first place. > >> > >> MWE: > >> > >> \starttext > >> > >> \startluacode > >> > >> -- Combination 1 > >> context.startplacefigure({title = "Figure"}) > >> context.startcombination({nx = "2", ny = "2"}, > >> > >> "\\externalfigure[cow][width=50mm]","Caption 1", > >> "\\externalfigure[cow][width=50mm]","Caption 2", > >> "\\externalfigure[cow][width=50mm]","Caption 3", > >> "\\externalfigure[cow][width=50mm]","Caption 4" > >> ) > >> > >> context.stopcombination() > >> context.stopplacefigure() > >> > >> -- Combination 2 > >> > >> context.startplacefigure({title = "Figure"}) > >> context.startcombination({nx = "2", ny = "2"}, > >> > >> "Picture 1","Caption 1", > >> "Picture 2","Caption 2", > >> "Picture 3","Caption 3", > >> "Picture 4","Caption 4" > >> ) > >> > >> context.stopcombination() > >> context.stopplacefigure() > >> > >> -- Combination 3 > >> > >> context.startplacefigure({title = "Figure"}) > >> context.startcombination({nx = "2", ny = "2"}, > >> > >> context.externalfigure({"cow"},{width = "50mm"}),"Caption 1", > >> context.externalfigure({"cow"},{width = "50mm"}),"Caption 2", > >> context.externalfigure({"cow"},{width = "50mm"}),"Caption 3", > >> context.externalfigure({"cow"},{width = "50mm"}),"Caption 4" > >> ) > >> > >> context.stopcombination() > >> context.stopplacefigure() > >> > >> \stopluacode > >> \stoptext > >> > >> Any hints on what I am doing wrong in example 3? > > as in any prodedural language a function as argument gets immediately > > executed so you need to delay: > > > > context.startplacefigure({title = "Figure"}) > > context.startcombination({nx = "2", ny = "2"}, > > context.delayed.externalfigure({"cow"},{width = "50mm"}), > > "Caption 1", > > context.delayed.externalfigure({"cow"},{width = "50mm"}), > > "Caption 2", > > context.delayed.externalfigure({"cow"},{width = "50mm"}), > > "Caption 3", > > context.delayed.externalfigure({"cow"},{width = "50mm"}), > > "Caption 4" > > ) > > context.stopcombination() > > context.stopplacefigure() > > > > (this is why encoding complex documents completely in a scrtipt > > language is non trivial and why for instance these template systems > > are there because these accumulate) > > Another solution is to use the content and caption blocks for each > combination entry. > > \starttext > > \startluacode > > context.startplacefigure({title = "Figure"}) > context.startcombination({nx = 1, ny = 1}) > context.startcontent() > context.externalfigure({"cow"},{width = "50mm"}) > context.stopcontent() > context.startcaption() > context("Caption 1") > context.stopcaption() > context.stopcombination() > context.stopplacefigure() > > \stopluacode > > \stoptext > > Wolfgang > > --000000000000749ec105ce2a33b3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you Hans and Wolfgang for the explanation!

Adam

On Tue, Oct 12, 2021 at 4:22 PM Wolfgang= Schuster <wolfgang= .schuster.lists@gmail.com> wrote:
Hans Hagen via ntg-context schrieb am 12.10.2021 u= m 14:12:
> On 10/11/2021 1:38 PM, Adam Reviczky via ntg-context wrote:
>> Hi,
>>
>> I am trying to use a combination figure with luacode (both with >> latest MKIV and LMTX).
>> However, the figures do not line up in the grid of the combination= .
>>
>> I get the correct result with examples 1 and 2 below, but example = 3
>> using lua functions for combination and externalfigure is what I <= br> >> wanted to use in the first place.
>>
>> MWE:
>>
>> \starttext
>>
>> \startluacode
>>
>> -- Combination 1
>> context.startplacefigure({title =3D "Figure"})
>> context.startcombination({nx =3D "2", ny =3D "2&quo= t;},
>>
>> "\\externalfigure[cow][width=3D50mm]","Caption 1&qu= ot;,
>> "\\externalfigure[cow][width=3D50mm]","Caption 2&qu= ot;,
>> "\\externalfigure[cow][width=3D50mm]","Caption 3&qu= ot;,
>> "\\externalfigure[cow][width=3D50mm]","Caption 4&qu= ot;
>> )
>>
>> context.stopcombination()
>> context.stopplacefigure()
>>
>> -- Combination 2
>>
>> context.startplacefigure({title =3D "Figure"})
>> context.startcombination({nx =3D "2", ny =3D "2&quo= t;},
>>
>> "Picture 1","Caption 1",
>> "Picture 2","Caption 2",
>> "Picture 3","Caption 3",
>> "Picture 4","Caption 4"
>> )
>>
>> context.stopcombination()
>> context.stopplacefigure()
>>
>> -- Combination 3
>>
>> context.startplacefigure({title =3D "Figure"})
>> context.startcombination({nx =3D "2", ny =3D "2&quo= t;},
>>
>> context.externalfigure({"cow"},{width =3D "50mm&quo= t;}),"Caption 1",
>> context.externalfigure({"cow"},{width =3D "50mm&quo= t;}),"Caption 2",
>> context.externalfigure({"cow"},{width =3D "50mm&quo= t;}),"Caption 3",
>> context.externalfigure({"cow"},{width =3D "50mm&quo= t;}),"Caption 4"
>> )
>>
>> context.stopcombination()
>> context.stopplacefigure()
>>
>> \stopluacode
>> \stoptext
>>
>> Any hints on what I am doing wrong in example 3?
> as in any prodedural language a function as argument gets immediately =
> executed so you need to delay:
>
> context.startplacefigure({title =3D "Figure"})
> =C2=A0=C2=A0=C2=A0 context.startcombination({nx =3D "2", ny = =3D "2"},
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.delayed.externalfig= ure({"cow"},{width =3D "50mm"}),
> "Caption 1",
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.delayed.externalfig= ure({"cow"},{width =3D "50mm"}),
> "Caption 2",
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.delayed.externalfig= ure({"cow"},{width =3D "50mm"}),
> "Caption 3",
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.delayed.externalfig= ure({"cow"},{width =3D "50mm"}),
> "Caption 4"
> =C2=A0=C2=A0=C2=A0 )
> =C2=A0=C2=A0=C2=A0 context.stopcombination()
> context.stopplacefigure()
>
> (this is why encoding complex documents completely in a scrtipt
> language is non trivial and why for instance these template systems > are there because these accumulate)

Another solution is to use the content and caption blocks for each
combination entry.

\starttext

\startluacode

context.startplacefigure({title =3D "Figure"})
=C2=A0=C2=A0=C2=A0=C2=A0 context.startcombination({nx =3D 1, ny =3D 1})
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.startcontent()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 co= ntext.externalfigure({"cow"},{width =3D "50mm"})
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.stopcontent()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.startcaption()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 co= ntext("Caption 1")
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 context.stopcaption()
=C2=A0=C2=A0=C2=A0=C2=A0 context.stopcombination()
context.stopplacefigure()

\stopluacode

\stoptext

Wolfgang

--000000000000749ec105ce2a33b3-- --===============0928618664198563355== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============0928618664198563355==--