Re: [NTG-context] [DKIM] Re: [DKIM] circuitikz module seems broken

2021-12-03 Thread Aditya Mahajan via ntg-context

On Fri, 3 Dec 2021, Jan-Erik Hägglöf via ntg-context wrote:

> The result of testing, different error messages in MKIV and LMTX.
> 
> The attached files belongs to LMTX run with the attached m-circuitikz.mkxl 
> and m-tikz.mkxl in texmf-local

Not placed at the right place. From your log file:

open source > level 2, order 3, name 
'/Users/jan-erikhagglof/context/context-osx-64/tex/texmf-local/m-circuitikz.mkxl'

(I am surprised it gets found! The should be texmf-local/tex/context/ sub-dir)

open source > level 3, order 4, name 
'/Users/jan-erikhagglof/context/context-osx-64/tex/texmf-context/tex/context/modules/mkxl/m-tikz.mkxl'

(I am guessing that this is the old m-tikz.mkxl).

For such experiments, it is simplest if you place the files in the current 
directory.

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] [DKIM] Re: [DKIM] circuitikz module seems broken

2021-12-03 Thread Aditya Mahajan via ntg-context
On Fri, 3 Dec 2021, Hans Hagen via ntg-context wrote:

> On 12/3/2021 10:49 AM, Hans Hagen via ntg-context wrote:
> 
> >> I’ve been struggeling with the circuitikz module since my upgrade to 
> >> LMTX.
> btw, We can have more 'catches' in the loader (t) module if needed. In 
> any case, also check if things work with mkiv. 

I tested the example on mkiv, I got error that dipchip and fliflop JK are not 
defined. The file compiles if I comment those out. But in LMTX, I also get a 
"missing semicolon" error. There is also this warning, which may have something 
to do with what is going wrong:

system  > module wrapping error in 'tikz'

The error appears to be related to keyword arguments. The following example 
works:

\usemodule[circuitikz]
\starttext
\startcircuitikz
\draw (0,2) to[I] (2,2) ;
\stopcircuitikz
\stoptext

But this does not:

\usemodule[circuitikz]
\starttext
\startcircuitikz
\draw (0,2) to[I=1] (2,2) ;
\stopcircuitikz
\stoptext


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] Syntax highlighting using LMTX

2021-12-02 Thread Aditya Mahajan via ntg-context
On Thu, 2 Dec 2021, Thangalin via ntg-context wrote:

> Hi all,
> 
> There are a few technical hurdles with using the t-vim module in LMTX.
> First, users need to install the module using externally defined shell
> scripts. Second, it's awkward to communicate to users how to install it,
> especially for Windows users. Third, it likely requires installing vim, as
> a separate step. Fourth, making general-purpose XML setups that optionally
> rely on syntax highlighting when it is an optional install is a little
> laborious.
> 
> If installing a module was as easy as "install.sh --module=t-vim" then that
> would leap over most hurdles. 

You can always install manually as follows:

cd $TEXMFHOME
wget https://mirrors.ctan.org/macros/context/contrib/context-{filter,vim}.zip
unzip context-{filter,vim}.zip

> Although there'd still be a dependency on installing vim. 

Yes, that's a trade-off that the vim module makes. But, last time I used 
Windows (some 10 years ago), installing vim was relatively easy. Download the 
install from vim's website, and click next a couple of times. 

> How would you go about creating a syntax highlighter for Java that can work
> with LMTX? 

I'll let others answer that. Had I known that, I wouldn't have written a module 
to do syntax highlighting :-) In the end, it also depends on how refined a 
syntax highlighter you want. Writing a simple keyword based highlighter is 
relatively easy. See, for example, scite-context-lexer-cpp.lua in the 
distribution, which is based on the CPP lexer in scite.

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] double underbars

2021-11-30 Thread Aditya Mahajan via ntg-context
On Tue, 30 Nov 2021, Taco Hoekwater via ntg-context wrote:

> 
> > Another question: what do you mean with a dy-shift version?
> 
> Nested bars have a parameter ‘dy’ which controls the vertical shifts needed 
> to make sure that they do not overlap. Text backgrounds do not have that 
> option at all.

There are backgroundoffset and frameoffset in framedtext ... not sure if they 
are inherited in text backgrounds. Or you can defining everything in metapost 
(but that may lose composability).

https://tex.stackexchange.com/a/125486/323

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] Typographical quotes

2021-11-27 Thread Aditya Mahajan via ntg-context
On Sat, 27 Nov 2021, Hans Hagen wrote:

> On 11/27/2021 6:40 PM, Aditya Mahajan via ntg-context wrote:
> > On Sat, 27 Nov 2021, Wolfgang Schuster via ntg-context wrote:
> > 
> > > Jean-Philippe Rey via ntg-context schrieb am 27.11.2021 um 16:21:
> > > > Dear list,
> > > > 
> > > > When typing a straight quotation mark, I used to get a curly apostrophe.
> > > > But
> > > with a recent version of ConTeXt, I now get a straight apostrophe. Is
> > > there a
> > > new option to convert automatically straight into curly apostrophes ?
> > > > 
> > > > \starttext
> > > > John's
> > > > \stoptext
> > > 
> > > The option is no longer part of the default feature set.
> > 
> > Personally, I think that that is a bit extreme. An apostrophe is a really
> > common construct and I suspect that this change in default will mean that
> > almost everyone needs to add tlig in their documents. We may perhaps need a
> > 'sensible-defaults' module :-)
> we entered the unicode world and left ascii space so for instance the ugly
> enter `` '' and expect english double quotes is also a not-done now, nor are
> !` and ?` for the spacing rotated ! and ?; i can't find the font right now but
> there were with interesting space-something ligatures that only didn't show up
> because tex has no space.

I am okay with removing all these vestiges of TeX. But, I still think that the 
following should work okay:

Let's try blah blah ...

I could have entered it as

Let’s try blah blah ..

but it is not that natural to me. 

> now, there are more tex traditions that context doesn't support; take this
> plain definition (there are many) dedicated to math users:

I am not opposed to remove 8bit TeX hacks. I was simply objecting for removing 
the apostrophe mapping. For example, you used it in the sentence above (in 
“don't”)!

> Anyway, it's easier to enabel a feature that to disable one when side effects
> of font handling kicks in happen.

I agree. Maybe I'll just add a imap in vim to map ' to ’ and forget about it

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] Typographical quotes

2021-11-27 Thread Aditya Mahajan via ntg-context
On Sat, 27 Nov 2021, Wolfgang Schuster via ntg-context wrote:

> Jean-Philippe Rey via ntg-context schrieb am 27.11.2021 um 16:21:
> > Dear list,
> >
> > When typing a straight quotation mark, I used to get a curly apostrophe. But
> with a recent version of ConTeXt, I now get a straight apostrophe. Is there a
> new option to convert automatically straight into curly apostrophes ?
> >
> > \starttext
> > John's
> > \stoptext
> 
> The option is no longer part of the default feature set. 

Personally, I think that that is a bit extreme. An apostrophe is a really 
common construct and I suspect that this change in default will mean that 
almost everyone needs to add tlig in their documents. We may perhaps need a 
'sensible-defaults' module :-)

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] Neovim and ConTeXt

2021-11-25 Thread Aditya Mahajan via ntg-context
On Thu, 25 Nov 2021, Nicola via ntg-context wrote:

> Again, take a look at the wiki.

Noted! Time to update my decade old setup (but I have moved completed to the 
neovim camp). 

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] Neovim and ConTeXt

2021-11-24 Thread Aditya Mahajan via ntg-context
On Wed, 24 Nov 2021, Clint Grady via ntg-context wrote:

> Are there any known ways to use ConTeXtLMTX with Neovim? 

Not that I am aware of. 

> I read the wiki page for Vim and it describes a hack to get latex-suite to 
> work with ConTeXt. [1] It wouldn't be too much work to submit a pull-request 
> to VimTeX (despite the name, this is for Neovim) [2] to add ConTeXt support, 
> but I don't want to duplicate work if someone else has already done it.

Please do so. There are different levels of what it means for a editor to 
support a language. I guess that you are talking about async compilation 
support, but keep in mind that context has a different error format than latex 
for that needs to be set different as well. It will be nice to have support to 
pass command line flags via the editor. Context also has a (slightly buggy) 
syntax checker (mtxrun --script check ..) which could be integrated.

I don't know what is the current state of context syntax highlighting support 
in vim/neovim (I use a highly modifies syntax file). It will be nice to have 
support of \startMP(code|page) and \startluacode to do syntax highlighting for 
metapost and lua. Metafun has added some new keywords and it will be nice to 
support those. I believe that context ships with a file that outputs all these 
keywords but I don't remember the name. 

It will be cool to have a more integrated support, like showing table of 
contents in the sidebar, (these are stored as a lua table in the tuc file and 
neovim has inbuilt lua interpreter, so...), modifying the jump keys so that so 
that ]] etc work correctly (with the context syntax) and so on. 

I'll be happy to test your pull request if you want. 

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] Bug in lmt_arrow

2021-11-21 Thread Aditya Mahajan via ntg-context
On Sat, 20 Nov 2021, Hans Hagen wrote:
> On 11/20/2021 6:53 AM, Aditya Mahajan via ntg-context wrote:
> > On Mon, 15 Nov 2021, Hans Hagen wrote:
> > 
> > > On 11/15/2021 4:07 AM, Aditya Mahajan wrote:
> > > > On Sun, 14 Nov 2021, Aditya Mahajan via ntg-context wrote:
> > > > 
> > > > > On Sun, 14 Nov 2021, Hans Hagen wrote:
> > > > > 
> > > > 
> > > > Spoke too soon. Now straight lines don't work:
> > > 
> > > new attempt (submitted to build)
> > 
> > The following still fails with ver 2021.11.19
> > 
> >  \starttext
> > 
> >  \startMPcode
> >newpath p;
> >ahfactor := 5;
> >p := origin .. (3cm,0);
> >draw lmt_arrow
> > [
> >   path = p,
> >   location = "percentage",
> >   percentage = 50,
> >   alternative = "curved",
> > ]
> > withpen pencircle scaled 1bp;
> >  \stopMPcode
> >  \stoptext
> > 
> > I get an error:
> > 
> > metafun > log >
> > metafun > log > error: This can't happen (division by zero)
> > metafun > log >
> bah, cycling between two failing tests ... new bin will be made on the farm in
> a moment

Thanks! Works perfectly now.

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] Bug in lmt_arrow

2021-11-19 Thread Aditya Mahajan via ntg-context
On Mon, 15 Nov 2021, Hans Hagen wrote:

> On 11/15/2021 4:07 AM, Aditya Mahajan wrote:
> > On Sun, 14 Nov 2021, Aditya Mahajan via ntg-context wrote:
> > 
> > > On Sun, 14 Nov 2021, Hans Hagen wrote:
> > > 
> > 
> > Spoke too soon. Now straight lines don't work:
> 
> new attempt (submitted to build)

The following still fails with ver 2021.11.19 

\starttext

\startMPcode
  newpath p;
  ahfactor := 5;
  p := origin .. (3cm,0);
  draw lmt_arrow
   [
 path = p, 
 location = "percentage",
 percentage = 50,
 alternative = "curved", 
   ]
   withpen pencircle scaled 1bp;
\stopMPcode
\stoptext

I get an error:

metafun > log >
metafun > log > error: This can't happen (division by zero)
metafun > log >

Thanks,
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] Can modes be used for content control?

2021-11-17 Thread Aditya Mahajan via ntg-context
On Tue, 16 Nov 2021, Idris Samawi Hamid ادريس سماوي حامد wrote:

> Hi Aditya,
> 
> Many thanks; see below:
> 
> On Tue, 16 Nov 2021 17:23:59 -0700, Aditya Mahajan via ntg-context
>  wrote:
> 
> > On Tue, 16 Nov 2021, Idris Samawi Hamid ادريس سماوي حامد via ntg-context
> > wrote:
> > 
> > > Dear gang,
> > > 
> > > For creating/authoring content in ConTeXt: Can modes or the like be used
> > > for content control? For example, someone wants to write at least two
> > > versions of a book managed from a single file. So, e.g., we may have
> > > 
> > > a) abridged content
> > > b) unabridged content - includes a)
> > > c) abridged content + translation
> > > d) unabridged content + translation
> > > [:]
> > > 
> > > One can author and organize this in XML - pre-ConteXt - but perhaps one
> > > prefers to write in ConTeXt (take advantage of shortcuts etc.). So maybe
> > > 
> > > \defineparagraphs[unabridged]
> > > \defineparagraphs[abridged]
> > > \defineparagraphs[translation]
> > > 
> > > Then one authors the complete work in a single project, but you can
> > > produce a variety of versions, depending on the mode chosen:
> > > 
> > > \definemode[unabridged]
> > > etc.
> > > 
> > > Can one do this in context?
> > 
> > Yes!
> > 
> > This is what I do (for solutions in homework assignments):
> > 
> > \definebuffer[solution][local=yes,nested=yes]
> > 
> > \startmode[solution]
> > \defineenumeration[solution][fancy setup...]
> > \stopmode
> > 
> > Then, in the main tex file:
> > 
> > 
> > \startsolution
> > ...
> > \stopsolution
> > 
> > 
> > By default, gives the version without solution. Compile with --mode=solution
> > to get the version with solution. The same thing should work in your case by
> > defining two modes: unabridged and translation. And then use
> > --mode=unabridged,translate etc to get multiple modes.
> 
> Here's a working sample:
> 
> ===
> % \definebuffer[unabridged]
> % \definebuffer[abridged]
> 
> \setupwhitespace[big]
> 
> \starttext
> \startmode[unabridged]
> \input knuth
> 
> \startblockquote
> \input ward
> \stopblockquote
> 
> % \startmode[abridged]
> % \input knuth
> % \stopmode
> \stopmode
> 
> \startmode[abridged]
> \input knuth
> \stopmode
> 
> % \startmode[abridged]
> % \input zapf
> % \stopmode
> \stoptext
> ===
> 
> Unfortunately - as pointed out on the wiki - modes cannot be nested.

But you don't have to directly use the modes. The following will work:

\definestartstop[abridged]

% By default, don't show the unabridged text
\definebuffer[unabridged][local=yes, nested=yes]

\startmode[unabridged]
% In the unabridged mode, show the abridged text
\definestartstop[unabridged]
\stopmode

\starttext
\startabridged
\input knuth

\startunabridged
\startblockquote
\input ward
\stopblockquote
\stopunabridged

\input zapf
\stopabridged

Blocks are a better mechanism, but I still prefer modes here because I find the 
\beginblock ... \endblock syntax to be a bit awkward in a context document.

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] Can modes be used for content control?

2021-11-16 Thread Aditya Mahajan via ntg-context
On Tue, 16 Nov 2021, Idris Samawi Hamid ادريس سماوي حامد via ntg-context wrote:

> Dear gang,
> 
> For creating/authoring content in ConTeXt: Can modes or the like be used  
> for content control? For example, someone wants to write at least two  
> versions of a book managed from a single file. So, e.g., we may have
> 
> a) abridged content
> b) unabridged content - includes a)
> c) abridged content + translation
> d) unabridged content + translation
> [:]
> 
> One can author and organize this in XML - pre-ConteXt - but perhaps one  
> prefers to write in ConTeXt (take advantage of shortcuts etc.). So maybe
> 
> \defineparagraphs[unabridged]
> \defineparagraphs[abridged]
> \defineparagraphs[translation]
> 
> Then one authors the complete work in a single project, but you can  
> produce a variety of versions, depending on the mode chosen:
> 
> \definemode[unabridged]
> etc.
> 
> Can one do this in context? 

Yes!

This is what I do (for solutions in homework assignments):

