[NTG-context] getting line numbers

2021-09-03 Thread Thierry Horsin via ntg-context
Hi everybody

Is there a way to have an automatic access to the current line number of a 
specific place inside a tex file ? To be more precise, here is what I would 
like to do.

I am currently trying to have some automatic external compilation by g++ of 
some portion of my tex file as in the following example below. \startC \stopC 
defines a framed part of text written between lines 538 and 549. Of course, if 
I add something before or inbetween my framed code, 538 and/or 549 will change. 
Thus I would like to get these two numbers automatically.

Thank you.
Thierry

\startC
#include 

using namespace std;
int mysum(int,int); int a; int b;
int main () { a=2; b=9;
  cout << mysum(a,b) << endl;
  return 0; 
}
int mysum(int a, int b)
{ return a+b; }
\stopC

\startluacode
myout = io.open("test.cpp", "w")
myin = io.open(tex.jobname..".tex", "r")
local n=0
for line in myin:lines() do
n=n+1
if n>539 and n<550 then
myout:write(line.."\n")
 end   
end
myout:close()
myin:close()
os.execute("g++ -o test test.cpp")
os.execute("./test > tmp")
local file=assert(io.open("tmp","r"))
local t = file:read("*all")
tex.print(t)
\stopluacode





___
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] getting line numbers

2021-09-03 Thread Aditya Mahajan via ntg-context
On Fri, 3 Sep 2021, Thierry Horsin via ntg-context wrote:

> Hi everybody
> 
> Is there a way to have an automatic access to the current line number of a 
> specific place inside a tex file ? To be more precise, here is what I would 
> like to do.

Also look at the filter module. 

https://github.com/adityam/filter

Behind the scenes, it works by saving the content in an external file and then
running it through any external program. It also allows for caching the
result, and has many options for customizing the behavior.

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
___


[NTG-context] Use MetaPost to distort images?

2021-09-03 Thread Henning Hraban Ramm via ntg-context
Hi, is it possible to apply geometric transformations to images using MetaPost?

This is again way over my head, but I’m still trying different methods to let a 
ConTeXt document look more “hand-made”.

In my example*, I added frame and shadow to a photo and _distorted_ it slightly 
to have it look like a postcard was glued on the page (with a piece of tape). 
I’d like to automate and randomize that process.

I guess I could achieve something similar with ImageMagick (not with 
GraphicsMagick), but if it would be possible inside LMTX that would be great.

Hraban


*) not small enough for the mailing list; see 
https://sedna.fiee.net/f/fb532dc85c784147a149/
___
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] getting line numbers

2021-09-03 Thread Thierry Horsin via ntg-context
Many thanks Hans.
Thierry

Le Friday 03 Sep 2021 à 14:16:40 (+0200), Hans Hagen a écrit :


> in this case, thinking a bit different is easier ...
> 
> \starttext
> 
> \startbuffer[MyBuffer]
> #include 
> 
> using namespace std;
> int mysum(int,int);
> int a; int b;
> int main () {
> a=2; b=9;
> cout << mysum(a,b) << endl;
> return 0;
> }
> int mysum(int a, int b) {
> return a+b;
> }
> \stopbuffer
> 
> We compile and run:
> 
> \typebuffer[MyBuffer][option=C]
> 
> \startluacode
> io.savedata("test.cpp",buffers.getcontent("MyBuffer"))
> --os.execute("g++ -o test test.cpp")
> --os.execute("./test > test.tmp")
> os.execute("echo done > test.tmp")
> buffers.assign("MyBuffer",io.loaddata("test.tmp"))
> \stopluacode
> 
> And get:
> 
> \typebuffer[MyBuffer]
> 
> Or just:
> 
> \typefile{test.tmp}
> 
> \stoptext
> 
> 
> -
>   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
___


Re: [NTG-context] metafun doesn't compile \root 3 \of 2

2021-09-03 Thread Hans Hagen via ntg-context

On 9/3/2021 11:48 AM, fv leung via ntg-context wrote:

\starttext

\m{\root3\of2}

\stoptext

works.

But

\starttext

\startMPcode
   label("\m{\root3\of2}", origin);
\stopMPcode

\stoptext

doesn't.

