Re: [NTG-context] "Remember picture" does not work (again)

2020-04-06 Thread Aditya Mahajan

On Mon, 6 Apr 2020, Jairo A. del Rio wrote:


A Metapost alternative would be fine, too.


See Chapter 5 of the metafun manual, which describes how anchors and 
position graphics.



Aditya
___
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
___


Re: [NTG-context] Lmtx + pgfplots compilation error

2020-04-06 Thread Henri Menke
The problem is that pgfplots uses the ^^ syntax to access characters but
this relies on ^ having catcode 7 which is not the case by default in
ConTeXt.  I had a similar issue in PGF before and that was fixed by just
replacing the ^^ syntax with the ascii code constants from
syst-ini.mkxl.

Cheers, Henri

On 06/04/20, 22:23, Fabrice Couvreur wrote:
> Hi,
> Still with the idea of using lmtx, I get a compilation error when I use
> pgfplots.
> Thank you.
> Fabrice
> 
> open source > level 9, order 92, name 'pgfplotsbinary.data.code.tex'
> 
> tex error   > tex error on line 42 in file
> pgfplotsbinary.data.code.tex: ! Undefined control sequence
> 
> l.42 \catcode`\ =11^^I\expandafter\xdef\csname pgfp@bin@
> 
> \the\counter^^I\endcsname{^^20}\endgroup\advance\counter by1
> lua error:
> 
> ?
> 
> 
> 
> 
> 
> 
> The control sequence at the end of the top line of your error message was
> never
> \def'ed. You can just continue as I'll forget about whatever was undefined.
> 
> 
> mtx-context | fatal error: return code: 256
> 
> TeX Output exited abnormally with code 1 at Mon Apr  6 22:19:01

> ___
> 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
___


[NTG-context] "Remember picture" does not work (again)

2020-04-06 Thread Jairo A. del Rio
I've tried using the fix in https://tex.stackexchange.com/a/492197/193767
in order to make TikX's remember picture feature usable, Code below, just
in case:

\unprotect% This fixes the present
bug\unexpanded\def\pdflastxpos{\numexpr\clf_lastxpos\relax}\unexpanded\def\pdflastypos{\numexpr\clf_lastypos\relax}%
This might be needed if you run PGF 3.1.3% see
https://github.com/pgf-tikz/pgf/issues/675\def\XC@tgt@mod#1{#1}\def\XC@sdef#1#2{\edef#1{#2}}\protect\usemodule[tikz]\starttext\starttikzpicture[remember
picture]
 \node (A) {Node 1};\stoptikzpicture
Hi world\starttikzpicture[remember picture]
\node (B) {Node
2};\stoptikzpicture\starttikzpicture[overlay,remember picture]
\draw (B) --++(0,0.5) -| (A);\stoptikzpicture\stoptext


However, the following appears:

l.1 6

120806

\lastxpos ->\clf_lastxpos

 \noexpand \pgfsyspdfmark {pgfid1}{\the \lastxpos

}{\the \lastypos }



}\endwrite

 \shipoutscratchbox

\page_shipout_box #1->\clf_shipoutpage #1

\relax \setbox #1\emptybox \global ...

...

l.20 \stoptext


I use LuaTeX 1.10 7127 + ConTeXt MkIV 2019.03.21 21:39 (TeX Live version),
in case this helps. Is another fix necessary? A Metapost alternative would
be fine, too.
___
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
___


[NTG-context] Lmtx + pgfplots compilation error

2020-04-06 Thread Fabrice Couvreur
Hi,
Still with the idea of using lmtx, I get a compilation error when I use
pgfplots.
Thank you.
Fabrice

open source > level 9, order 92, name 'pgfplotsbinary.data.code.tex'

tex error   > tex error on line 42 in file
pgfplotsbinary.data.code.tex: ! Undefined control sequence

l.42 \catcode`\ =11^^I\expandafter\xdef\csname pgfp@bin@

\the\counter^^I\endcsname{^^20}\endgroup\advance\counter by1
lua error:

?






The control sequence at the end of the top line of your error message was
never
\def'ed. You can just continue as I'll forget about whatever was undefined.


mtx-context | fatal error: return code: 256

TeX Output exited abnormally with code 1 at Mon Apr  6 22:19:01
___
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
___


Re: [NTG-context] Fwd: Using Lua files in project structure

2020-04-06 Thread Jairo A. del Rio
This worked for me. Thank you very much.

El lun., 6 de abr. de 2020 a la(s) 11:11, Aditya Mahajan (adit...@umich.edu)
escribió:

>
> On Mon, 6 Apr 2020, Jairo A. del Rio wrote:
> >
> > Well, I'll be more specific. I attach a zip file showing a minimal
> example
> > of what I achieved so far and its output (labelled "Works") and what I
> > actually want, but does not work (labelled "Doesnotwork"). I've tried
> > different commands and combinations, all of them useless. As a side note,
> > I'm porting some TikZ functions. Although it is not recommended in
> ConTeXt,
> > some of them are really necessary to me.
>
> I didn't try to completely debug what is going wrong in your setup, but
> here is a simpler way to achieve the same result. I am using components
> because (i) it works and (ii) I don't use the product-project setup
> regularly enough to debug it quicky.
>
> Aditya
___
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
___


Re: [NTG-context] Using Lua files in project structure

2020-04-06 Thread Wolfgang Schuster

Jairo A. del Rio schrieb am 06.04.2020 um 15:58:
Well, I'll be more specific. I attach a zip file showing a minimal 
example of what I achieved so far and its output (labelled "Works") and 
what I actually want, but does not work (labelled "Doesnotwork"). I've 
tried different commands and combinations, all of them useless. As a 
side note, I'm porting some TikZ functions. Although it is not 
recommended in ConTeXt, some of them are really necessary to me.


You use dofile(...) in your environment and Lua files
but this doesn't work when you load files which aren't
in the current directory or in your TeX installation.

Wolfgang
___
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
___


Re: [NTG-context] Fwd: Using Lua files in project structure

2020-04-06 Thread Aditya Mahajan


On Mon, 6 Apr 2020, Jairo A. del Rio wrote:


Well, I'll be more specific. I attach a zip file showing a minimal example
of what I achieved so far and its output (labelled "Works") and what I
actually want, but does not work (labelled "Doesnotwork"). I've tried
different commands and combinations, all of them useless. As a side note,
I'm porting some TikZ functions. Although it is not recommended in ConTeXt,
some of them are really necessary to me.


I didn't try to completely debug what is going wrong in your setup, but 
here is a simpler way to achieve the same result. I am using components 
because (i) it works and (ii) I don't use the product-project setup 
regularly enough to debug it quicky.


Aditya<>
___
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
___


Re: [NTG-context] Float positioning

2020-04-06 Thread Tomas Hala
Hi Alexey,

# Yes, I tried leftpage/rightpage: this removes the blank page, but may
# cause images to be reordered (so that e. g. 3 goes before 2), which is
# completely unacceptable IMO.

Yes, you are right. 
But -- I do not know why -- your code you attached gives on my computer (TL2019)
the 1-3-2 order, too.
 
# Also, this doesn't help with the text flow at the page where the first
# image is positioned (still no text below the image).

Is it one or two problems? I do know how to solve by some system way...

You can try the work around below, it is based on computation of additional 
measures for special instance of figure.

Best wishes,

Tomáš 

%%
\showframe
\setupexternalfigures[location={local,default}]

\definefloat[figpage][figure]

\newdimen\myxx
\newdimen\myht 
\newcount\mysp