\definebuffer[solution][local=yes,nested=yes]

\startmode[solution]
\defineenumeration[solution][fancy setup...]
\stopmode

Then, in the main tex file:


\startsolution
...
\stopsolution


By default, gives the version without solution. Compile with --mode=solution to 
get the version with solution. The same thing should work in your case by 
defining two modes: unabridged and translation. And then use 
--mode=unabridged,translate etc to get multiple modes.

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] SimpleSlides and Visual counters

2021-11-16 Thread Aditya Mahajan via ntg-context
On Mon, 15 Nov 2021, Otared Kavian via ntg-context wrote:

Hi Otared,

> It seems that the visual counter in  SimpleSlides module (the version I have 
> from ConTeXt Garden is from 2014) does not work fine with the latest LMTX.
> Is the issue is known ? If so, is there a new version of SimpleSlides in 
> which the issue has been fixed ?

I haven't looked at simpleslides in over a decade! The module did use some 
low-level macros, which are unlikely to work with LMTX without change. 

It could also be a bug with visualcounter module. I haven't tested in with LMTX 
(I still use MkIV for most of my presentations). If you can post a minimal 
example, I could take a look.

Thanks,
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] unknown script

2021-11-16 Thread Aditya Mahajan via ntg-context

On Tue, 16 Nov 2021, skyhorse--- via ntg-context wrote:

> 
> OS: Linux (Ubuntu 20.04.3)
> /opt/context-lmtx   and all directories and files in it are owned by user 
> and not root.
> 
> I've had this problem before but forgot how to deal with it and neglected to 
> make a not of it.
> I deleted all old context files and did a fresh install of context-lmtx 
> without su priveledges today. When attempting to typeset a lmtx source file I 
> get an 'unknown script' error.
> 
> Here's what pops up on my display screen:
> 
> $ context simple-example.lmtx
> resolvers   | resolving | configuration files already identified
> resolvers   | resolving | loading configuration file 
> 'selfautoparent:/texmf/web2c/texmfcnf.lua'
> resolvers   | resolving |
> resolvers   | resolving | locating list of '/opt/context-lmtx/tex/texmf' 
> (runtime) (tree:opt/context-lmtx/tex/texmf)
> resolvers   | methods | resolving, method 'locators', how 'uri', handler 
> 'tree', argument 'tree:opt/context-lmtx/tex/texmf'
> resolvers   | trees | locator '/opt/context-lmtx/tex/texmf' found
> resolvers   | resolving | hash '/opt/context-lmtx/tex/texmf' appended
> resolvers   | resolving |
> resolvers   | methods | resolving, method 'generators', how 'uri', 
> handler 'file', argument '/opt/context-lmtx/tex/texmf'
> resolvers   | expansions | using cached scan of path 
> '/opt/context-lmtx/tex/texmf', branch '/opt/context-lmtx/tex/texmf'
> resolvers   | methods | resolving, method 'generators', how 'uri', 
> handler 'file', argument '/opt/context-lmtx/tex/texmf'
> resolvers   | expansions | using cached scan of path 
> '/opt/context-lmtx/tex/texmf', branch '/opt/context-lmtx/tex/texmf'
> resolvers   | resolving |
> resolvers   | resolving | not saving runtime tree 
> '/opt/context-lmtx/tex/texmf'
> resolvers   | resolving | not saving runtime tree 
> '/opt/context-lmtx/tex/texmf'
> resolvers   | resolving | remembered file 'mtx-context.lua'
> resolvers   | resolving | remembered file 'mtx-contexts.lua'
> resolvers   | resolving | remembered file 'mtx-context.lua'
> resolvers   | resolving | remembered file 'mtx-t-context.lua'
> resolvers   | resolving | remembered file 'mtx-t-contexts.lua'
> resolvers   | resolving | remembered file 'mtx-t-context.lua'
> resolvers   | resolving | remembered file 'context.lua'
> mtxrun  | unknown script 'context.lua' or 'mtx-context.lua'
> 
> # END
> 
> Can anyone shed some light on how this should be handled?

mtxrun --generate


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] mwe (font proble) SOLVED

2021-11-14 Thread Aditya Mahajan via ntg-context
On Sun, 14 Nov 2021, skyhorse--- via ntg-context wrote:

> 
> Solved.  Well almost.  I do know that it's an access problem of some sort.
> I used 'font-manager' to look at fonts and it showed  'DejaVu Math Tex Gyre' 
> as "disabled"
> For su is shows the font as usable.
> When context is run su, it compiles successfully.
> So the fonts are there.  The example does work, but, not for me as user.
> I for some reason have the some fonts disabled.
> I'll figure out how to enable them.

Most likely, you installed context using `su` or `sudo`. It is possible that 
the directory where the fonts are installed are not readable by the user. 

The simple work-around is to install context as a regular user so that you have 
the permissions to read the font files.

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] Bug in lmt_arrow

2021-11-14 Thread Aditya Mahajan via ntg-context
On Sun, 14 Nov 2021, Aditya Mahajan via ntg-context wrote:

> On Sun, 14 Nov 2021, Hans Hagen wrote:
> 
> > On 11/14/2021 4:33 AM, Aditya Mahajan via ntg-context wrote:
> > > Hi,
> > > 
> > > There is a bug in lmt_arrow. If given a "non-cycle" path, lmt_arrow
> > > completes the cycle.
> > > 
> > >  \starttext
> > > 
> > >  \startMPcode
> > >newpath p;
> > >ahfactor := 5;
> > >p := origin .. (1cm, 1cm) .. (2cm, 0);
> > >draw lmt_arrow
> > > [
> > >   path = p,
> > >   location = "percentage",
> > >   percentage = 50,
> > >   alternative = "curved",
> > > ]
> > > withpen pencircle scaled 1bp;
> > >  \stopMPcode
> > >  \stoptext
> > > 
> > > With 2021.11.11, I get the attached file. Note that lmt_arrow has drawn 
> > > the
> > > "cycle" version of the path, even though p does not have a cycle.
> > > 
> > > I have looked at the code and cannot figure out why this is happening.
> > 
> > it happens in the 'direct' variant (metapost.registerdirect) where a boolean
> > is passed as signal and that boolean then is also picked up by the (shared)
> > path injector as (old school) signal that a path is closed while it should
> > instead consutl the closed field in a path table (sounds more complex than 
> > it
> > is)
> > 
> > so in the end it is a nasty side effect of the fast inject code path (shared
> > function with different stack values; i'll probably have to ditch a "low 
> > level
> > backward compatibility feature no one uses anyway" some day)
> > 
> > i uploaded a fix that you can test when the bins are compiled at
> > 
> > https://build.contextgarden.net/#/waterfall?tags=c.luametatex
> > 
> > new bins then in:
> > 
> > https://dl.contextgarden.net/build/luametatex/
> > 
> > (fyi: in the mp code you see that the path p is 'get' from the lua end where
> > it got passed to by parameter)
> 
> Thanks! Works perfectly here.

Spoke too soon. Now straight lines don't work:

\starttext

\startMPcode
  newpath p;
  ahfactor := 5;
  p := origin .. (3cm,0);
  draw lmt_arrow
   [
 path = p, 
 location = "percentage",
 percentage = 50,
 alternative = "curved", 
   ]
   withpen pencircle scaled 1bp;
\stopMPcode
\stoptext


gives

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 > 
metafun > log >
metafun > log > error: This can't happen (division by zero)
metafun > log >
metapost> trace >  arrowhead ->  -> 
begingroup.save.q,e,r;pair.e;e=point.length(EXPR2)of(EXPR2);path.q;q=gobble((EXPR2)shifted-e.cutafter.makepath(pencircle.scaled(2ahlength)))cuttings;if.ahvariant>0:path.r;r=gobble((EXPR2)shifted-e.cutafter.makepath(pencircle.scaled((1-ahdimple)*2ahlength)))cuttings;fi(q.rotated(ahangle/2)(ahangle/2)if.ahvariant=1:--point0of.r--elseif.ahvariant=2:...point0of.r...else:--fi.cycle)shifted.e.endgroup
metapost> trace >  endgroup
metapost> trace >  pushparameters "arrow" ; save a ; string a 
; a := getparameter "alternative" ; save l ; string l ; l := getparameter 
"location" ; save k ; string k ; k := getparameter "kind" ; save p ; path p ; p 
:= getparameter "path" ; interim ahvariant := if a = "dimpled" : 1 elseif a = 
"curved" : 2 else : 0 fi ; interim ahdimple := getparameter "dimple" ; interim 
ahscale := getparameter "scale" ; interim ahangle := getparameter "angle" ; 
interim ahlength := getparameter "length" ; if not getparameter "headonly" : 
draw p ; fi ; if hasparameter "pen" : if hasoption "pen" "auto" : ahlength := ( 
getparameter "penscale" ) * boundingradius ( currentpen ) ; else : ahlength := 
( getparameter "penscale" ) * boundingradius ( getparameterpen "pen" ) ; fi ; 
fi ; if k = "draw" : draw elseif k = "both" : filldraw else : fill fi if l = 
"middle" : midarrowhead p ; elseif l = "percentage" : arrowheadonpath ( p , ( 
getparameter "percentage" ) / 100 ) ; elseif l = &quo

Re: [NTG-context] Bug in lmt_arrow

2021-11-14 Thread Aditya Mahajan via ntg-context
On Sun, 14 Nov 2021, Hans Hagen wrote:

> On 11/14/2021 4:33 AM, Aditya Mahajan via ntg-context wrote:
> > Hi,
> > 
> > There is a bug in lmt_arrow. If given a "non-cycle" path, lmt_arrow
> > completes the cycle.
> > 
> >  \starttext
> > 
> >  \startMPcode
> >newpath p;
> >ahfactor := 5;
> >p := origin .. (1cm, 1cm) .. (2cm, 0);
> >draw lmt_arrow
> > [
> >   path = p,
> >   location = "percentage",
> >   percentage = 50,
> >   alternative = "curved",
> > ]
> > withpen pencircle scaled 1bp;
> >  \stopMPcode
> >  \stoptext
> > 
> > With 2021.11.11, I get the attached file. Note that lmt_arrow has drawn the
> > "cycle" version of the path, even though p does not have a cycle.
> > 
> > I have looked at the code and cannot figure out why this is happening.
> 
> it happens in the 'direct' variant (metapost.registerdirect) where a boolean
> is passed as signal and that boolean then is also picked up by the (shared)
> path injector as (old school) signal that a path is closed while it should
> instead consutl the closed field in a path table (sounds more complex than it
> is)
> 
> so in the end it is a nasty side effect of the fast inject code path (shared
> function with different stack values; i'll probably have to ditch a "low level
> backward compatibility feature no one uses anyway" some day)
> 
> i uploaded a fix that you can test when the bins are compiled at
> 
>   https://build.contextgarden.net/#/waterfall?tags=c.luametatex
> 
> new bins then in:
> 
>   https://dl.contextgarden.net/build/luametatex/
> 
> (fyi: in the mp code you see that the path p is 'get' from the lua end where
> it got passed to by parameter)

Thanks! Works perfectly here.

> (interesting that it didn't show up sooner, maybe most users have closed paths
> and/or most lmt_ features used closed paths)

I was reusing two year old code and took me a while to figure out why the 
output was suddenly wrong. 

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] Bug in lmt_arrow

2021-11-13 Thread Aditya Mahajan via ntg-context
Hi,

There is a bug in lmt_arrow. If given a "non-cycle" path, lmt_arrow completes 
the cycle. 

\starttext

\startMPcode
  newpath p;
  ahfactor := 5;
  p := origin .. (1cm, 1cm) .. (2cm, 0);
  draw lmt_arrow
   [
 path = p, 
 location = "percentage",
 percentage = 50,
 alternative = "curved", 
   ]
   withpen pencircle scaled 1bp;
\stopMPcode
\stoptext

With 2021.11.11, I get the attached file. Note that lmt_arrow has drawn the 
"cycle" version of the path, even though p does not have a cycle.

I have looked at the code and cannot figure out why this is happening.

Thanks,
Aditya

test.pdf
Description: Adobe PDF document
___
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] rule beneath chapter number

2021-11-11 Thread Aditya Mahajan via ntg-context
On Fri, 12 Nov 2021, jbf via ntg-context wrote:

> The following MWE deliberately shows two ways of getting a short rule 
> beneath a chapter number, but neither achieve what I want. \underbar is 
> too close to the number 

\setupbar[underbar][offset=-0.8] % play around with the number

> and \crlf\blackrule too far below. So basically 
> my question is: is there a way of adjusting the position of a brief rule 
> beneath the number? 

\defineframed[underbarframed]
 [
   frame=off,
   rulethickness=1pt,
   bottomframe=on,
   frameoffset=-1pt, % negative of rulethickness
   boffset=0.8ex, % play around with this
 ]


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] Achieving the effect of \overset outside math mode

2021-11-11 Thread Aditya Mahajan via ntg-context
On Fri, 12 Nov 2021, kauśika via ntg-context wrote:

> Dear list,
> 
> I don't have a MWE per se, but as the title suggests, I want to be able to 
> achieve the effect of \overset outside math mode. As I understand, \overset 
> itself is implemented using \mathop and \limits. 
> 
> Currently to achieve this I have defined some macros using \offset thus :
> \define[1]\pabv{\dontleavehmode\offset[width=0em,y=-16pt,x=3pt]{#1}}
> Unfortunately, I have to hard code the x values. So I have define several 
> such 
> macros with different offsets. Not an elegant solution, but it is what I 
> could 
> muster.
> 
> So, my objective is to place a smaller piece of text above another larger 
> piece of text so that the text above is centered w.r.t the text below.

Wolfgang has a ruby module, which provides this feature.

https://ctan.org/pkg/context-ruby

Doc: 
https://ctan.org/tex-archive/macros/context/contrib/context-ruby/doc/context/third/ruby

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] Cannot access Lua function

2021-11-01 Thread Aditya Mahajan via ntg-context
On Sun, 31 Oct 2021, Hans Hagen via ntg-context wrote:

> in that case you probably need to hide more .. (when you process with 
> \nopdfcompression at the top you can look in the pdf, i.e. compression 
> is not encryption
> 
> one thing you can do is make a copy of lpdf-xmp.lmt and wipe all tricky 
> values and then use that to make a format
> 
> but if security is important, maybe better is to use "qpdf" to encrypt 
> the file (you can then also prevent editing for instance)

qpdf is also good at stripping metadata:

qpdf --empty --pages input.pdf -- output.pdf


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] Converting LaTeX math to ConTeXt

2021-10-12 Thread Aditya Mahajan via ntg-context
On Tue, 12 Oct 2021, Jason Ross wrote:

> 
> 
> On 10/11/21 4:02 PM, Aditya Mahajan wrote:
> > You can use pandoc to parse latex and convert it to mathml:
> > 
> > Processing this in context (see attached files), gives a partially working
> > solution. It doesn't look okay, but should be easily fixable.
> > 
> > Do note that this is almost same as compiling latex output to PDF because
> > editing presentation mathml by hand is no fun.
> 
> Hmm. Looks like converting to MathML isn't going to work just yet.
> Is this an issue with ConTeXt? The MathML seems to render correctly in
> LibreOffice but gets mangled when exporting to ConTeXt.

This is an issue with ConTeXt, but most of these issues are minor are easy to 
fix. Just send minimal examples showing the incorrect rendering.

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] Converting LaTeX math to ConTeXt

2021-10-11 Thread Aditya Mahajan via ntg-context
On Sun, 10 Oct 2021, Jason Ross via ntg-context wrote:

> On 10/10/21 3:23 AM, Hans Hagen wrote:
> 
> These are just a couple examples, but in general it's not enough to do
> naive string substitution in LaTeX and get valid ConTeXt back, and my
> patchwork solutions are starting to smell.