draw thetextext("\m{\root3\of2}",origin);

labels are done in the default (normally monospace) font

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


Re: [NTG-context] getting line numbers

2021-09-03 Thread Hans Hagen via ntg-context

On 9/3/2021 12:58 PM, Thierry Horsin via ntg-context wrote:

Hi everybody

Is there a way to have an automatic access to the current line number of a 
specific place inside a tex file ? To be more precise, here is what I would 
like to do.

I am currently trying to have some automatic external compilation by g++ of 
some portion of my tex file as in the following example below. \startC \stopC 
defines a framed part of text written between lines 538 and 549. Of course, if 
I add something before or inbetween my framed code, 538 and/or 549 will change. 
Thus I would like to get these two numbers automatically.

Thank you.
Thierry

\startC
#include 

using namespace std;
int mysum(int,int); int a; int b;
int main () { a=2; b=9;
   cout << mysum(a,b) << endl;
   return 0;
 }
int mysum(int a, int b)
{ return a+b; }
\stopC

\startluacode
myout = io.open("test.cpp", "w")
myin = io.open(tex.jobname..".tex", "r")
local n=0
for line in myin:lines() do
n=n+1
if n>539 and n<550 then
 myout:write(line.."\n")
  end
end
myout:close()
myin:close()
os.execute("g++ -o test test.cpp")
os.execute("./test > tmp")
local file=assert(io.open("tmp","r"))
local t = file:read("*all")
tex.print(t)
\stopluacode

in this case, thinking a bit different is easier ...

\starttext

\startbuffer[MyBuffer]
#include 

using namespace std;
int mysum(int,int);
int a; int b;
int main () {
a=2; b=9;
cout << mysum(a,b) << endl;
return 0;
}
int mysum(int a, int b) {
return a+b;
}
\stopbuffer

We compile and run:

\typebuffer[MyBuffer][option=C]

\startluacode
io.savedata("test.cpp",buffers.getcontent("MyBuffer"))
--os.execute("g++ -o test test.cpp")
--os.execute("./test > test.tmp")
os.execute("echo done > test.tmp")
buffers.assign("MyBuffer",io.loaddata("test.tmp"))
\stopluacode

And get:

\typebuffer[MyBuffer]

Or just:

\typefile{test.tmp}

\stoptext


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


Re: [NTG-context] getting line numbers

2021-09-03 Thread Hans Hagen via ntg-context

On 9/3/2021 3:53 PM, Aditya Mahajan via ntg-context wrote:

On Fri, 3 Sep 2021, Thierry Horsin via ntg-context wrote:


Hi everybody

Is there a way to have an automatic access to the current line number of a 
specific place inside a tex file ? To be more precise, here is what I would 
like to do.


Also look at the filter module.

 https://github.com/adityam/filter

Behind the scenes, it works by saving the content in an external file and then
running it through any external program. It also allows for caching the
result, and has many options for customizing the behavior.
you forgot to mention that it also makes sure that you only process when 
there has been a change (after all calling gcc comes at a price)


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
___


Re: [NTG-context] Fuzzy lines

2021-09-03 Thread Henning Hraban Ramm via ntg-context

> Am 13.05.2021 um 20:02 schrieb Henning Hraban Ramm :
> 
> Thank you, that is what I was asking for!
> 
> Unfortunately, the deviation of edge points is too big – try my attached test 
> file.

Hi Aditya et al.,

coming back to this: I found "fill" was not working, since do_sketchfill didn’t 
use sketchrandomized. That was an easy fix.

But I couldn’t fix the edge points issue: the less segments I use, the more 
some of the edge points deviate (see attachment with 10 segments; I used the 
setup from your theorems article).
Lower left and upper right are good, what happens with the others?

I just can’t understand the loop that splits the original path segments:

for t = 0 step 1/sketch_segments until 1-1/sketch_segments :
((point   (t*arclength(p)) on p) 
randomshifted s) .. controls
((postcontrol (t*arclength(p)) on p) 
randomshifted s) and
((precontrol  ((t+1/sketch_segments)*arclength(p)) on p) 
randomshifted s) ..
endfor

Would it make sense to check if a point is an edge point (without curve 
controls)?


Next question: Can I apply this to \framed and TABLE lines? (Probably only via 
backgrounds?)