\def\myfig#1#2#3{%
  \myht=\makeupheight
  \setbox0=\hbox{{\externalfigure[#2][#3]}}
  \advance\myht by -\wd0 
  \myht=.5\myht
  \myxx=\myht
  \divide\myxx by \lineheight
  \mysp=\myxx 
  \advance\mysp by 1

  \setupfloat[figpage][toffset=\myht]
  \setupcaption[figpage][spaceafter=\the\mysp*big]
  \startplacefigpage[location={here},title=#1]
{\externalfigure[#2][#3]}
  \stopplacefigpage
}

\starttext

\dorecurse{3}{\input{knuth}}
  \startplacefigure[location={here},title=cow]
{\externalfigure[cow][width=150mm]}
  \stopplacefigure
\dorecurse{1}{{\blue\input{knuth}}}
\myfig{cow again}{cow}{width=150mm}
\myfig{one more cow}{cow}{width=100mm}
\myfig{one more cow}{cow}{width=50mm}
\myfig{one more cow}{cow}{width=150mm}

\dorecurse{10}{{\green\input{knuth}}}

\stoptext
%%



# 
# -- 
# Regards,
# Alexey Kryukov 
# 
# Moscow State University
# Faculty of History
# 
# On Mon, 6 Apr 2020 13:58:57 +0200
# Tomas Hala wrote:
# 
# > Hi Alexey,
# > 
# > I do not how free are you in decision where figures should be located
# > but I tried with "leftpage" and "rightpage" instead of "page" and
# > it seems to be ok.
# > 
# > \placefigure[rightpage]{one more cow}{\externalfigure[cow]
# > [width=150mm]} \placefigure[leftpage]{cow again}{\externalfigure[cow]
# > [width=150mm]}
# > 
# > Best wishes,
# > 
# > Tomáš
# > 
# > 
# > Mon, Apr 06, 2020 ve 02:15:50PM +0300 Alexey Kryukov napsal(a):
# > # Hi all,
# > # 
# > # Suppose I have the following document:
# > # 
# > # \setupexternalfigures[location={local,default}]
# > # \starttext
# > # 
# > # \dorecurse{3}{\input{knuth}}
# > # \placefigure[top]{cow}{\externalfigure[cow][width=150mm]}
# > # \input{knuth}
# > # \placefigure[page]{one more cow}{\externalfigure[cow][width=150mm]}
# > # \placefigure[page]{cow again}{\externalfigure[cow][width=150mm]}
# > # \dorecurse{10}{\input{knuth}}
# > # \stoptext
# > # 
# > # Here I would expect the text flow to continue below the first image,
# > # and then two more images to be positioned on separate pages.
# > # Instead I get no text at all at the page with the Figure 1 and one
# > # more blank page after it. Only after the last image the text flow
# > # continues.
# > # 
# > # Since similar situations are very common for documents which contain
# > # several large illustrations, I would like to know if there are any
# > # workarounds for the problem.
# > # 
# > # -- 
# > # Regards,
# > # Alexey Kryukov 
# > # 
# > # Moscow State University
# > # Faculty of History
# > # 
___
# > # 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
# > # 
___
# > 
# >  Tomáš Hála
# > 
# > Mendelova univerzita, Provozně ekonomická fakulta, ústav informatiky
# > Zemědělská 1, CZ-613 00 Brno,  tel. +420 545 13 22 28
# > 
# > http://akela.mendelu.cz/~thala
# > 
___
# > 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!
# 
# 

[NTG-context] Fwd: Using Lua files in project structure

2020-04-06 Thread Jairo A. del Rio
-- Forwarded message -
De: Jairo A. del Rio 
Date: lun., 6 de abr. de 2020 a la(s) 08:58
Subject: Re: [NTG-context] Using Lua files in project structure
To: Wolfgang Schuster 


Well, I'll be more specific. I attach a zip file showing a minimal example
of what I achieved so far and its output (labelled "Works") and what I
actually want, but does not work (labelled "Doesnotwork"). I've tried
different commands and combinations, all of them useless. As a side note,
I'm porting some TikZ functions. Although it is not recommended in ConTeXt,
some of them are really necessary to me.

El dom., 5 de abr. de 2020 a la(s) 11:05, Wolfgang Schuster (
wolfgang.schuster.li...@gmail.com) escribió:

> Jairo A. del Rio schrieb am 05.04.2020 um 17:49:
> > None of them work. Maybe I'm doing something wrong.
>
> I guess so because
>
>  \loadluafile[testh.lua]
>
> and
>
>  \luaenvironment testh.lua
>
> work for me.
>
> Wolfgang
>
<>
___
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
___


Re: [NTG-context] startMPpage..stopMPpage written to a separate PDF?

2020-04-06 Thread Wolfgang Schuster

Gerben Wierda schrieb am 05.04.2020 um 12:27:




On 5 Apr 2020, at 11:34, Hans Hagen  wrote:

On 4/5/2020 12:29 AM, Gerben Wierda wrote:

I have a series of startMPpage—stopMPpage pairs (with MP code inbetween). These 
now become separate pages in a single PDF. But I need them to become separate 
PDF’s each during my ConTeXt run, with a name of my own choosing. Is this 
possible? I guess this will be problematic, but one can hope (maybe some very 
low level TeX trickery)...

no (i would probably cook up something but it's not worth the trouble and it 
would add lots of ugly code deep down) but


Yes, I was thinking about some low level open/writeout stuff in TeX but was 
scared to try.

Still, a \startMPfile{pdffilename}..\stopMPfile (instead of page) would have 
been great...


Something like this:

\starttext

\startbuffer[square]
\startMPpage
draw fullsquare scaled 10 withcolor red ;
\stopMPpage
\stopbuffer

\typesetbufferonly[square]

\startbuffer[circle]
\startMPpage
draw fullcircle scaled 10 withcolor green ;
\stopMPpage
\stopbuffer

\typesetbuffer[circle]

\startbuffer[triangle]
\startMPpage
draw fulltriangle scaled 10 withcolor blue ;
\stopMPpage
\stopbuffer

\savebuffer[list=triangle,prefix=no,file=triangle.tex]

\typesetfile[triangle.tex][]

\stoptext

Wolfgang
___
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
___


Re: [NTG-context] Float positioning

2020-04-06 Thread Alexey Kryukov
Hi Tomas,

thank you for your answer.

Yes, I tried leftpage/rightpage: this removes the blank page, but may
cause images to be reordered (so that e. g. 3 goes before 2), which is
completely unacceptable IMO.

Also, this doesn't help with the text flow at the page where the first
image is positioned (still no text below the image).

-- 
Regards,
Alexey Kryukov 

Moscow State University
Faculty of History

On Mon, 6 Apr 2020 13:58:57 +0200
Tomas Hala wrote:

> Hi Alexey,
> 
> I do not how free are you in decision where figures should be located
> but I tried with "leftpage" and "rightpage" instead of "page" and
> it seems to be ok.
> 
> \placefigure[rightpage]{one more cow}{\externalfigure[cow]
> [width=150mm]} \placefigure[leftpage]{cow again}{\externalfigure[cow]
> [width=150mm]}
> 
> Best wishes,
> 
> Tomáš
> 
> 
> Mon, Apr 06, 2020 ve 02:15:50PM +0300 Alexey Kryukov napsal(a):
> # Hi all,
> # 
> # Suppose I have the following document:
> # 
> # \setupexternalfigures[location={local,default}]
> # \starttext
> # 
> # \dorecurse{3}{\input{knuth}}
> # \placefigure[top]{cow}{\externalfigure[cow][width=150mm]}
> # \input{knuth}
> # \placefigure[page]{one more cow}{\externalfigure[cow][width=150mm]}
> # \placefigure[page]{cow again}{\externalfigure[cow][width=150mm]}
> # \dorecurse{10}{\input{knuth}}
> # \stoptext
> # 
> # Here I would expect the text flow to continue below the first image,
> # and then two more images to be positioned on separate pages.
> # Instead I get no text at all at the page with the Figure 1 and one
> # more blank page after it. Only after the last image the text flow
> # continues.
> # 
> # Since similar situations are very common for documents which contain
> # several large illustrations, I would like to know if there are any
> # workarounds for the problem.
> # 
> # -- 
> # Regards,
> # Alexey Kryukov 
> # 
> # Moscow State University
> # Faculty of History
> # 
> ___
> # 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
> # 
> ___
> 
>  Tomáš Hála
> 
> Mendelova univerzita, Provozně ekonomická fakulta, ústav informatiky
> Zemědělská 1, CZ-613 00 Brno,  tel. +420 545 13 22 28
> 
> http://akela.mendelu.cz/~thala
> ___
> 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
___


Re: [NTG-context] Float positioning

2020-04-06 Thread Tomas Hala
Hi Alexey,

I do not how free are you in decision where figures should be located
but I tried with "leftpage" and "rightpage" instead of "page" and
it seems to be ok.

\placefigure[rightpage]{one more cow}{\externalfigure[cow][width=150mm]}
\placefigure[leftpage]{cow again}{\externalfigure[cow][width=150mm]}

Best wishes,

Tomáš


Mon, Apr 06, 2020 ve 02:15:50PM +0300 Alexey Kryukov napsal(a):
# Hi all,
# 
# Suppose I have the following document:
# 
# \setupexternalfigures[location={local,default}]
# \starttext
# 
# \dorecurse{3}{\input{knuth}}
# \placefigure[top]{cow}{\externalfigure[cow][width=150mm]}
# \input{knuth}
# \placefigure[page]{one more cow}{\externalfigure[cow][width=150mm]}
# \placefigure[page]{cow again}{\externalfigure[cow][width=150mm]}
# \dorecurse{10}{\input{knuth}}
# \stoptext
# 
# Here I would expect the text flow to continue below the first image,
# and then two more images to be positioned on separate pages. Instead I
# get no text at all at the page with the Figure 1 and one more
# blank page after it. Only after the last image the text flow continues.
# 
# Since similar situations are very common for documents which contain
# several large illustrations, I would like to know if there are any
# workarounds for the problem.
# 
# -- 
# Regards,
# Alexey Kryukov 
# 
# Moscow State University
# Faculty of History
# 
___
# 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
# 
___

 Tomáš Hála

Mendelova univerzita, Provozně ekonomická fakulta, ústav informatiky
Zemědělská 1, CZ-613 00 Brno,  tel. +420 545 13 22 28

http://akela.mendelu.cz/~thala
___
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
___


[NTG-context] Float positioning

2020-04-06 Thread Alexey Kryukov
Hi all,

Suppose I have the following document:

\setupexternalfigures[location={local,default}]
\starttext

\dorecurse{3}{\input{knuth}}
\placefigure[top]{cow}{\externalfigure[cow][width=150mm]}
\input{knuth}
\placefigure[page]{one more cow}{\externalfigure[cow][width=150mm]}
\placefigure[page]{cow again}{\externalfigure[cow][width=150mm]}
\dorecurse{10}{\input{knuth}}
\stoptext

Here I would expect the text flow to continue below the first image,
and then two more images to be positioned on separate pages. Instead I
get no text at all at the page with the Figure 1 and one more
blank page after it. Only after the last image the text flow continues.

Since similar situations are very common for documents which contain
several large illustrations, I would like to know if there are any
workarounds for the problem.

-- 
Regards,
Alexey Kryukov 

Moscow State University
Faculty of History
___
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
___


Re: [NTG-context] Trying to understand this ctxlua error

2020-04-06 Thread Gerben Wierda
On 6 Apr 2020, at 02:54, Wolfgang Schuster  
wrote:
> 
> Gerben Wierda schrieb am 06.04.2020 um 00:41:
>> I got this error after I had changed some lua code:
>> tex error   > tex error on line 272 in file archimate-lua.new: ! 
>> Undefined control sequence
>> warnIfVerbose( "Breaking off the processing of node %s\nNo
>>   l...eak
>>  xsi:type", node)
>> \luat_start_lua_code_indeed ...ormalexpanded {\endgroup \noexpand \directlua 
>> {#1
>>  
>> }}
>> l.272 \stopluacode
>> 
>> The control sequence at the end of the top line of your error message was 
>> never
>> \def'ed. You can just continue as I'll forget about whatever was undefined.
>> I have been looking at that code for over two hours, not seeing anything 
>> wrong with it. But I’ve now finally found the culprit and I still do not get 
>> it.
>> The culprit was:
>>   warnIfVerbose( "Breaking off the processing of %s\n No 
>> elementRef", node)
>> The problem goes away when I use:
>>   warnIfVerbose( "Breaking off the processing of %s\nNo elementRef", 
>> node)
>> (I don’t want the line after the node is printed to begin with a space).
>> But the lack of space between \n and N kills lua (apparently). For 
>> completeness (as string.format and texio.write_nl are also in play):
>> function warnWithLabelIfVerbose( str, ... )
>>   if verboseProgram then
>> texio.write_nl( str .. string.format(...))
>>   end
>> end
>> function warnIfVerbose( ... )
>>   warnWithLabelIfVerbose("-> ", ...)
>> end
>> Is this a lua bug? A ConTeXt bug? Expected behaviour? And if so, why is 
>> reported that on line 272 (where \stopluacode is) is the error? Or is the 
>> error message indeed helpful and do I just lack the know how to interpret it?
> 
> ConTeXt expands TeX commands in a luacode-environment
> and when you have \n followed by text you create a new
> command with starts with \n but since it isn't defined
> you get a error message.
> 
> In the example below the commented block produces
> the same error message as you get.
> 
> \starttext
> 
> %\startluacode
> %print("text\ntext")
> %\stopluacode
> 
> \startluacode
> print("text\n text")
> \stopluacode
> 
> \stoptext

OK, thanks. This means the ConTeXt environment mixes standard TeX (where \nfoo 
would be considered a TeX command) and lua string substitution (where \nfoo 
would mean a newline followed by foo), correct? I understand why that happens 
(otherwise one would have to escape all \ characters directed at TeX) but it 
really took me hours (because I did not understand the error message that 
correctly told me \Nno was the problem). It’s what you see depends on what you 
are looking for, I guess.

Maybe a warning in the documentation (or maybe there is one and I missed it)

G

___
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
___


Re: [NTG-context] startMPpage..stopMPpage written to a separate PDF?

2020-04-06 Thread Taco Hoekwater


> On 5 Apr 2020, at 12:27, Gerben Wierda  wrote:
> 
> Alternatively, I could have a step before this to turn the input XML into 
> many separate XMLs and have many ConTeXt runs. Probably that is the best way 
> to do it. Each generated XML would have all of the original XML except it 
> would only have one ‘view’ in it and the rest removed.

Or you could write out a shell script while processing the run. 

function moduledata.archimate(filename)
  local root = xml.load(filename)
  warnIfVerbose( "Processing %s", filename)
  local shfile = io.open(tex.jobname.. ".sh", "w")
  local i = 1
  for view in xml.collected(root,"diagrams/view") do
local viewName = xml.text(view,"/name")
shfile:write(string.format('mutool merge -o "%s.pdf" %s "%s.pdf" ', 
viewName, i, tex.jobname))
i = i + 1
….
  end
  shfile:close()

and process that shell script at the end of the run.


___
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
___