You can use pandoc to parse latex and convert it to mathml:

$ cat math.tex

\documentclass{amsart}
\begin{document}
\begin{align}
 a &= \begin{pmatrix}
1 & 2 & 3 \\
1 & 2 & 3 \\
1 & 2 & 3
 \end{pmatrix},
 b &= \begin{pmatrix}
1 & 2 & 3 \\
1 & 2 & 3 \\
1 & 2 & 3
 \end{pmatrix},
 \\
 c &= \begin{pmatrix}
1 & 2 & 3 \\
1 & 2 & 3 \\
1 & 2 & 3
 \end{pmatrix},
 d &= \begin{pmatrix}
1 & 2 & 3 \\
1 & 2 & 3 \\
1 & 2 & 3
 \end{pmatrix},
\end{align}
\end{document}

$ pandoc -f latex -t html --mathml math.tex


http://www.w3.org/1998/Math/MathML;>a=(123123123),b=(123123123),c=(123123123),d=(123123123),\begin{aligned}
 a = \begin{pmatrix}
1  2  3 \\
1  2  3 \\
1  2  3
 \end{pmatrix},
 b = \begin{pmatrix}
1  2  3 \\
1  2  3 \\
1  2  3
 \end{pmatrix},
 \\
 c = \begin{pmatrix}
1  2  3 \\
1  2  3 \\
1  2  3
 \end{pmatrix},
 d = \begin{pmatrix}
1  2  3 \\
1  2  3 \\
1  2  3
 \end{pmatrix},\end{aligned}

Processing this in context (see attached files), gives a partially working 
solution. It doesn't look okay, but should be easily fixable.

Do note that this is almost same as compiling latex output to PDF because 
editing presentation mathml by hand is no fun.

Aditya

test.tex
Description: TeX document


test.pdf
Description: Adobe PDF document
___
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] running tikz

2021-09-30 Thread Aditya Mahajan via ntg-context
On Thu, 30 Sep 2021, Henri Menke via ntg-context wrote:

> On Thu, 2021-09-30 at 11:57 +0200, Alain Delmotte via ntg-context
> wrote:
> > Hi!
> > 
> > I would like to use tikz to benefit of the package "pgf-soroban" I
> > did write for LaTeX (after adapting it and before, later, to
> > translate it to metapost).
> > 
> > I did try the sample program from the tikz manual, but I get an error
> > saying that "t-pgf.tex" is not found; but it is in the tree of
> > ConTeXt-lmtx.
> > 
> > How to make all the files in the distribution known to the compiler?
> 
> 
> Note that there is currently no proper support for LMTX in PGF/TikZ.
> 
> https://github.com/pgf-tikz/pgf/issues/990

Interesting... it seems that only a few features don't work. I regularly use 
pgfplots, and haven't noticed any compatibility issues in my examples.

What will be needed to add a LMTX "driver" for TikZ? Porting pgfsys-luatex.def 
to pgfsys-luametatex.def? Or is something else also needed?

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] running tikz

2021-09-30 Thread Aditya Mahajan via ntg-context
On Thu, 30 Sep 2021, Alain Delmotte via ntg-context wrote:

> 
> Hi!
> 
> I would like to use tikz to benefit of the package "pgf-soroban" I did write 
> for
> LaTeX (after adapting it and before, later, to translate it to metapost).
> 
> I did try the sample program from the tikz manual, but I get an error saying
> that "t-pgf.tex" is not found; but it is in the tree of ConTeXt-lmtx.

How did you install TikZ? The error message seems to suggest that tikz module 
is not installed. You can check by looking at the output of 

mtxrun t-pgf.tex

On my system, that gives:

/opt/luametatex/texmf-modules/tex/context/pgf/basiclayer/t-pgf.tex

(which I had installed the texmf-modules tree by copying from the context 
standalone tree.

> How to make all the files in the distribution known to the compiler?

By putting them in the right location in the tree (somewhere inside 
$TEXMF/tex/context ...). 

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] Weird error when using \startformula inside lua

2021-09-11 Thread Aditya Mahajan via ntg-context
On Sat, 11 Sep 2021, Hans Hagen wrote:

> On 9/11/2021 5:11 AM, Aditya Mahajan via ntg-context wrote:
> > I sometimes define lua functions for showing out worked out calculations.
> > The following minimal example shows that
> > 
> >context([[\startformula ... \stopformula]])
> > 
> > fails in LMTX with an error message:
> > 
> > tex error   > tex error on line 3 in file ./test.tex: Undefined control
> > sequence \undefined
> > 
> > MWE:
> > 
> > \startluacode
> >thirddata = thirddata or {}
> > 
> >local comment = [[
> >  This is a famous formula
> >  \startformula
> >a^2 + b^2 = c^2
> >  \stopformula
> >]]
> > 
> >function thirddata.explanation()
> >context(comment)
> >end
> > 
> > \stopluacode
> > 
> > \starttext
> > \ctxlua{thirddata.explanation()}
> > \stoptext
> > 
> > The actual use case is more complicated (where I use templates, so I don't
> > want to convert everything to context.startformula() etc.). The example
> > compiles with MkIV but not LMTX.
> > 
> > Any idea what is going on?
> \enabletrackers[context*]
> 
> shows that we have an unprotected \startformula so we need this in
> strc-mat.mkxl:
> 
> \permanent\protected\defcsname\e!start\v!formula\endcsname{\strc_formulas_start_formula{}}
> \permanent\protected\defcsname\e!stop
> \v!formula\endcsname{\strc_formulas_stop_formula}
> 
> \permanent\tolerant\protected\def\defineformulaalternative[#1]#*[#2]#*[#3]%
>   {\frozen\instance\protected\defcsname\e!start#1\v!formula\endcsname{#2}%
>\frozen\instance\protected\defcsname\e!stop #1\v!formula\endcsname{#3}}
> 
> (the \protected probably got lost when i added overload protection etc)

Thanks! This fixes the error in my main document as well.

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] Weird error when using \startformula inside lua

2021-09-10 Thread Aditya Mahajan via ntg-context
I sometimes define lua functions for showing out worked out calculations. The 
following minimal example shows that 

  context([[\startformula ... \stopformula]]) 

fails in LMTX with an error message:

tex error   > tex error on line 3 in file ./test.tex: Undefined control 
sequence \undefined 

MWE:

\startluacode
  thirddata = thirddata or {}

  local comment = [[
This is a famous formula
\startformula
  a^2 + b^2 = c^2
\stopformula
  ]]

  function thirddata.explanation()
  context(comment)
  end

\stopluacode

\starttext
\ctxlua{thirddata.explanation()}
\stoptext

The actual use case is more complicated (where I use templates, so I don't want 
to convert everything to context.startformula() etc.). The example compiles 
with MkIV but not LMTX.

Any idea what is going on?

Thanks,
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] Use MetaPost to distort images?

2021-09-05 Thread Aditya Mahajan via ntg-context
On Sun, 5 Sep 2021, Henning Hraban Ramm via ntg-context wrote:

> 
> > Am 05.09.2021 um 10:10 schrieb Hans Hagen :
> >> BTW, here’s my script:
> >> Here are some results:
> > 
> > Did you try that with the filter module? It would make it more portable
> 
> I completely forgot I could do that (and I even know how).

See attached. Basically, you can just copy-paste your script as the value of 
the filtercommand, and that's it. 

Aditya

PS: I realized that there is a regression, and \externalfilterbasefile does not 
remove the file extension. So, the output is named mill.png-taped.png rather 
than mill-taped.png. I'll look into it later

rotate.tex
Description: TeX document
___
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
___


Re: [NTG-context] problem with MkIV/TeXlive/TEXMFCACHE

2021-08-30 Thread Aditya Mahajan via ntg-context
On Mon, 30 Aug 2021, Rainer J.H. Brandt via ntg-context wrote:

> But, as I said, my texmf.cnf sets TEXMFCACHE to $TEXMFSYSVAR;$TEXMFVAR,
> and TEXMFSYSVAR is /var/opt/texlive.  Why is that ignored?

mtxrun (and context MKIV and LMTX) do not read texmf.cnf rather read values 
from contextcnf.lua (it used to be texmfcnf.lua, not sure how TL handles this).

You can also try setting it explicitly in the shell:

$ TEXMFCACHE=/var/opt/texlive/texmf-cache mtxrun --generate

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 update/t-vim (again)

2021-08-24 Thread Aditya Mahajan via ntg-context
On Mon, 23 Aug 2021, Aditya Mahajan via ntg-context wrote:

> On Mon, 23 Aug 2021, Benjamin Buchmuller via ntg-context wrote:
> 
> > This is the setup I have been using, but I'm unsure if the problem could be 
> > related to the other problem I had. (Not scaled to a MWE, but short 
> > enough.) I figured the issue by removing some of the lines.
> 
> I get the same error. Most likely due to some grouping issue because there is 
> also this:
> 
> system  > invalid \starttext ... \stoptext structure
> 
> I'll look into it.

The error was due to the change in job.files.run macro. I have adapted the 
t-filter module to use the new interface. So, the error should go away if you 
update your installed modules.

Thanks for the bug report.

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] numbered exercises

2021-08-24 Thread Aditya Mahajan via ntg-context
On Tue, 24 Aug 2021, Henning Hraban Ramm via ntg-context wrote:

> > Am 24.08.2021 um 21:17 schrieb Wolfgang Schuster via ntg-context 
> > :
> > 
> > Henning Hraban Ramm via ntg-context schrieb am 24.08.2021 um 20:31:
> >> Hi, I’m typesetting a textbook that contains numbered and indented 
> >> exercises. They must not float.
> >> 
> >> Which structure should I use for them? There must be an easy answer, but I 
> >> draw a blank.
> > 
> > Use an enumeration.
> 
> Thank you, but how can I define a title/caption for the enumeration and its 
> reference?

http://www.ntg.nl/maps/36/09.pdf

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 update/t-vim (again)

2021-08-23 Thread Aditya Mahajan via ntg-context
On Mon, 23 Aug 2021, Benjamin Buchmuller via ntg-context wrote:

> This is the setup I have been using, but I'm unsure if the problem could be 
> related to the other problem I had. (Not scaled to a MWE, but short enough.) 
> I figured the issue by removing some of the lines.

I get the same error. Most likely due to some grouping issue because there is 
also this:

system  > invalid \starttext ... \stoptext structure

I'll look into it.

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 update

2021-08-19 Thread Aditya Mahajan via ntg-context
On Thu, 19 Aug 2021, Hans Hagen via ntg-context wrote:

> Hi,
> 
> Here are the highlights of todays update:
> 
> - somewhat more compact tuc files, not for all documents, but it can 
> accumulate; also less memory used then; i could bring down an extreme 
> 2000 page 5 column doc tuc file down to 5% -- it was 70 MB; for the 
> luametatex manual it reducec the tuc more than 30%; hard to tell if 
> there will be an associated performance hit, but i'm sure thomas will 
> complain if that's the case

I never realized that tuc files can grow so big. For big documents, would it 
make sense to simply read and write zipped tuc files?

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] Size of root symbol

2021-08-18 Thread Aditya Mahajan via ntg-context
On Wed, 18 Aug 2021, Bruce Horrocks via ntg-context wrote:

> Is there a simple way to get both root signs in this MWE to be the same size?
> 
> \starttext
> \startformula
> \sqrt[3]{4n} \ne \sqrt[3] {n}
> \stopformula
> \stoptext

Make the quantities whose roots are being taken to be of the same size.

\starttext

% The simplest solution:
\startformula
\sqrt[3]{4n} \ne \sqrt[3] {\vphantom{4} n}
\stopformula

% More general
% \strut = \vphantom{(}, which is too big
\startformula
\sqrt[3]{\strut 4n} \ne \sqrt[3] {\strut n}
\stopformula

% We can define our own phantom sizes. You can play around with the numbers.
\define\filler{\vrule width 0pt height 2ex depth 0.3ex \relax}
\startformula
\sqrt[3]{\filler 4n} \ne \sqrt[3] {\filler n}
\stopformula

\stoptext

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] Progressively encouraging page/column breaks at \blank with penalties

2021-08-14 Thread Aditya Mahajan via ntg-context
On Sun, 15 Aug 2021, Joey McCollum via ntg-context wrote:

> Hi,
> 
> I'm trying to implement a section break marker in a grid layout. At a
> section break, two lines of space should separate the subsequent segments
> of text (just plain paragraphs, in this case), and a symbol (in the example
> below, "X") should be set in the middle of these two lines. For my
> purposes, the section break symbol should never occur at the top of a page
> or column, and it is more desirable to have a page or column end with the
> section break symbol than to have a single orphaned line follow the symbol
> at the end of the page or column. Based on these constraints, I thought
> that using the "samepage" and "preference" options for the first and second
> line breaks would work nicely:
> 
> ```
> \define\SectionBreak{%
> \blank[halfline, samepage]% non-breaking to ensure that no column
> begins with the section break symbol
> \startalignment[middle]%
> {X}% section break symbol
> \stopalignment%
> \blank[halfline, preference]% this can (and, if possible, should) be
> broken across a column
> ```
> 
> This does successfully prevent the placement of the symbol at the top of a
> page/column, but it doesn't encourage the placement of the symbol at the
> end of a page/column as often as I would like. 

Depending on what you want, you can try adding \testpage[n] (where n is a 
number). This checks if the remainder of the page has enough space for n lines; 
if not, then it issues a page-break.

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] new upload/issue with t-vim?

2021-08-13 Thread Aditya Mahajan via ntg-context
On Mon, 9 Aug 2021, Hans Hagen wrote:

> On 8/8/2021 11:53 PM, Aditya Mahajan via ntg-context wrote:
> > On Sun, 8 Aug 2021, Hans Hagen via ntg-context wrote:
> > 
> > > On 8/8/2021 1:13 PM, Benjamin Buchmuller via ntg-context wrote:
> > > > I'm not sure if it's related to this latest:
> > > > 
> > > > ConTeXt  ver: 2021.08.07 22:53 LMTX  fmt: 2021.8.8  int: english/english
> > > > 
> > > > or a previous one, but with this one:
> > > > 
> > > > ConTeXt  ver: 2021.07.30 00:57 LMTX  fmt: 2021.8.8  int: english/english
> > > > 
> > > > My document compiled fine.
> > > > 
> > > > When I use the t-vim module (freshly installed again from the garden;
> > > > but I
> > > also tried to replace some files from the GitHub, but not sure if I did it
> > > right …), I now get an error when I do something like
> > > > 
> > > > \usemodule[vim]
> > > > 
> > > > \definevimtyping[vimR]
> > > > 
> > > > \typevimRfile{path_to_file.R} % specifically: {../sourcecodes/myfile.R}
> > > > 
> > > > --
> > > > 
> > > > lua error > lua error on line 2 in file virtual://block.sourcecode.7:
> > > > 
> > > > token call, execute:
> > > ...ConTeXt/tex/texmf-context/tex/context/base/mkiv/l-io.lua:70: bad
> > > argument
> > > #1 to '?' (string expected, got nil)
> > > i'll check it, i cleaned up some code but didn't realize that it was
> > > used in a module
> > 
> > This was also reported on t-vim's github page:
> > https://github.com/adityam/filter/pull/48.
> > 
> > I basically use jobs.file.run to cache the results and I can easily write a
> > module specific version of that, if needed. I'll look at it in a day or two
> > (away from a stable internet connection until then).
> blame me for this one
> 
> just wait for the update (i added the name,action interface again as i assumes
> the { filename =, action= } usage)

For the record, the vim module is working again with version 2021.08.10. Thanks 
Hans!

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] nil from TeX to Lua