Hraban




sketchtest2.pdf
Description: Adobe PDF document


mp-sketch.mp
Description: Binary data
___
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] update lmtx

2021-09-03 Thread Hans Hagen via ntg-context

Hi,

The end of the week update provides:

\starttext

\startTEXpage[offset=10pt]
\starttabulate[|c|c|c|]
\NC 1   \NC second column \NC third column \NC \NR
\NC 2   \NC second\NC third\NC \NR
\NC 3 r \NS[1][r]second & third \NC \NR
\NC 3 c \NS[1][c]second & third \NC \NR
\NC 3 l \NS[1][l]second & third \NC \NR
\stoptabulate
\stopTEXpage

\stoptext

where \NS means that there will be a span over columns (I needed such a 
span fro a manual but it only covers simple cases).


There is also a new lowlevel manual, this time on marks (aka markings), 
think of running headers and so.


I'm considering replacing the marking code by new code that I already 
have one my machine. In mkiv we;ve always used a more powerful 
alternative for the marks that than what luatex and friends provide but 
in luametatex I added a few of the missing pieces to the engine in 
addition to what already what there for a while. But I need Wolfgang to 
go over the code in order to identify possible side effects first.


Hans

ps. Because Dutch telecom (who so far took over all the providers we 
ever had so we had to change a few times) now completely quits web 
services we need to switch provider (again; so much for synergy) so the 
upcoming week there might be glitches in accessing the installer (we 
don't fallback on the garden yet).


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


Re: [NTG-context] Use MetaPost to distort images?

2021-09-03 Thread Bruce Horrocks via ntg-context


> On 3 Sep 2021, at 11:28, Henning Hraban Ramm via ntg-context 
>  wrote:
> 
> Hi, is it possible to apply geometric transformations to images using 
> MetaPost?
> 
> This is again way over my head, but I’m still trying different methods to let 
> a ConTeXt document look more “hand-made”.
> 
> In my example*, I added frame and shadow to a photo and _distorted_ it 
> slightly to have it look like a postcard was glued on the page (with a piece 
> of tape). I’d like to automate and randomize that process.
> 
> I guess I could achieve something similar with ImageMagick (not with 
> GraphicsMagick), but if it would be possible inside LMTX that would be great.

No idea about MetaPost but "Fred's ImageMagic Scripts" 
 is a fantastic resource. 
Start with "vintage" 1, 2 & 3 towards the bottom.

The site is a little idiosyncratic in that you click and nothing appears to 
happen. This is because all the pages start with the same table of scripts at 
the top so you have to scroll down to see an example of the effect achieved by 
the script you just selected.

—
Bruce Horrocks
Hampshire, UK

___
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] Using \vrule within mathmatrix

2021-09-03 Thread fv leung via ntg-context
\definemathmatrix[pmatrix][matrix:parentheses][simplecommand=pMat]

\starttext

I used to typeset an augmented matrix this way:

\m{\pMat{1,7,-6,\vrule,-4;3,-4,7,\vrule,13;4,3,1,\vrule,9}}

But this no longer works.

Though I can get over this with

\m{\pMat{1,7,-6,¦,-4;3,-4,7,¦,13;4,3,1,¦,9}} ,

I find the result from the old way looks nicer.

Is the using of \backslash vrule within mathmatrix gone for good?

\stoptext
___
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] Implementing a custom authorconversion for bibliographies

2021-09-03 Thread Joey McCollum via ntg-context
Hi,

I mentioned this in an earlier e-mail but thought that now might be a good
time to describe this issue in detail. I'd like to define a new
authorconversion that renders the first author in a list differently than
the remaining authors in the list. Specifically, I'd like to use the
"inverted" authorconversion for the first author and the "normal"
authorconversion for the rest.

In the newer bibl-bib.lua file, I can see what I might have to modify to
accomplish this (I added the  if combiner == "invertedfirst"  block):