2021-08-09 Thread Aditya Mahajan via ntg-context
On Mon, 9 Aug 2021, Hans van der Meer via ntg-context wrote:

> In the TeX to Lua interface with
> 
> \def\Macro#1{\directlua{luafunction("#1")}}
> 
> the transfer from TeX to Lua is by string. However what to do at the Lua end 
> when calling \Macro{}?
> As I understand it, then on the Lua side an empty argument and an empty 
> string are indistinguishable. 

That is not the case:

$ echo 'print("" == nil)' | lua
false

> This is not always wanted, for example when one needs to place either a nil 
> or an empty string into a Lua table. I am running in trouble when to t.key 
> set to \Macro{} should become nil or when it should become "".

If you call luafunction(""), the string is empty and not nil. 

\startluacode
  userdata = userdata or {}
  function userdata.macro(str)
  if str == nil then
  context("Argument is nil")
  elseif str == "" then
  context("Argument is empty")
  else 
  context("Argument is %s", str)
  end
  end
\stopluacode

\define[1]\Macro{\ctxlua{userdata.macro([==[#1]==])}}

\starttext

\startlines
\Macro{}
\Macro{ABC}
\ctxlua{userdata.macro()}
\stoplines
\stoptext


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] new upload/issue with t-vim?

2021-08-08 Thread Aditya Mahajan via ntg-context
On Sun, 8 Aug 2021, Hans Hagen via ntg-context wrote:

> On 8/8/2021 1:13 PM, Benjamin Buchmuller via ntg-context wrote:
> > I'm not sure if it's related to this latest:
> > 
> > ConTeXt  ver: 2021.08.07 22:53 LMTX  fmt: 2021.8.8  int: english/english
> > 
> > or a previous one, but with this one:
> > 
> > ConTeXt  ver: 2021.07.30 00:57 LMTX  fmt: 2021.8.8  int: english/english
> > 
> > My document compiled fine.
> > 
> > When I use the t-vim module (freshly installed again from the garden; but I
> also tried to replace some files from the GitHub, but not sure if I did it
> right …), I now get an error when I do something like
> > 
> > \usemodule[vim]
> > 
> > \definevimtyping[vimR]
> > 
> > \typevimRfile{path_to_file.R} % specifically: {../sourcecodes/myfile.R}
> > 
> > --
> > 
> > lua error > lua error on line 2 in file virtual://block.sourcecode.7:
> > 
> > token call, execute:
> ...ConTeXt/tex/texmf-context/tex/context/base/mkiv/l-io.lua:70: bad argument
> #1 to '?' (string expected, got nil)
> i'll check it, i cleaned up some code but didn't realize that it was 
> used in a module

This was also reported on t-vim's github page: 
https://github.com/adityam/filter/pull/48.

I basically use jobs.file.run to cache the results and I can easily write a 
module specific version of that, if needed. I'll look at it in a day or two 
(away from a stable internet connection until then).

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] new upload

2021-08-07 Thread Aditya Mahajan via ntg-context
On Sat, 7 Aug 2021, Hans Hagen via ntg-context wrote:

> Hi,
> 
> I did a new upload. Attached is a document describing a new cheap (lmtx only)
> feature. It's probably not that useful for most users, because it is meant for
> somewhat extreme situations. but you never know.

How is this different from reading files from a zip file?

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] How to check if buffer or block has content

2021-08-02 Thread Aditya Mahajan via ntg-context
On Mon, 2 Aug 2021, Benjamin Buchmuller via ntg-context wrote:

> Hi,
> 
> How can I check if a buffer or block has content (or is empty) before a 
> \useblocks or \getbuffer statement?
> 
> I would like to typeset a headline only if the buffer/block has been used in 
> a particular section and want to avoid headlines with empty sections.

There may be more efficient ways to do it (since buffers are stored at the lua 
end), but you can always do \doiftextelse(\getbuffer[...]} to test it buffer 
creates any output.

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] mp-geo Metapost package with ConTeXt

2021-07-26 Thread Aditya Mahajan via ntg-context
On Mon, 26 Jul 2021, Gavin via ntg-context wrote:

> 2) While I’m having good luck with paths, colors are causing trouble. In the 
> data set the color information is in strings with French names of the color, 
> like “rouge.” If I hand this string to MetaPost, MetaPost doesn’t expand it 
> into a color. It does work if it is a native color, like “red,” but not if it 
> is a defined color and not if the color is in a Lua variable. Any suggestions?

\definecolor[rouge][red] should work. A better option will be use color 
palettes. 

This is very old code, but will give an idea of how to use palettes:
https://github.com/adityam/visualcounter/blob/master/visualcounter.pdf 
Effectively all you need to do is add \setuppalet[name] at an appropriate 
place, and then the user can easily change the colors (rather than having them 
specified as part of data files).

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] Modules under LMTX, was Re: Use of lettrine module in LMTX

2021-07-25 Thread Aditya Mahajan
On Sun, 25 Jul 2021, Rik Kabel wrote:

> Perhaps a list of modules known to run correctly with LMTX is called 
> for, and perhaps a classification of modules to indicate which ConTeXt 
> versions each supports, and a way to download a distribution-appropriate 
> subset.

For some of my modules, I *.mkii, *.mkiv, *.mkxl so that the engine-appropriate 
version is selected. Note that if there is LMTX prefers mkxl but will select 
mkiv if mkxl is not available. 

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] MP boxes: boxjoin not recognized?

2021-07-22 Thread Aditya Mahajan

On Wed, 21 Jul 2021, Hans Hagen wrote:

> On 7/21/2021 12:29 PM, Rudd, Kevin wrote:
> > Hi---
> > 
> > All of my figures that use MP boxes are now failing. It looks like 
> > "boxjoin" (from the MP "boxes" macros) is not being recognized. Also, 
> > apparently unrelated, I wonder if the comparison in "boxes.mp" is 
> > correct as it appears that lmtx loads "mp-xbox.mpiv" instead of 
> > "mp-xbox.mpxl". Here is some log output and a (mostly) MWE.
> 
> Indeed, I made that one an mp-* because it removes a dependency. 

Maybe we should also merge rboxes.mp with mp-xbox.* It is almost the same code 
as boxes.mp.

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] Math cases

2021-07-22 Thread Aditya Mahajan
On Thu, 22 Jul 2021, Jack Hill wrote:

> Dear list,
> 
> I'm using ConTeXt version 2021.07.22 19:16 and the following code 
> typesets both columns in math mode
> 
> \starttext
> \startformula
> \delta_{ij} =
> \startcases
> \NC 1 \NC if i = j \NR
> \NC 0 \NC otherwise \NR
> \stopcases
> \stopformula
> \stoptext
> 
> The wiki states that the second column should be typeset in text mode. 
> Is this a bug or does ConTeXt now typeset the second column in math mode 
> by default?

Yes, we felt that it was more consistent with other align mechanisms to default 
to math. So, for the 2nd column, we now have \NC for a "normal" (i.e., math) 
column and \TC for a text column. So you can use:

\startformula
\delta_{ij} =
\startcases  
\NC 1 \TC if $i = j$ \NR
\NC 0 \TC otherwise \NR
\stopcases 
\stopformula   
\stoptext  

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] mp-geo Metapost package with ConTeXt

2021-07-15 Thread Aditya Mahajan
On Thu, 15 Jul 2021, Hans Hagen wrote:

> On 7/14/2021 4:43 PM, Gavin wrote:
> > Hello ConTeXters,
> > 
> > I’d like to use the mp-geo Metapost package with ConTeXt to draw simple
> globes viewed from various directions. The package is here:
> > 
> > https://melusine.eu.org/syracuse/poulecl/mp-geo/
> > 
> > It looks like the last update was 2008 and I don’t read French, so I though
> my chances of getting anything to work were pretty small. However, I was
> pleasantly surprised that this MWE found the mp-geo package, the necessary
> Metapost files in the ConTeXt installation, and the data files.
> > 
> > \starttext
> > \startMPcode
> > input mp-geo;
> > figure(-10u,-10u,10u,10u);
> > Mercator(3,48,30);
> > fin;
> > end
> > \stopMPcode
> > \stoptext
> > 
> > While all of the files were found, it did not produce a globe. Instead I got
> an error complaining about an invalid character in the data files. This error
> is repeated for about 20 files (a small fraction of the total). I put the
> first error and its data file below. All the others are identical with
> different .dat files.
> > 
> > Maybe it’s just an encoding mismatch or a hidden character I can easily
> delete or replace. On the other hand, maybe I shouldn't even be attempting
> this? 2008 is a long time ago in ConTeXt time. Feel free to tell me this
> project is crazy, but if you have an idea how I can make this work, I’d really
> appreciate it! It looks like a fun package.
> Looks interesting (I didn't know about it, also the surface stuff). 
> Anyway, the message relates to scantokens not liking what gets read from 
> a file, quite probably a missing file (I'll make it return a different 
> message but still one needs to be aware of the fact that fiel reading in 
> mp is kind of weird so it really expects a file).

Actually the data files are fairly simple: 

no_of_points


So, it would be much simpler to read and parse it via lua rather than 
scantokens. Rest of the code simply determines a "view" of what to show. So, it 
can be a good exercise in lua-MP interface.

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] weekend upload

2021-07-12 Thread Aditya Mahajan
On Tue, 13 Jul 2021, Jeong Dal wrote:

> Dear Aditya,
> 
> Thank you for your code and an explanation.
> 
> > Let's assume that the last MPpage was a \startuseMPgraphic{boxes}  
> > \stopuseMPgraphic. Suppose I wanted to use these pictures in a 
> > presentation. On the first slide, I can use
> > 
> >\useMPgraphic[stacking=0]{boxes}
> > 
> > to show the three boxes, and on the next slide, I can use
> > 
> >\useMPgraphic[stacking={-1,0}]{boxes}
> > 
> 
> I tried to reproduce your example using \startuseMPgraphic{boxes} … 
> \stopuseMPgraphic, and useMPgraphic[stacking=0]{boxes} .
> A modified one of your code is below.
> There is no error message but no output at all.
> Would you please tell me what is wrong in here?

> [...]
> \startuseMPgraphic[offset=2mm]{boxes}
> [...]

You cannot use [offset=2mm] here. Just use \startuseMPgraphic{boxes}.

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] weekend upload

2021-07-11 Thread Aditya Mahajan
On Sun, 11 Jul 2021, Bruce Horrocks wrote:

> > On 9 Jul 2021, at 17:29, Hans Hagen  wrote:
> > 
> > This weekend upload has something new for metapost animation lovers:
> 
> Forgive my ignorance but what exactly am I supposed to be seeing here? I run 
> the example and get two rows of ten boxes. They don't move so it's not like 
> an animated GIF was put into the PDF and they don't appear to be consecutive 
> frames that could be joined into an animated GIF.

For me, this feature provides the same capability as 'layers' in a graphical 
program. Consider the diagram shown in page 1 of the attached PDF. Suppose I 
want to "highlight" boxes A and B by drawing a square around them. That is 
easy; simply determine the bounding box of A, B (I do that manually here), and 
expand it a bit and draw it. Simple. See page 2. 

Now, suppose I want to fill this highlighted box. Suddenly, we have a problem. 
The highlight box needs to be "behind" the other boxes. How do we do it. We 
determine the location of boxes A, B, and C, but do not draw them. Determine 
the highlight box. Now draw the highlight box first and then draw the boxes. 
Suddenly the code became an order of magnitude more complicated. 

With the new stacking mechanism, I can just put the highlight box on "stack 
-1", and everything works well. See page 4. What's also super cool is that I 
can control what gets shown by changing the stacking key. 

Let's assume that the last MPpage was a \startuseMPgraphic{boxes}  
\stopuseMPgraphic. Suppose I wanted to use these pictures in a presentation. On 
the first slide, I can use

\useMPgraphic[stacking=0]{boxes}

to show the three boxes, and on the next slide, I can use

\useMPgraphic[stacking={-1,0}]{boxes}

to show the boxes and the highlight. Drawing such "conditional" graphics was 
cumbersome in the past. Now, it is easier. 

If you show a bunch of such "conditional" graphics in a sequence, you get an 
animation (or you could wrap around the animation module). 

Aditya

PS: Hans, stacking doesn't completely work with the boxes macro. drawunboxed is 
always drawn on stack 0, which the bpath is drawn on the right stack. That is 
the reason I use stack = -1 to put the highlight in the "background". 

background.pdf
Description: Adobe PDF document


background.tex
Description: TeX document
___
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] weekend upload

2021-07-09 Thread Aditya Mahajan


On Fri, 9 Jul 2021, Hans Hagen wrote:

> Hi,
> 
> This weekend upload has something new for metapost animation lovers:
> 
> \starttext
> 
> \startuseMPgraphic{demo}
>  stacking := 6;
>  fill fullcircle scaled 10cm
>  withcolor "red" ;
>% stacking := 3;
>  stacking := 9;
>  fill fullcircle scaled 10cm shifted (3cm,0)
>  withcolor "green" ;
>  interim stacking := 4;
>  fill fullcircle scaled 10cm shifted (3cm,3cm)
>  withcolor "blue" ;
>  for i=1 upto 10 :
>  draw fullcircle scaled (i*cm)
>  withstacking 8
>  withpen  pencircle scaled 1mm
>  withcolor"gray" ;
>  endfor ;
>  for i=1 upto 20 :
>  draw fullcircle scaled (i*cm/2)
>  withstacking (if odd(i) : i else : 5 fi)
>  withpen  pencircle scaled 2mm ;
>  endfor ;
>  draw boundingbox currentpicture
>  withpen  pencircle scaled 1pt
>  withstacking 0 ;
>  currentpicture := currentpicture xsized 15mm;
> \stopuseMPgraphic
> 
> \setupMPvariables[demo]
> 
> \startTEXpage
>  \vskip1ex
>  \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,#1}}\space}}
>  \vskip1ex \nointerlineskip
>  \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,1-#1}}\space}}
>  \vskip1ex
> \stopTEXpage
> 
> \stoptext
> 
> I have some more ideas but want to approach it stepwise. It bpils down 
> to the fact that one can put stuff on different 'layers' and optionally 
> flush these (by default all are flushed but the stackling order is 
> honored). An advantage is that one doesn't have to set up a graphic in 
> order (read: save pictures, flush them later on) and it is actually a 
> rather cheap extension in terms of runtime and overhead. Although I 
> could emulate it in mkiv, it is currently an LMTX only feature.
> 
> The (optional) list accepts the usual {1,2,5,7-9} kind of specification.

Very interesting. What will be the syntax to use this with \processMPbuffer and 
\startMPcode?

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] Proper ligatures in Malayalam

2021-07-07 Thread Aditya Mahajan
On Tue, 6 Jul 2021, Ajith R wrote:

> Hi,
> 
> I am running Debian 10 and context --version returns
> 
> mtx-context | ConTeXt Process Management 1.02
> mtx-context |
> mtx-context | main context
> file: /usr/share/texmf/tex/context/base/mkiv/context.mkiv
> mtx-context | current version: 2018.04.04 00:51

This is more than 3 years old! You will need to update. Not sure if there is a 
debian package for LMTX. You can always install it in parallel to the system 
installation by following the instructions on the wiki. 

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] names of cached images

2021-07-02 Thread Aditya Mahajan

On Fri, 2 Jul 2021, Jano Kula wrote:

> Hello again,
> 
> likely a bug and one question. Using this code with lmtx:
> 
> \starttext
> \externalfigure[mill][width=40mm,cache=./first,conversion=gray.pdf] %
> mill...
> \externalfigure[mill][width=40mm,cache=.,conversion=gray.pdf]   %
> m_k_i_v_mill...
> \externalfigure[mill][width=40mm,cache=./second]% no
> visible caching
> \stoptext
> 
> *First two figures*
> Chached image in the ./cache subdirectory has a lmtx name without prefix,
> the cached image in the current directory has mkiv syntax with  m_k_i_v_
> prefix.
> 
> *Third figure*
> The images are cached to a specified directory, only when some conversion
> is used. I'd like to cache images without any transformation. Is there any
> conversion which doesn't alter the figure, just caches it? Is new
> conversion type needed? Or is there other way to force caching without
> conversion?

Conversion is costly and that is why caching makes sense there. What is the 
benefit of caching (i.e., simply copying the file to a different directory) 
when there is no conversion?

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] Rolling out a pandoc-context publication workflow in an organization

2021-07-02 Thread Aditya Mahajan
On Fri, 2 Jul 2021, Jan U. Hasecke wrote:

> 
> Dear Hans,
> 
> thanks for the hint to the repo. I remember that it was mentiooned before.
> 
> Am 02.07.21 um 10:42 schrieb Hans Hagen:
> > official    : https://bitbucket.org/phg/context-mirror/src/beta/

There is also

github: https://github.com/contextgarden/context-mirror

which simply mirrors the bitbucket repo.

> Is there a how-to-bootstrap-from-repository? How can I get a running 
> context with the repo?

These repos contain just the contents on texmf-context, but not the binaries 
(or sources of binaries). You need the binaries (and fonts!) to get a working 
installation. 

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] Proper ligatures in Malayalam

2021-07-01 Thread Aditya Mahajan
On Thu, 1 Jul 2021, Ajith R wrote:

> Hi Pablo,
> 
> I am not sure if my previous mail was delivered or not.
> I didn't get the correct ligatures even after copy pasting the code you
> provided (incluing the feature "malayalam-two").

In such cases, it is always useful to include the output of `context --version` 
to help debug why the output is different.

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] Rolling out a pandoc-context publication workflow in an organization

2021-07-01 Thread Aditya Mahajan
On Thu, 1 Jul 2021, Taco Hoekwater wrote:

> Hi,
> 
> > On 1 Jul 2021, at 08:02, Jan U. Hasecke  wrote:
> > 
> > I come up with the idea of an "organizational context distribution" that 
> > has all requirements preinstalled. That could look like this:
> 
> I would put the whole context distribution in the git. That way, you can
> potentially hotfix something centrally.

And that also makes sure that all your editors are using the same version of 
context. If everyone installs their own versions, debugging can be a pain.

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] Different authorconversion for citation alternatives and bibliographic entries

2021-06-30 Thread Aditya Mahajan
On Wed, 30 Jun 2021, Ágoston Volcz wrote:

> Hi there,
> 
> My university has special requirements for the theses I submit.
> Layout, fonts etc. are pretty straightforward to set up in ConTeXt.
> The one part I'm struggling with is citations / bibliography.
> I have to use the german citation style with footnotes. Essentially
> the first time I cite something, I have to put the full entry in a
> footnote. From the second time on, I only have to put a shorter entry
> in the footnotes.
> I have two problems:
> 
> 1. I created the publ-imp-deu.lua and publ-imp-deu.mkvi files. If I
> put them into the
> ~/bin/context/tex/texmf-context/tex/context/base/mkiv/ directory, I
> get the following two lines in the log:
> ```
> publications> unknown library 'deu'
> publications> no data definition file 'publ-imp-deu.lua' for 'deu'
> ```
> If I put them into the directory where my thesis is, they seem to get
> recognized, but I would very much like to reuse them and not have to
> copy them to each project directory. What am I doing wrong?

Try running mtxrun --generate to update the database.

However, I think that texmf-context/... is a bad place to put local files 
because they can be overwritten by system update. It may be better to put them 
in $TEXMFHOME/tex/context/personal/...

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] simplifying repeated macro calls in metafun

2021-06-23 Thread Aditya Mahajan
On Wed, 23 Jun 2021, Aditya Mahajan wrote:

> On Thu, 24 Jun 2021, Jeong Dal wrote:
> 
> > Now, I am trying to do the same thing using \startuseMPgraphic, but I don’t 
> > the correct result yet.
> > Using \startuseMPgraphic, and \dorecurse, the code is simpler. But, it 
> > seems to me that \startanimation … \stopanimation is not working with 
> > \dorecurse{}{} …
> > It just list all the graphics.
> > Any hint is welcome.
> 
> A while back, I wrote some code to easily generate metapost animations. 
> 
> https://adityam.github.io/context-blog/post/metapost-animation/
> 
> I haven't used it much because I am mostly on linux, and its is a PITA to get 
> an older version of Adobe Reader to work under wine. 

Here's a version using these macros. It runs with MkIV but not with LMTX. 
Sorry, no time to debug what's going wrong in LMTX right now.

Aditya

mp-test.tex
Description: TeX document
___
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] Delivering the value of a variable in MetaFun to ConTeXt

2021-06-23 Thread Aditya Mahajan
On Thu, 24 Jun 2021, Jeong Dal wrote:

> Dear Hans,
> 
> Your code works fine.
> 
> > \starttext
> > 
> > \startMPcode
> >numeric maxCount;
> >maxCount := 10;
> >setglobalmacro("MyMacro",decial maxCount);
> >setglobalcount("MyCount",maxCount);
> > \stopMPcode
> > 
> > 
> > \dorecurse{\MyMacro}{It is \recurselevel. }\par
> > \dorecurse{\MyCount}{It is \recurselevel. }\par
> > 
> > \stoptext
> 
> I applied your method to my code as following. 
> 
> \newcount\udCount  %%% add count
> \startMPinitializations%{UDBasic}
>   pair A,B,C,D;
>   pair E, F, G, H;
>   path p,q;
>   numeric ang,maxNum;
> 
>   numeric n; %AM Added
> 
>   u:=1in;
>   A=(.95*TextWidth,u); B=(0,u); C=(0,0); D=(.95*TextWidth,0);
>   p := A--B--C--D;
>   q := (TextWidth,1.5u)--(0,1.5u)--(0,-.5u)--(TextWidth,-.5u)--cycle;
>   z0=(.1u,0);
>   
>vardef nextPt (expr M,N) = 
>if ypart(N) = 0: 
>H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[A,B];
>else:
>H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[C,D];
>fi;
>H
>enddef;
> 
>def grayUD(expr i) =
>   draw G -- if ypart(B)=ypart(G): B -- C else: C -- B fi --z[i];
>   filldraw z[i]+2*(G-z[i])*u -- z[i] -- z[i+1] -- z[i+1]+(G-z[i])*u -- 
> cycle withcolor .75white; 
>   draw G -- z[i+1] dashed evenly;
>   draw z[0] for k=0 upto i: --z[k] endfor dashed evenly;
>   clip currentpicture to q;
>enddef;
> 
>def linesUD(expr i) =
>   draw p;
>   draw z0 for k=0 upto i+1: --z[k] endfor dashed evenly;
> 
>   % AM: removed. Set in in the main code
>   % setbounds currentpicture to boundingbox q;
>enddef;
> 
>ang := 40;
>z[1] = whatever[z[0], z[0]+dir(ang)*u] = whatever[A,B];
> 
>% AM: Changed next line from G to z[-1]
>z[-1] = whatever[z[0], z[0]+dir(2*ang)*u] = whatever[A,B];
>for k = 2 upto 20:
>   z[k] = nextPt(z[k-2],z[k-1]);
>   maxNum := k;
>   exitif xpart(z[k]) > TextWidth;
>endfor;
>maxNum := maxNum-1;
>setglobalmacro("udMacro",decimal maxNum);  %%% define udMacro and udCount
>setglobalcount("udCount",maxNum);
> 
> \stopMPinitializations
> 
> \startuseMPgraphic{foldUD}{num}
>numeric n;
>n := \MPvar{num}-1;
>G := z[n-1];
>grayUD(n);
> \stopuseMPgraphic
> \startuseMPgraphic{dotLines}{num}
>numeric n;
>n := \MPvar{num}-1;
>linesUD(n);
> \stopuseMPgraphic
> 
> \setupinteraction[state=start]
> \usemodule[animation]
> \starttext
> %\startanimation[menu=yes]
> %{
> \dorecurse{\udCount}
>  {\useMPgraphic{foldUD}{num=\recurselevel}}
>  {\useMPgraphic{dotLines}{num=\recurselevel}}
> %}
> %\stopanimation
> \stoptext
> 
> 1. Using “udCount” doesn’t issue error message, but it draws the path p only.
> 2. Using “udMacro” issue the error message.
> 
> Is there anything that I miss?

You need to call the setglobalmacro(...) macro. The code inside 
\startMPinitializations is only executed when you call any MP environment. But 
you are using \udCount before \useMPgraphic. A simple solution is to run dummy 
MP code so that MP initializations are run:

\starttext
\setbox\scratchbox\hbox{\startMPcode draw unitcircle; \stopMPcode}
\dorecurse{\udCount}
 {\useMPgraphic{foldUD}{num=\recurselevel}}
 {\useMPgraphic{dotLines}{num=\recurselevel}}
\stoptext


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] simplifying repeated macro calls in metafun

2021-06-23 Thread Aditya Mahajan
On Thu, 24 Jun 2021, Jeong Dal wrote:

> Now, I am trying to do the same thing using \startuseMPgraphic, but I don’t 
> the correct result yet.
> Using \startuseMPgraphic, and \dorecurse, the code is simpler. But, it seems 
> to me that \startanimation … \stopanimation is not working with 
> \dorecurse{}{} …
> It just list all the graphics.
> Any hint is welcome.

A while back, I wrote some code to easily generate metapost animations. 

https://adityam.github.io/context-blog/post/metapost-animation/

I haven't used it much because I am mostly on linux, and its is a PITA to get 
an older version of Adobe Reader to work under wine. 

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] simplifying repeated macro calls in metafun

2021-06-20 Thread Aditya Mahajan
On Mon, 21 Jun 2021, Jeong Dal wrote:

> 
> Hi,
> 
> I defined a macro definition in metafun, and draw figures using 
> \startbuffer[] … \stopbuffer and \processMPbuffer[].
> As you see in the attached code, the same macro definition is used repeatedly 
> by changing the numeric argument. 
> Is there a better way to simplify the code, for example, using \dorecurse and 
> recurselevel?

See attached. The main idea is to store the repetitive bits in 
\startuseMPgraphic{...} and then reuse them using \includeMPgraphic. 

Aditya

mp-test.tex
Description: TeX document
___
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] A not so short introduction to ConTeXt - French version - progress report.

2021-06-16 Thread Aditya Mahajan
On Wed, 16 Jun 2021, Garulfo wrote:

> Hi all, Joaquín
> 
> I hope your are doing well.
> 
> To keep you informed of my progress on the French version of "a not so 
> short introduction to ConTeXt", I am done for part I, and II, and I am 
> starting with Part III...

Thanks. The visual style does look nice.

One question about the translation. Does it make sense to introduce the French 
interface as well (\demarretexte ... \stoppetexte, etc.)?

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] randomizer line-breaking

2021-06-08 Thread Aditya Mahajan
On Tue, 8 Jun 2021, Steffen Wolfrum wrote:

> 
> 
> > Am 08.06.2021 um 15:30 schrieb Hans Hagen :
> > 
> > On 6/8/2021 3:15 PM, Steffen Wolfrum wrote:
> > 
> >> perhaps I incidently use a command that utilizes random... what could this 
> >> be?
> > mwe

http://texfaq.org/FAQ-minxampl
https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-working-example-mwe-what-is-that

These are latex centric advice on creating a minimal working example but 
broadly applicable for context as well.

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] new upload

2021-05-31 Thread Aditya Mahajan
On Mon, 31 May 2021, Hans Hagen wrote:

> On 5/31/2021 6:50 PM, Aditya Mahajan wrote:
> > On Mon, 31 May 2021, Hans Hagen wrote:
> > 
> > > Hi,
> > > 
> > > I uploaded a new lmtx version. This time a new mechanism.
> > 
> > This is very interesting...I haven't played around with it, but is it the
> > case that \markanchor does not do alignment and so can completely replace
> > the old \hpos{...} class of macros?
> > 
> > This also gives many interesting possibilities for math  drawing "boxes"
> > in matrices (e.g.,
> > https://tex.stackexchange.com/questions/333011/draw-a-box-around-matrix-elements)
> > or even the nath style `\wall` macro (see pg 11 of
> > https://texdoc.org/serve/nathguide.pdf/0) ... Of course, I mean this in
> > terms of the visual effect and not the interface.
> Like this ... I'll think about taking some size into account (a bit like hpos
> does).

Yes! If we can take size of cell into account, it will be perfect. 

We can also think of a wrapper so that an explicit \framed is not needed. 

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] new upload

2021-05-31 Thread Aditya Mahajan
On Mon, 31 May 2021, Hans Hagen wrote:

> Hi,
> 
> I uploaded a new lmtx version. This time a new mechanism.

This is very interesting...I haven't played around with it, but is it the case 
that \markanchor does not do alignment and so can completely replace the old 
\hpos{...} class of macros?

This also gives many interesting possibilities for math  drawing "boxes" in 
matrices (e.g., 
https://tex.stackexchange.com/questions/333011/draw-a-box-around-matrix-elements)
 or even the nath style `\wall` macro (see pg 11 of 
https://texdoc.org/serve/nathguide.pdf/0) ... Of course, I mean this in terms 
of the visual effect and not the interface. 

Thanks,
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] BibTeX inproceedings entries not rendered correctly in APA style

2021-05-28 Thread Aditya Mahajan
On Fri, 28 May 2021, Alan Braslau wrote:

> On Thu, 27 May 2021 20:21:55 - (UTC)
> Nicola  wrote:
> 
> > Thank you all for the precious comments.
> > 
> > The current LMTX appears to have almost fixed my issue, except that
> > inproceedings entries without a publisher have the text "Author"
> > instead of the publisher's name.
> > 
> > I must say that I have no requirement to use the APA style
> > specifically; I do it only because it uses the format (Name, Year)
> > for the citation. I guess that I could use another style (aps seems
> > fine) and just customize the citation format. I have tried with
> > 
> > \usebtxdataset[main.bib]
> > \setupbtx[default:cite][alternative=authoryear]
> > \usebtxdefinitions[aps]
> > 
> > but it seems that the setup command has no effect: the citations still
> > use numbers.
> 
> APS is an inherently numbered citation format.
> 
> If you have not defined a publisher, how should ANY format place the
> undefined publisher's name?

Simply leave it blank?

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] t-vim module: no highlighting for custom filetypes

2021-05-28 Thread Aditya Mahajan
On Thu, 27 May 2021, Nicola wrote:

> On 2021-05-27, Aditya Mahajan  wrote:
> > On Thu, 27 May 2021, Nicola wrote:
> >
> >> On 2021-05-24, Aditya Mahajan  wrote:
> >> > On Fri, 21 May 2021, Nicola wrote:
> >> >
> >> >> I have only a minor annoyance: I have just noticed that -- is typeset as
> >> >> an en-dash in LMTX (but not in MKIV, as documented). Could you look into
> >> >> that?
> >> >
> >> > Fixed in the new release.
> >>
> >> Thanks. I have updated to version 2021.05.23 and run `mtxrun
> >> --generate`. Syntax highlighting is fine, but with LMTX I'm still
> >> getting an en-dash. Below, a MWE.
> >
> > Can you test if the file tests/vim/21-en-dash.tex works fine at your end:
> >
> > https://github.com/adityam/filter/blob/dev/tests/vim/21-en-dash.tex
> 
> No, I get an en-dash with that, too. Log included below.

For now, please use align=flushleft, either globally:

\setupsyntaxhighlighting[align=flushleft]

or as part of defining the typing environment:

\definevimtyping[...][, align=flushleft, ...]