```
function authors.concat(author,combiner,what,settings)
if type(combiner) == "string" then
combiner = authors[combiner or "normal"] or authors.normal
end
local split = splitauthors(author)
local setting = settings[what]
local etallimit, etaldisplay, etaltext = 1000, 1000, ""
if setting then
etallimit   = settings.etallimit   or 1000
etaldisplay = settings.etaldisplay or etallimit
etalltext   = settings.etaltextor ""
end
local max = #split
if max > etallimit and etaldisplay < max then
max = etaldisplay
end
if combiner == "invertedfirst" then
for i=1,max do
if i == 1 then
split[i] = authors.inverted(split[i],settings)
else
split[i] = authors.normal(split[i],settings)
end

end
else
for i=1,max do
split[i] = combiner(split[i],settings)
end
end
local result = bibtexconcat(split,settings)
if max < #split then
return result
else
return result .. etaltext
end
end
```

Unfortunately, this doesn't seem to do anything. It's not clear to me
how bibl-bib.lua and bibl-bib.mkiv are being used by the other publication
support modules, if they're being used at all (publ-ini.mkiv doesn't appear
to register it, anyway). Is there another file I'd have to change to make
"invertedfirst" a working authorconversion? Is there a similar block of
code in publ-ini.lua where I should be implementing this change instead?

Thanks!

Joey
___
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] metafun doesn't compile \root 3 \of 2

2021-09-03 Thread fv leung via ntg-context
\starttext

\m{\root3\of2}

\stoptext

works.

But

\starttext

\startMPcode
  label("\m{\root3\of2}", origin);
\stopMPcode

\stoptext

doesn't.

Running `LuaMetaTeX' on `trial' with
``/home/fvleung/ConTeXt/tex/texmf-linux-64/bin/mtxrun --autogenerate
--script context trial.tex''

resolvers   | formats | executing runner 'run luametatex format':
/home/fvleung/ConTeXt/tex/texmf-linux-64/bin/luametatex --jobname="trial"
--fmt=/home/fvleung/ConTeXt/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.fmt
--lua=/home/fvleung/ConTeXt/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.lui
cont-yes.mkiv --c:currentrun=1 --c:fulljobname="./trial.tex"
--c:input="./trial.tex" --c:kindofrun=1 --c:maxnofruns=9
--c:texmfbinpath="/home/fvleung/ConTeXt/tex/texmf-linux-64/bin"
open source > level 1, order 1, name 'cont-yes.mkiv'
fonts   > beware: no fonts are loaded yet, using 'lm mono' in box
system  >
system  > ConTeXt  ver: 2021.07.27 19:27 LMTX  fmt: 2021.7.28  int:
english/english
system  >
system  > 'cont-new.mkxl' loaded
open source > level 2, order 2, name
'/home/fvleung/ConTeXt/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system  > beware: some patches loaded from cont-new.mkiv
close source> level 2, order 2, name
'/home/fvleung/ConTeXt/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system  > files > jobname './trial', input './trial.tex', result
'./trial'
fonts   > latin modern fonts are not preloaded
languages   > language 'en' is active
open source > level 2, order 3, name './trial.tex'
fonts   > preloading latin modern fonts (second stage)
fonts   > 'fallback modern-designsize rm 12pt' is loaded
metapost> initializing instance 'metafun:1' using format 'metafun'
and method 'default'
metapost> loading 'metafun' as 'metafun.mpxl' using method 'default'
metapost> initializing number mode 'scaled'
metapost> trace > This is MPLIB for LuaMetaTeX, version 3.11,
running in scaled mode.
metapost> trace >
metapost> trace > loading metafun for lmtx, including the plain
1.004 base definitions
metapost> trace >
tex error   > tex error on line 7 in file ./trial.tex: Argument of
\root has an extra }

32\normalstopimath \fi


\par

}
 }


 \global \setbox \mptextbox \hbox {\clf_mptexttoks
}


[[special cmd: end local call]]


\relax
...


 \stopMPcode

1 \starttext
2
3 \startMPcode
4   label("\m{\root3\of2}", origin);
5 \stopMPcode
6
7 >>  \stoptext
8
I've run across a '}' that doesn't seem to match anything. For example,
'\def\a#1{...}' and '\a}' would produce this error. The '\par' that I've
just
inserted will cause me to report a runaway argument that might be the root
of the
problem.
mtx-context | fatal error: return code: 256

TeX Output exited abnormally with code 1 at Fri Sep  3 17:44:19
___
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
___