I'll test a bit more carefully and then upload a new version.

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] t-vim module: no highlighting for custom filetypes

2021-05-27 Thread Aditya Mahajan
On Thu, 27 May 2021, Nicola wrote:

> On 2021-05-24, Aditya Mahajan  wrote:
> > On Fri, 21 May 2021, Nicola wrote:
> >
> >> I have only a minor annoyance: I have just noticed that -- is typeset as
> >> an en-dash in LMTX (but not in MKIV, as documented). Could you look into
> >> that?
> >
> > Fixed in the new release.
> 
> Thanks. I have updated to version 2021.05.23 and run `mtxrun
> --generate`. Syntax highlighting is fine, but with LMTX I'm still
> getting an en-dash. Below, a MWE.

Can you test if the file tests/vim/21-en-dash.tex works fine at your end:

https://github.com/adityam/filter/blob/dev/tests/vim/21-en-dash.tex

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] Define new symbol by stitching two symbols together

2021-05-24 Thread Aditya Mahajan
On Sun, 23 May 2021, Hans Hagen wrote:

> On 5/22/2021 8:23 PM, Nicola wrote:
> > I would like to define new symbols by stitching together existing
> > glyphs. This is what I have come up so far:
> > 
> >  \define[1]\Transition{-\!\![#1]\!\!\rightarrow}
> >  \starttext
> >  \m{L\Transition{A}R}
> >  \stoptext
> > 
> > This should render as -[ ]->, ideally with no space between the dash or
> > the arrow and the brackets, i.e., -[ should appear like a single glyph;
> > ditto for ]-->. With the definition above, however, the space is
> > variable, and in some circumstances the gliphs overlap.
> > 
> > How can I improve the above definition?
> don't use these funny \! skips ... use some font related metric:
> 
>  \define[1]\Transition{-\kern-1ex[#1]\kern-1.1ex\rightarrow}

This is how we used to define arrows in the old days ...

\define[1]\Transition{\relbar\joinrel\mathrel{[}#1\mathrel{]}\joinrel\rightarrow}
\define[1]\BigTransition{\relbar\joinrel\relbar\joinrel\mathrel{[}#1\mathrel{]}\joinrel\relbar\joinrel\rightarrow}

\starttext
\m{L\Transition{A}R}

\m{L\BigTransition{A}R}
\stoptext

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] t-vim module: no highlighting for custom filetypes

2021-05-24 Thread Aditya Mahajan
On Fri, 21 May 2021, Nicola wrote:

> I have only a minor annoyance: I have just noticed that -- is typeset as
> an en-dash in LMTX (but not in MKIV, as documented). Could you look into
> that?

Fixed in the new release.

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] t-vim module: no highlighting for custom filetypes

2021-05-23 Thread Aditya Mahajan
On Sun, 23 May 2021, Hans Hagen wrote:

> On 5/22/2021 6:15 PM, Aditya Mahajan wrote:
> > On Sat, 22 May 2021, Hans Hagen wrote:
> > 
> > > On 5/21/2021 9:37 PM, Nicola wrote:
> > 
> > > > I have only a minor annoyance: I have just noticed that -- is typeset as
> > > > an en-dash in LMTX (but not in MKIV, as documented). Could you look into
> > > > that?
> > > 
> > > best is that the module uses:
> > > 
> > > \the\everyinitializeverbatim
> > > 
> > > because there we disable all kind of non verbatim stuff
> > 
> > Thanks. It took a few trial and error that \the\everyinitializeverbatim
> > must come after \usealignparameter. However, using \nohypencollapsing after
> > \usealignparameter means that I cannot get hypenated lines (something which
> > had been requested in the past for t-vim). See the attached file.
> > 
> > BTW, shouldn't we have `features=none` in the default mono font setup so
> > that this doesn't happen anyways?
> afaik we already do that
> 
> (i'll add some more control, already added \setuphyphenation[hyphen=no] here)
> 
> I need to find a reasonable way to provide control over all these things ...
> real low level btw is \hyphenationmode\zerocount ... look in lang-ini.mkxl for
> all possible flags)

Thanks. I guess, it is time to freeze the mkiv version of the module and 
introduce a mkxl version.

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] Unwanted upright math in MkIV

2021-05-23 Thread Aditya Mahajan
On Sun, 23 May 2021, Gavin wrote:

> Hello,
> 
> I’m using ConTeXt with MacOS. The current version of MkIV produces upright 
> math rather than italic. MWE:
> 
> \starttext
> \m{f = \beta}
> \stoptext

Works correctly here. What does context --version say?

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] t-vim module: no highlighting for custom filetypes

2021-05-22 Thread Aditya Mahajan
On Sat, 22 May 2021, Hans Hagen wrote:

> On 5/21/2021 9:37 PM, Nicola wrote:

> > I have only a minor annoyance: I have just noticed that -- is typeset as
> > an en-dash in LMTX (but not in MKIV, as documented). Could you look into
> > that?
> 
> best is that the module uses:
> 
> \the\everyinitializeverbatim
> 
> because there we disable all kind of non verbatim stuff

Thanks. It took a few trial and error that \the\everyinitializeverbatim  must 
come after \usealignparameter. However, using \nohypencollapsing after 
\usealignparameter means that I cannot get hypenated lines (something which had 
been requested in the past for t-vim). See the attached file. 

BTW, shouldn't we have `features=none` in the default mono font setup so that 
this doesn't happen anyways?

Thanks,
Aditya



test.tex
Description: TeX document
___
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] mathfun

2021-05-21 Thread Aditya Mahajan
On Fri, 21 May 2021, Otared Kavian wrote:

> By the way, what does 
> 
>   \complexexpr{123 + new(456,789)}
> 
> mean?

Haven't look at the code yet, but I'd guess `new(a,b) = a + bi`. 

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] mathfun

2021-05-21 Thread Aditya Mahajan
On Fri, 21 May 2021, Hans Hagen wrote:

> I uploaded an lmtx update (only m-mathfun added).
> 
> Attached a short description of this (windy stormy friday afternoon) math
> experiment. The question is, what similar features using this trickery come to
> mind.

Personally, I can see occasionally making use of this instead of 
\ctxlua{myfunction(args)}. There is a similar library called pgfmath which is 
part of the tikz package, which is used quite heavily by the pgfplots package 
but also appears to be popular for other purposes:

https://tex.stackexchange.com/questions/tagged/pgfmath?tab=Votes

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] t-vim module: no highlighting for custom filetypes

2021-05-21 Thread Aditya Mahajan
On Fri, 21 May 2021, Nicola wrote:

> On 2021-05-21, Nicola  wrote:
> > For some reason, the vim module has stopped highlighting code associated
> > to custom filetypes (it still works for built-in filetypes).
> 
> I think I have found the culprit. In t-vim.tex, lines 63-88, Vim is
> called with --clean. That option appears *after* -u, effectively
> overriding it. Moving --clean as the first option (or, better, removing
> it) solves my issue.
> 
> Some remarks. The module has this comment:
> 
>--clean % dont load scada [sic] file (nvim)
> 
> If the purpose of the option is to avoid loading a shada file, `-i NONE`
> (which is already there) should be enough.

Thanks for finding the bug. 

> In Vim, --clean is not strictly necessary, because it is effectively
> a shorthard for `-N -i NONE --noplugin`. > In Neovim, the meaning might be
> slightly different. Which brings me to the next paragraph.

Indeed, the vim manpage says:

   --clean Do not use any personal configuration (vimrc, plugins,  
etc.).
   Useful to see if a problem reproduces with a clean Vim setup.

while nvim manpage says:

 --clean Skip loading plugins and shada (viminfo) file.

So, in vim, the --clean option also skips vimrc while in nvim it does not.

Looking at my git log, I see that I added --clean option for nvim:

commit b907543d9f6b2185185f3674035987f47bf91381
Author: Aditya Mahajan 
Date:   Wed Apr 29 17:48:24 2020 -0400

Add --clean option

to not load viminfo files in `nvim`. Somehow `nvim` does not honor

```
-i NONE
```

option.

Looking at the man page of nvim I see 

 -i shadaUse shada instead of the default
 ~/.local/share/nvim/shada/main.shada.  If shada is NONE, do not
 read or write a ShaDa file.  :help shada

So, -i NONE should have worked. I'll test this again, and if -i NONE now works 
in nvim, I'll simply remove that line.

> My recommendation would be not to care about Neovim. It is *not*
> a drop-in replacement for Vim and not meant to be compatible with Vim
> (it has already diverged from Vim in significant ways). Supporting both
> is likely going to become more and more difficult as time goes by.

nvim was 8-10% faster than vim in my tests:

https://adityam.github.io/context-blog/post/vim-vs-neovim/

> Anyway, if you do want to support both, I'd suggest at least to
> segregate the two commands, even if currently they may be (almost)
> identical.

That's a good suggestion. For now, I'll play around with the order of options 
to seei if that fixes the problem. I agree that at some stage it might be 
better to simply split off the module into a `t-nvim.tex` which configures the 
settings for nvim separately.

I actually want t-vim (or rather t-filter) to support more editors/syntax 
highlighters. At some stage I had added rudimentary support for other syntax 
highlighters most of them required scaffolding to wrap around the latex output:

https://adityam.github.io/context-blog/post/clean-tex-output/


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] Color problem

2021-05-20 Thread Aditya Mahajan
On Thu, 20 May 2021, Rik Kabel wrote:

> Consider the following example:
> 
>\define \HighlightColor {red}

Why not just use:

\definecolor[HighlightColor][red] 

and then use color=HighlightColor, etc.

>\definehighlight[RED][color=\HighlightColor]
>\definelabel[AA][alternative=inright,headcolor=\HighlightColor,text=]
>\definelabel[BB][alternative=inright,headcolor=red,text=]
>\noheaderandfooterlines
>\starttext
>\hsize3cm
>Is the label red?\AA
> 
>Is the label red?\BB
> 
>\RED{Is this line red?}
>\stoptext

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] Hand Style Sketching in Metapost

2021-05-20 Thread Aditya Mahajan
On Thu, 20 May 2021, Jeroen wrote:

> I have the following working example with hatching. This works fine, but
> when I uncomment the sketching commands, no figure is rendered. Is the
> mp-sketch macro still working?

Seems to be working here with LMTX ver. 2021.04.29. See attached.

Aditya

hatch.pdf
Description: Adobe PDF document


hatch.tex
Description: TeX document
%D \module
%D   [   file=mp-sketch.mp
%Dversion=2021.05.13
%D  title=\CONTEXT\ \METAPOST\ graphics,
%D   subtitle=Sketch drawing,
%D     author=Aditya Mahajan,
%D   date=\currentdate,
%D  copyright={Aditya Mahajan}]

%D This metapost module is inspired by a TeX.SE question:
%D http://tex.stackexchange.com/q/39296/323
%D
%D I thought that it would be fun to implement a similar feature in MetaPost.
%D
%D To use this package in MetaPost:
%D
%D \starttyping
%Dinput mp-sketch;
%D
%Dbeginfig(1)
%D  sketchypaths; % Make draw and fill sketchy
%D  ...
%D  naturalizepaths; % Restore the value of draw and fill
%D  ...
%Dendfig
%D \stoptyping
%D
%D The code is heavily inspired by Hans Hagen's Metafun macros.
%D
%D The macro \type{sketchypaths} is modeled after \type{visualizepaths} from
%D \filename{mp-tool}.

def sketchypaths =
let draw = sketchdraw ;
let fill = sketchfill ;
enddef ;

%D Check if \filename{mp-tool} is loaded
if not known context_tool :
  let normaldraw = draw;
  let normalfill = fill;

  def naturalizepaths =
  let fill = normalfill ;
  let draw = normaldraw ;
  enddef ;
fi

%D The variable \type{sketch_amount} determines the amount of randomness in the
%D drawing
numeric sketch_amount; sketch_amount := 0.75bp;

%D The variable \type{sketch_passes} determines the number of times the path
%D is drawn
numeric sketch_passes; sketch_passes := 1;

%D Based on \type{randomized}. Assumes p is path:
numeric sketch_segments; sketch_segments := 20;

primarydef p sketchrandomized s = (
if path p :
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
if cycle p :
cycle
else :
((point arclength(p) on p) randomshifted s)
fi
else :
p
fi
) enddef ;


%D The macro \type{sketchdraw} draws the randomized path. The 
%D \type{expr} ... \type{text} trick is copied from the definition of 
%D \type{drawarrow}
def sketchdraw expr p =
   do_sketchdraw(p)
enddef;

def do_sketchdraw(expr p) text t =
  if (path p) :
  for i = 1 upto max(1,sketch_passes) :
normaldraw p 
   sketchrandomized sketch_amount 
   withtransparency ("multiply", 1/max(1,sketch_passes))
   t ;
  endfor;
  else :
  normaldraw p t;
  fi
enddef;

%D The macro \type{sketchfill} randomizes the path before filling it.
def sketchfill expr p =
  do_sketchfill(p)
enddef ;

def do_sketchfill(expr p) text t =
  if (path p) :
  for i = 1 upto max(1,sketch_passes) :
normalfill p 
   randomized sketch_amount 
   withtransparency ("multiply", 1/max(1,sketch_passes))
   t ;
  endfor;
  else :
  normalfill p t;
  fi
enddef;

endinput;

% Modified example from
% http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html

beginfig(1)
  pair A,B,C,O;
  A=(0,0); B=(3cm,0); C=(1cm,2cm);

  O - 1/2[B,C] = whatever * (B-C) rotated 90;
  O - 1/2[A,B] = whatever * (A-B) rotated 90;

  sketchypaths;
  sketch_amount := 5bp;
  draw A--B--C--cycle;

  draw O withpen pencircle scaled 4bp;

  sketch_amount := 2bp;
  draw fullcircle scaled 2abs(O-A) shifted O;
endfig
___
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-05-13 Thread Aditya Mahajan
On Thu, 13 May 2021, Henning Hraban Ramm wrote:

> My test file also includes the noise overlay after Jairo’s suggestions. Maybe 
> you want to implement that, too?
> At the moment it still doesn’t respect the pen size, and the number of 
> patterns per path is fixed.

I am not sure if simply adding random noise to the line give an impression of 
hand-drawn lines. For a different approach, see:

https://m.habr.com/en/post/454376/

which uses the code here:

https://github.com/jemmybutton/fiziko

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] Fuzzy lines

2021-05-13 Thread Aditya Mahajan
On Thu, 13 May 2021, Henning Hraban Ramm wrote:

> 
> > Am 13.05.2021 um 18:36 schrieb Aditya Mahajan :
> > 
> >> Now I want to draw that path several times.
> >> 
> >> If I understand it right, I can’t put that into "sketchdraw" because that 
> >> leaves the end open for path additions like "withcolor".
> > 
> > A slightly different approach is needed. See attached. I also added a bit a 
> > error protection in case someone sets sketch_passes to be negative by 
> > mistake. 
> 
> Thank you so much!

Here is a different effect ... more of a trembling hand drawing than a sketch. 
You can play around with sketch_amount to see some variation. 

In this, rather than using the default randomized path (which randomizes the 
points of a path), I split the path into 20 segments, and randomize each 
segment. 

Aditya%D \module
%D   [   file=mp-sketch.mp
%Dversion=2021.05.13
%D  title=\CONTEXT\ \METAPOST\ graphics,
%D   subtitle=Sketch drawing,
%D author=Aditya Mahajan,
%D   date=\currentdate,
%D  copyright={Aditya Mahajan}]

%D This metapost module is inspired by a TeX.SE question:
%D http://tex.stackexchange.com/q/39296/323
%D
%D I thought that it would be fun to implement a similar feature in MetaPost.
%D
%D To use this package in MetaPost:
%D
%D \starttyping
%Dinput mp-sketch;
%D
%Dbeginfig(1)
%D  sketchypaths; % Make draw and fill sketchy
%D  ...
%D  naturalizepaths; % Restore the value of draw and fill
%D  ...
%Dendfig
%D \stoptyping
%D
%D The code is heavily inspired by Hans Hagen's Metafun macros.
%D
%D The macro \type{sketchypaths} is modeled after \type{visualizepaths} from
%D \filename{mp-tool}.

def sketchypaths =
let draw = sketchdraw ;
let fill = sketchfill ;
enddef ;

%D Check if \filename{mp-tool} is loaded
if not known context_tool :
  let normaldraw = draw;
  let normalfill = fill;

  def naturalizepaths =
  let fill = normalfill ;
  let draw = normaldraw ;
  enddef ;
fi

%D The variable \type{sketch_amount} determines the amount of randomness in the
%D drawing
numeric sketch_amount; sketch_amount := 0.75bp;

%D The variable \type{sketch_passes} determines the number of times the path
%D is drawn
numeric sketch_passes; sketch_passes := 1;

%D Based on \type{randomized}. Assumes p is path:
numeric sketch_segments; sketch_segments := 20;

primarydef p sketchrandomized s = (
if path p :
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
if cycle p :
cycle
else :
((point arclength(p) on p) randomshifted s)
fi
else :
p
fi
) enddef ;


%D The macro \type{sketchdraw} draws the randomized path. The 
%D \type{expr} ... \type{text} trick is copied from the definition of 
%D \type{drawarrow}
def sketchdraw expr p =
   do_sketchdraw(p)
enddef;

def do_sketchdraw(expr p) text t =
  if (path p) :
  for i = 1 upto max(1,sketch_passes) :
normaldraw p 
   sketchrandomized sketch_amount 
   withtransparency ("multiply", 1/max(1,sketch_passes))
   t ;
  endfor;
  else :
  normaldraw p t;
  fi
enddef;

%D The macro \type{sketchfill} randomizes the path before filling it.
def sketchfill expr p =
  do_sketchfill(p)
enddef ;

def do_sketchfill(expr p) text t =
  if (path p) :
  for i = 1 upto max(1,sketch_passes) :
normalfill p 
   randomized sketch_amount 
   withtransparency ("multiply", 1/max(1,sketch_passes))
   t ;
  endfor;
  else :
  normalfill p t;
  fi
enddef;

endinput;

% Modified example from
% http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html

beginfig(1)
  pair A,B,C,O;
  A=(0,0); B=(3cm,0); C=(1cm,2cm);

  O - 1/2[B,C] = whatever * (B-C) rotated 90;
  O - 1/2[A,B] = whatever * (A-B) rotated 90;

  sketchypaths;
  sketch_amount := 5bp;
  draw A--B--C--cycle;

  draw O withpen pencircle scaled 4bp;

  sketch_amount := 2bp;
  draw fullcircle scaled 2abs(O-A) shifted O;
endfig


test.tex
Description: TeX document


test.pdf
Description: Adobe PDF document
___
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-05-13 Thread Aditya Mahajan
On Thu, 13 May 2021, Henning Hraban Ramm wrote:

> 
> > Am 11.05.2021 um 18:02 schrieb Aditya Mahajan :
> > 
> > Look at this old code on how hide such code behind a macro to have a clean 
> > interface:
> > 
> > https://github.com/adityam/mp-sketch/blob/master/mp-sketch.mp
> 
> Hi Aditya,
> I’m trying to include my additions into your code, but it doesn’t work.
> 
> 
> numeric sketch_amount; sketch_amount := 3bp;
> numeric sketch_passes; sketch_passes := 5;
> 
> def sketchdraw expr p =
>   do_sketchdraw(p if (path p): randomized sketch_amount fi)
> enddef;
> 
> def do_sketchdraw(expr p) text t =
> normaldraw p t ;
> enddef;
> 
> 
> Now I want to draw that path several times.
> 
> If I understand it right, I can’t put that into "sketchdraw" because that 
> leaves the end open for path additions like "withcolor".
> 
> But it also doesn’t work in "do_sketchdraw"; I thought it might like this:

A slightly different approach is needed. See attached. I also added a bit a 
error protection in case someone sets sketch_passes to be negative by mistake. 

It may be interesting to rewrite these macros using the new key-value interface 
for metapost, so that something like this works:

\sketchdraw[amount=3bp, passes=5, transparency=yes] fullsquare scaled 1cm 
withcolor red;

test.pdf
Description: Adobe PDF document


test.tex
Description: TeX document
%D \module
%D   [   file=mp-sketch.mp
%Dversion=2021.05.13
%D  title=\CONTEXT\ \METAPOST\ graphics,
%D   subtitle=Sketch drawing,
%D author=Aditya Mahajan,
%D   date=\currentdate,
%D  copyright={Aditya Mahajan}]

%D This metapost module is inspired by a TeX.SE question:
%D http://tex.stackexchange.com/q/39296/323
%D
%D I thought that it would be fun to implement a similar feature in MetaPost.
%D
%D To use this package in MetaPost:
%D
%D \starttyping
%Dinput mp-sketch;
%D
%Dbeginfig(1)
%D  sketchypaths; % Make draw and fill sketchy
%D  ...
%D  naturalizepaths; % Restore the value of draw and fill
%D  ...
%Dendfig
%D \stoptyping
%D
%D The code is heavily inspired by Hans Hagen's Metafun macros.
%D
%D The macro \type{sketchypaths} is modeled after \type{visualizepaths} from
%D \filename{mp-tool}.

def sketchypaths =
let draw = sketchdraw ;
let fill = sketchfill ;
enddef ;

%D Check if \filename{mp-tool} is loaded
if not known context_tool :
  let normaldraw = draw;
  let normalfill = fill;

  def naturalizepaths =
  let fill = normalfill ;
  let draw = normaldraw ;
  enddef ;
fi

%D The variable \type{sketch_amount} determines the amount of randomness in the
%D drawing
numeric sketch_amount; sketch_amount := 3bp;

%D The variable \type{sketch_passes} determines the number of times the path
%D is drawn
numeric sketch_passes; sketch_passes := 1;

%D The macro \type{sketchdraw} draws the randomized path. The 
%D \type{expr} ... \type{text} trick is copied from the definition of 
%D \type{drawarrow}
def sketchdraw expr p =
   do_sketchdraw(p)
enddef;

def do_sketchdraw(expr p) text t =
  if (path p) :
  for i = 1 upto max(1,sketch_passes) :
normaldraw p 
   randomized sketch_amount 
   withtransparency ("multiply", 1/max(1,sketch_passes))
   t ;
  endfor;
  else :
  normaldraw p t;
  fi
enddef;

%D The macro \type{sketchfill} randomizes the path before filling it.
def sketchfill expr p =
  do_sketchfill(p)
enddef ;

def do_sketchfill(expr p) text t =
  if (path p) :
  for i = 1 upto max(1,sketch_passes) :
normalfill p 
   randomized sketch_amount 
   withtransparency ("multiply", 1/max(1,sketch_passes))
   t ;
  endfor;
  else :
  normalfill p t;
  fi
enddef;

endinput;

% Modified example from
% http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html

beginfig(1)
  pair A,B,C,O;
  A=(0,0); B=(3cm,0); C=(1cm,2cm);

  O - 1/2[B,C] = whatever * (B-C) rotated 90;
  O - 1/2[A,B] = whatever * (A-B) rotated 90;

  sketchypaths;
  sketch_amount := 5bp;
  draw A--B--C--cycle;

  draw O withpen pencircle scaled 4bp;

  sketch_amount := 2bp;
  draw fullcircle scaled 2abs(O-A) shifted O;
endfig
___
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-05-11 Thread Aditya Mahajan


On Tue, 11 May 2021, Jairo A. del Rio wrote:

> For simple pens, you may define your own (section 9.7 of MetaPost manual).
> For complicated strokes, something along these lines could be useful as a
> starting point (I'm not taking cyclic paths in consideration, btw). I did
> something similar with duck footprints some weeks ago:
> 
> %Sorry for the ugly code...

Look at this old code on how hide such code behind a macro to have a clean 
interface:

https://github.com/adityam/mp-sketch/blob/master/mp-sketch.mp

Sometimes I use such effects in presentations but you have to resist the 
temptation to overdo it:

http://www.cim.mcgill.ca/~adityam/talks/2016-it-forum.pdf

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] Include PDF pages

2021-05-11 Thread Aditya Mahajan
On Tue, 11 May 2021, denis.ma...@ub.unibe.ch wrote:

> > Von: ntg-context  Im Auftrag von MANUEL 
> > GONZALEZ SUAREZ
> > Gesendet: Dienstag, 11. Mai 2021 09:30
> > An: Context 
> > Betreff: [NTG-context] Include PDF pages
> > 
> > Hello everybody:
> > 
> > 
> > My query is as follows: in LaTeX there is the package "pdfpages" 
> > (https://www.ctan.org/pkg/pdfpages) that allows pages from a PDF file to be 
> > included in a TeX document. Is there a similar procedure that works in 
> > ConTeXt?
>
> https://wiki.contextgarden.net/Including_pages_from_PDF_documents

If these don't meet your needs, it is also relatively easy to roll your own 
macro:

https://adityam.github.io/context-blog/post/include-multi-page-pdf/

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] Update setpath to set the path

2021-05-10 Thread Aditya Mahajan
On Sun, 9 May 2021, Thangalin wrote:

> Thoughts on updating the setpath.bat file to persist setting the path?
> 
> Here's an updated version that sets the system environment variable while
> preserving the existing unexpanded PATH value:
> 
> [] 
>
> The reason for this change is because the Windows installation instructions
> (on the wiki) are incomplete: technically, the user must run setpath.bat
> for each new session. 

This is how setuptex works on linux as well. 

> This implies that any third-party program that wants
> to make use of ConTeXt on Windows would have to communicate said fact to
> the user, or let the user set the full path to ConTeXt within the
> third-party program. Both of these can be avoided by persisting the PATH
> setting across sessions.

One of the benefits of context minimals is that you can install multiple 
versions in parallel, which allows the user to update frequently without the 
risk of breaking something for long-term projects. Specifically, you can keep a 
"frozen" version of context for long-term projects and install a newer version 
in parallel for newer projects. 

So, your suggestions should be included as a separate script and not as part of 
the default. Then there is the question of providing an uninstall script as 
well...

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] Bug in \framed and \inframed

2021-05-06 Thread Aditya Mahajan
On Thu, 6 May 2021, Johann Birnick wrote:

> There is a bug with \framed and related commands: If this is the first object 
> in
> a line, a linebreak is inserted! See the following example:
> 
> 
> \starttext
>  
> 
> This \inframed{works} fine.
> 
> \inframed{But} this not.
> 
> \stoptext

https://wiki.contextgarden.net/FAQ#Why_is_there_a_line-break_in_the_output_after_some_commands.3F

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] Style options and setupinterlinespace

2021-04-26 Thread Aditya Mahajan
On Mon, 26 Apr 2021, denis.ma...@ub.unibe.ch wrote:

> Wikified, as per Aditya's suggestion.

I expanded on the description to make it clearer (hopefully). However, as I was 
testing, I realized that the remark about math font sizes ("These quick font 
switches [...] do not change the bodyfont, so they don't affect [...] math font 
size") is no longer true. In LTMX, \tfa correctly scales the math font size as 
well. 

\starttext
\tfc x$x$x
\stoptext

I am not sure when this behavior changed, but looking at some of my old 
documents I see that I have been using "\tfc $+$" in some of my tikz code for 
about 4 years. So, it appears to be a old feature. I am thinking of changing 
the wiki from:

These quick font switches are meant for changing the font style, alternative, 
or size of a few words: they do not change the bodyfont, so they don't affect 
interline spacing or math font sizes

to 

These quick font switches are meant for changing the font style, alternative, 
or size of a few words: they do not change the bodyfont, so they don't affect 
interline spacing.

(so not mention math at all). Let me know if I am misunderstanding something 
here.


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] Style options and setupinterlinespace

2021-04-26 Thread Aditya Mahajan
> Von: Maier, Denis Christian (UB)
> Gesendet: Donnerstag, 22. April 2021 15:15
> An: 'mailing list for ConTeXt users' 
> Betreff: Style options and setupinterlinespace
> 
> Hi,
> 
> the wiki (https://wiki.contextgarden.net/Font_Switching) currently says:
> 
> 
> > These quick font switches are meant for changing the font style, 
> > alternative, or size of a few words: they do not change the bodyfont, so 
> > they don't affect interline spacing or math font sizes. So, if you want to 
> > change the font size of an entire paragraph, use 
> > \switchtobodyfont 
> > described below in Complete Font 
> > Change. 
> > However, it is fine to use them as style directives in setup commands, that 
> > is, using them as an option for 
> > style=... in any 
> > setup command that accepts style option
> 
> From this, I'd infer that a  or  should change the 
> interline spacing as well. But it does not seem to be the case as the example 
> below shows.

Using style=\tfx is roughly equivalent to typing `\tfx` at an appropriate 
place. There is no automatic \setupinterlinespace after the style value is 
executed. 

On Mon, 26 Apr 2021, denis.ma...@ub.unibe.ch wrote:

> Hi again,
> 
> should I change the wiki or is the current behaviour a bug (that will 
> eventually be corrected)?

Perhaps, it will be a good idea to add a concluding sentence "However, the 
previous caveats (no change in interline space or math font sizes) still 
apply". 


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] Set luatex cache directory path

2021-04-06 Thread Aditya Mahajan
On Tue, 6 Apr 2021, Thangalin wrote:

> Thanks Aditya.
> 
> What do you think of changing the default luatex-cache directory to the
> system's temporary directory? Consider:
> 
>- The $HOME directory is sacrosanct (4784 people agree:
>https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1575053)
>- The temp directory is cleared on Linux (Unix?) system reboots; purged
>during regular Windows upkeep
>- The temp directory is writable by default
>- Changing the location requires calling an additional program, which
>isn't obvious (principle of least astonishment)

Use:

mtxrun --autogenerate --script mtx-context ...

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] Set luatex cache directory path

2021-04-06 Thread Aditya Mahajan
On Mon, 5 Apr 2021, Thangalin wrote:

> Peter Münster once asked:
> 
> > What should I do please, to prevent ConTeXt from creating
> $HOME/luatex-cache?
> 
> I'd like to do the same:
> 
> $ cd $HOME
> $ ls luatex-cache
> ls: cannot access 'luatex-cache': No such file or directory
> $ context test.tex
> $ ls luatex-cache/
> context
> $ rm -rf luatex-cache
> $ export TEXMFCACHE=/tmp

Add

$ mtxrun --generate

> $ context test.tex
> mtxrun  | unknown script 'mtx-context.lua' or 'mtx-mtx-context.lua'
> $ export TEXMFCACHE=
> $ context --version
> ...
> mtx-context | current version: 2021.03.31 18:04
> 
> What environment variable must change to set the luatex-cache directory?

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] Running a couple of context statements in a linux bash shell heredocument?

2021-04-01 Thread Aditya Mahajan
On Thu, 1 Apr 2021, Henri Menke wrote:

> On Thu, 2021-04-01 at 16:23 +0200, Alexander Rosenstock wrote:
> > Hi all,
> >  
> > is it possible running a couple of context statements as a
> > heredocument integrated in a - for example linux bash - shellscript?
> > Do you have any experience or idea or alternative solution?
> >  
> 
> This will work, but only if file_that_does_not_exist (possibly with
> additional file extensions) does not exist:
> 
> $ cat <<'EOF' | context file_that_does_not_exist
> \starttext
> Hello world!
> \stoptext
> EOF
 
I couldn't get that to work but this works ...

$cat <<'EOF' | context --pipe 
\starttext
Hello world!
\stoptext
EOF

Generates a file called cont-new.pdf. I could not change it using --result or 
--jobname.

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] metafun / patterns

2021-03-25 Thread Aditya Mahajan
On Thu, 25 Mar 2021, Hans Hagen wrote:

> Hi,
> 
> As I'm still in metafun (and svg) mode I decided to support patterns 
> (that are already supported at the tex end) also in metafun. As there 
> has never been demands I suppose it's not that interesting but it sort 
> of fits in.
> 
> There are some tricky aspectx involved so the interface might evolve a 
> bit (some more control options) but here are some examples anyway:

This is nice! I have used something like this in the past (but with "manual 
clipping", which is always cumbersome for irregular shapes).

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] Writing to .tuc directly from Lua

2021-03-23 Thread Aditya Mahajan
On Tue, 23 Mar 2021, Jairo A. del Rio wrote:

> Hi, list. I read about this:
> 
> https://www.mail-archive.com/ntg-context@ntg.nl/msg60217.html
> 
> But I want to know how to pass data to the .tuc file directly from Lua. I
> think about some complex strings are calculations which are done in each
> pass and slow down the whole compilation process. Something like:
> 
> local function factorial(n)
> if in_tuc then -- whatever in_tuc means
>return factorials[n]
> else
>...
>factorials[n] = ...
>return ...
> end
> end
> 
> Is that feasible? Should I use the CLD versions of the TeX macros instead?

Does this help:

https://wiki.contextgarden.net/System_Macros/Key_Value_Assignments#Multi-pass_data

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] Typing within doifmode leads to error

2021-03-20 Thread Aditya Mahajan
On Sun, 21 Mar 2021, Hans Hagen wrote:

> On 3/20/2021 10:03 PM, Aditya Mahajan wrote:
> > On Sat, 20 Mar 2021, Hans Hagen wrote:
> > 
> > > > 
> > > > I wonder if we could have an environment, say \startluatemplate ...
> > > > \stopluatemplate, which is evaluated on the fly rather than when loading
> > > > a
> > > > file.
> > > 
> > > define 'evaluated on the fly'
> > 
> > Consider the following example:
> > 
> > \enablemode[A]
> > \starttext
> > \startluatemplate
> >
> >\starttyping
> >A and not B
> >\stoptyping
> >
> >\starttyping
> >not (A and not B)
> >\stoptyping
> >
> > \stopluatemplate
> > \stoptext
> > 
> > What I am thinking is that \startluatemplate ... \stopluatemplate grabs the
> > content (like a buffer) and then processes it using the mkix conversion
> > mechanism. Thus, in terms of output, it should be equivalent to:
> > 
> > \enablemode[A]
> > \starttext
> > \startbuffer[luatemplate]
> >
> >\starttyping
> >A and not B
> >\stoptyping
> >
> >\starttyping
> >not (A and not B)
> >\stoptyping
> >
> > \stopbuffer
> > \savebuffer[file={\jobname-luatemplate.mkix}, list={luatemplate}]
> > \input \jobname-luatemplate.mkix
> > \stoptext
> > 
> > but without the need to save to an external file.
> this is just for the mode right? in that case we can also can provide
> 
> 

:-)

I don't use templates too often, so I don't have other examples in mind where 
the \startluatemplate ... \stopluatemplate might be needed. So, just adding 
tex.enablemode at the lua will also work. We can see if another use case comes 
up in the future!

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] Typing within doifmode leads to error

2021-03-20 Thread Aditya Mahajan
On Sat, 20 Mar 2021, Hans Hagen wrote:

> > 
> > I wonder if we could have an environment, say \startluatemplate ...
> > \stopluatemplate, which is evaluated on the fly rather than when loading a
> > file.
> 
> define 'evaluated on the fly'

Consider the following example:

\enablemode[A]
\starttext
\startluatemplate
  
  \starttyping
  A and not B
  \stoptyping
  
  \starttyping
  not (A and not B)
  \stoptyping
  
\stopluatemplate
\stoptext

What I am thinking is that \startluatemplate ... \stopluatemplate grabs the 
content (like a buffer) and then processes it using the mkix conversion 
mechanism. Thus, in terms of output, it should be equivalent to:

\enablemode[A]
\starttext
\startbuffer[luatemplate]
  
  \starttyping
  A and not B
  \stoptyping
  
  \starttyping
  not (A and not B)
  \stoptyping
  
\stopbuffer
\savebuffer[file={\jobname-luatemplate.mkix}, list={luatemplate}]
\input \jobname-luatemplate.mkix
\stoptext

but without the need to save to an external file. 

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] Typing within doifmode leads to error

2021-03-20 Thread Aditya Mahajan
On Sat, 20 Mar 2021, Hans Hagen wrote:

> On 3/20/2021 4:00 PM, Christoph Reller wrote:
> > On Sat, Mar 20, 2021 at 12:12 PM Hans Hagen  > <mailto:j.ha...@xs4all.nl>> wrote:
> > 
> > On 3/20/2021 8:24 AM, Aditya Mahajan wrote:
> >  > On Sat, 20 Mar 2021, Christoph Reller wrote:
> >  >> Of course we can do this in lua:
> >  >>
> >  >> if tex.modes["A"] and not tex.modes{"B"] then
> >  >> ...
> >  >> end
> >  >
> >  > ... which means that you can use that at the context end as well
> > (old feature).
> >  > Save the following as test.mkix (or add "% macros=mkix" as the
> > first line):
> >  >
> >  > ```
> >  > \starttext
> >  > 
> >  > \starttyping
> >  > A and not B
> >  > \stoptyping
> >  > 
> >  > \starttyping
> >  > not (A and not B)
> >  > \stoptyping
> >  > 
> >  > \stoptext
> > a neat application!
> > 
> > 
> > Thank you for this hint, Aditya. This would be a very nice solution 
> > indeed. But it does not seem to work:
> > 
> > % macros=mkix
> > \definemode[A][yes]
> > \starttext
> > \startluacode
> >    if tex.modes['A'] then
> >      context("A")
> >    end
> > \stopluacode
> > 
> > A
> > 
> > \stoptext
> > 
> > With ConTeXt LMTX 2021.03.17 the output of the above is a single "A". I 
> > would expect two. What am I doing wrong?
> 
> When the file gets preprocessed the mode is not known
> 
> context --mode=A foo.tex
> 
> it does of course also work when you set the mode in a parent file and 
> then include foo.tex

I wonder if we could have an environment, say \startluatemplate ... 
\stopluatemplate, which is evaluated on the fly rather than when loading a 
file. 

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] Typing within doifmode leads to error

2021-03-20 Thread Aditya Mahajan
On Sat, 20 Mar 2021, Christoph Reller wrote:
> Of course we can do this in lua:
> 
> if tex.modes["A"] and not tex.modes{"B"] then
> ...
> end

... which means that you can use that at the context end as well (old feature).
Save the following as test.mkix (or add "% macros=mkix" as the first line):

```
\starttext

\starttyping
A and not B
\stoptyping

\starttyping
not (A and not B)
\stoptyping

\stoptext
```

See the templates manual for more details: 
https://www.pragma-ade.com/general/manuals/templates-mkiv.pdf

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] Typing within doifmode leads to error

2021-03-18 Thread Aditya Mahajan
On Fri, 19 Mar 2021, Christoph Reller wrote:

> Hi,
> 
> Consider the following MWE:
> 
> \definetyping[T]
> \definemode[mode][yes]
> \starttext
> \doifmode{mode}{%
>   \startT
> Bla
>   \stopT}
> \stoptext
> 
> Compilation with the currently latest ConTeXt LMTX (ver: 2021.03.17 17:46
> LMTX  fmt: 2021.3.18) fails with:
> 
> tex error   > runaway error: end of file encountered
> mtx-context | fatal error: return code: 1
> 
> Compilation is successful if I replace doifmode{mode}{...} by
> \startmode[mode]...\stopmode.
> 
> Is there anything I'm missing? (This could be a bug.)

Has to be with how tex works. The argument of any macro (\doifmode{mode}{...} 
in this case) is scanned under the current catcode regime. So, any environment 
(like typing) which changes catcodes does work inside the argument to another 
macro. 

So, either use the environment version of \doifmode (which doesn't _capture_ it 
content):

\definetyping[T]
\definemode[mode][yes]
\starttext
\startmode[mode]
  \startT
Bla
  \stopT
\stopmode
\stoptext

Or use buffers (to avoid catcode all together):

\definetyping[T]
\definemode[mode][yes]
\starttext
\startbuffer[code]
\startT
Bla
\stopT
\stopbuffer

\doifmode{mode}{\getbuffer[code]}
\stoptext

or (note type**T**buffer so that the output is formatting according to the 
options of \definetyping[T])

\definetyping[T]
\definemode[mode][yes]
\starttext
\startbuffer[code]
Bla
\stopbuffer

\doifmode{mode}{\typeTbuffer[code]}
\stoptext

Perhaps this should be added to the FAQ on the wiki.

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] Math: Nested Cases?

2021-03-18 Thread Aditya Mahajan
On Thu, 18 Mar 2021, Weber, Matthias wrote:

> Hello,
> 
> Is it possible to nest cases in math, like so:

In principle, it should be. But we never tested this and I suspect that there 
is some macro which doesn't get initialized correctly in nested cases. 

> \starttext
> \startformula
> x=
>\startcases[align={right,left},distance=3pt]
>\NC  a \NC =
>\startcases[align={right,left},distance=3pt]
>\NC  1 \NC  \text{case  a1} \NR
>\NC  2 \NC  \text{case  a2} \NR
>\stopcases
>\NR
>\NC b \NC =
>\startcases[align={right,left},distance=3pt]
>\NC  3 \NC  \text{case  b3}\NR
>\NC 4  \NC  \text{case  b4}\NR
>\stopcases
>\NR
>\stopcases
> \stopformula
> \stoptext
> 
> I get an error about a missing $ when I try a nested start/stop-cases.

The missing $ error is because the cases environment uses two column separators 
(for the second column): \NC for "normal text column" and \MC for "math 
column". This is so that in the typical case, you can just use:

\startformula
  x = \startcases
  \NC 1 \NC case $a_1$ \NR
  \NC 2 \NC case $a_2$ \NR
  \stopcases
\stopformula

So, in your cases, you should have used:

\starttext
\startformula
x=
   \startcases[align={right,left},distance=3pt]
   \NC  a \MC =
   \startcases[align={right,left},distance=3pt]
   \NC  1 \NC  case  a1 \NR
   \NC  2 \NC  case  a2 \NR
   \stopcases
   \NR
   \NC b \MC =
   \startcases[align={right,left},distance=3pt]
   \NC  3 \NC  case  b3\NR
   \NC 4  \NC  case  b4\NR
   \stopcases
   \NR
   \stopcases
\stopformula
\stoptext


But, something goes wrong and that doesn't work either (with a different error 
message). I suspect that something is not getting initialized correctly at 
\startcases and will look into that. 

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] lmt_outline

2021-03-10 Thread Aditya Mahajan
On Wed, 10 Mar 2021, Mohammad Hossein Bateni wrote:

> Hello,
> 
> Hans said he's in the metapost mode now :)
> 
> I have used lmt_outline in the following example and it is really an
> improvement over the previous outline "effect" because one can set the
> fillcolor and drawcolor separately.  (that was not possible before, right?)
> 
> \starttext
> \definedfont[dejavusansmono*arabic]
> \setupalign[r2l]
> \startMPcode
> draw lmt_outline [
>   text = "سلام",
>   drawcolor = "red",
>   fillcolor = "white",
>   kind = "reverse",
>   align = "r2l",
> ] scaled 3mm;
> \stopMPcode
> \stoptext
> 
> 1. This works well on a plain background.  I can specify the background
> color in fillcolor and get the outline effect.  When the background is an
> image, this does not work too well.  Can we use some clip trickery to allow
> for "transparent" fill?  Ideally I want to set the fillcolor to a special
> value that would lead to only the outlines drawn.

Have you seen this example on the wiki which uses nofill:

https://wiki.contextgarden.net/Cover_Pages#Empty_or_Transparent_letters

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] Incorrect css reference in exported html file

2021-02-27 Thread Aditya Mahajan
Hi,

This message is prompted by a bug report for t-vim 
(https://github.com/adityam/filter/issues/43), but the issue is more general. 
Whenever, `cssfile` in `\setupexport` points to a file now in $PWD, the 
reference to the file in the exported CSS is incorrect:

Consider the following directory tree:

test.tex
styles/mystyle.css

where test.tex is:

```
\setupbackend[export=yes]
\setupexport[cssfile=styles/mystyle.css]

\starttext
\startparagraph
  This is a test
\stopparagraph
\stoptext
```

and 

styles/mystyle.tex is (the content doesn't matter, listing it for completeness):

```
paragraph,
p,
div.paragraph,
div.p {
  color : red ;
}
```

I am attaching a zip file for convenience. 

When I compile the above file, I get (selective lines from output)

```
backend > export > copying styles/mystyle.css
...
backend > export > adding css reference 'styles/styles/mystyle.css'
```

Indeed, the styles/mystyle.css file is copied to 
`test-export/styles/mystyle.css` but the reference in 
`test-export/test-export-div.html` is:

```

```

Note the repeated styles/styles. 

What is happening is that while copying the file, context is using (in 
back-exp.lua):

local source = addsuffix(cssextra[i],"css")
local target = joinfile(stylepath,basename(source))

while for reference, context is using:

result[#result+1] = replacetemplate(csspreamble, { filename = cssfile })
extras[#extras+1] = replacetemplate(cssheadlink, { filename = cssfile })

Shouldn't the last part be 

  filename=basename(source)

to get the right name? Without that whenever the value of cssfile is a file in 
another directory, the css reference in the exported html file will be 
incorrect.

In case anyone is interested, this manifests in t-vim as follows.
The t-vim module includes a pre-generated css file which provides the color and 
style values for the default color schemes. 

The module provides a macro \vimcssfile, which is the complete path of the file 
(basically the value of  `resolvers.resolve("full:vimtyping-default.css")`).

The intended usage is:

\usemodule[vim]
\setupbackend[export=yes]
\setupexport[cssfile=\vimtypingcssfile]
...


In this case, the css file is correctly copied to the '\jobname-export/styles` 
directory. but the `\jobname-div.html` file contains a unusable reference:

```
...

```

In principle, I can work around this in t-vim but I think that this will impact 
others as well.

Thanks,
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] \hbox to ... equivalent in ConTeXt (\framed)

2021-02-26 Thread Aditya Mahajan
On Fri, 26 Feb 2021, Jairo A. del Rio wrote:

> Hi list.
> 
> Is there an interface for \hbox to  via framed? I think it's not the
> ConTeXt spirit to do something like
> 
> \framed[offset=0cm]{\hbox to 10cm{Uno dos tres}}

\framed[width=10cm]{}

and

\framed[height=3cm, width=10cm]{...}

if you want a box with a specified width and height. 

> where spacing is stretched so all the available space is filled, so I want
> to know about a better way. Thank you beforehand.

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] How to reduce the inter-item space

2021-02-26 Thread Aditya Mahajan
On Fri, 26 Feb 2021, Alain Delmotte wrote:

> 
> Thanks, that answered all my requirements.

This post illustrates the effect of each keyword for spacing:

https://adityam.github.io/context-blog/post/spacing-in-itemize/

> I suppose that the rule "not mixing keywords and assignment in the same
> argument" is valid for all setups having multiples commands.

Yes, there are no commands in ConTeXt where keyword and assignments are mixed 
in the options.

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
___


  1   2   3   4   5   6   7   8   9   10   >