Re: [NTG-context] Macros which scan subscripts/superscripts in ConTeXt

2020-06-25 Thread Aditya Mahajan

On Thu, 25 Jun 2020, Jairo A. del Rio wrote:


Hi, list! I've seen the following in Stack Exchange:

https://tex.stackexchange.com/questions/503208/define-macro-that-scans-ahead-for-super-and-or-subscript-absorbs-them-and-mo

The answer is:

\documentclass{article}\usepackage{amsmath}\usepackage{xparse}
\NewDocumentCommand{\mymathsym}{e{^_}}{%
 x^{\mathrm{foo}\IfValueT{#1}{,#1}}_{\mathrm{bar}\IfValueT{#2}{,#2}}%}
\begin{document}
\begin{gather}\mymathsym \\\mymathsym^{\mathrm{extrasup}}
\\\mymathsym_{\mathrm{extrasub}}
\\\mymathsym^{\mathrm{extrasup}}_{\mathrm{extrasub}}
\\\mymathsym_{\mathrm{extrasub}}^{\mathrm{extrasup}}   \end{gather}
\end{document}

Such a macro contextually defines a behavior for a subscript and a
superscript even if they aren't displayed in a specific order, so

\mymacro_{a}^{b}

\mymacro^{b}_{a}


have the same output, even if the intended behavior is not the typical
one (I could redefine it so subscripts change colors, for instance).
Although I could just port the macro using xparse-generic because it
works in ConTeXt too, how to define a macro like that the ConTeXt way,
i.e., using only ConTeXt macros?


Return of the dodo :-)

% Must be outside \unprotect .. \protect so that _ has usual catcodes
\def\capturemathoplimits#1%
  {\doifnextcharelse _%
{\docapturemathoplimitsA{#1}}
{\doifnextcharelse ^%
  {\docapturemathoplimitsB{#1}}
  {\redocapturemathoplimits{#1

\def\docapturemathoplimitsA#1#2#3%
  {\doifnextcharelse ^%
{\dodocapturemathoplimitsA{#1}{#2}{#3}}
{\dodocapturemathoplimitsA{#1}{#2}{#3}\empty\empty}}

\def\dodocapturemathoplimitsA#1#2#3#4#5{#1{#5}{#3}}

\def\docapturemathoplimitsB#1#2#3%
  {\doifnextcharelse _%
{\dodocapturemathoplimitsB{#1}{#2}{#3}}
{\dodocapturemathoplimitsB{#1}{#2}{#3}\empty\empty}}

\def\dodocapturemathoplimitsB#1#2#3#4#5{#1{#3}{#5}}

\def\redocapturemathoplimits#1{#1\empty\empty\empty\empty\empty}


% Usage:

\define\mymacro{\capturemathoplimits\domymacro}

\def\domymacro#1#2%
  % #1 is supscript, #2 is subscript
  
{x^{\mathrm{foo}\doifsomething{#1}{,#1}}_{\mathrm{bar}\doifsomething{#2}{,#2}}}

\starttext
\startlines
$\mymacro$ 
$\mymacro^{\mathrm{extrasup}}$
$\mymacro_{\mathrm{extrasub}}$ 
$\mymacro^{\mathrm{extrasup}}_{\mathrm{extrasub}}$ 
$\mymacro_{\mathrm{extrasub}}^{\mathrm{extrasup}}$ 
\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
___


[NTG-context] Macros which scan subscripts/superscripts in ConTeXt

2020-06-25 Thread Jairo A. del Rio
Hi, list! I've seen the following in Stack Exchange:

https://tex.stackexchange.com/questions/503208/define-macro-that-scans-ahead-for-super-and-or-subscript-absorbs-them-and-mo

The answer is:

\documentclass{article}\usepackage{amsmath}\usepackage{xparse}
\NewDocumentCommand{\mymathsym}{e{^_}}{%
  x^{\mathrm{foo}\IfValueT{#1}{,#1}}_{\mathrm{bar}\IfValueT{#2}{,#2}}%}
\begin{document}
\begin{gather}\mymathsym \\\mymathsym^{\mathrm{extrasup}}
\\\mymathsym_{\mathrm{extrasub}}
\\\mymathsym^{\mathrm{extrasup}}_{\mathrm{extrasub}}
\\\mymathsym_{\mathrm{extrasub}}^{\mathrm{extrasup}}   \end{gather}
\end{document}

Such a macro contextually defines a behavior for a subscript and a
superscript even if they aren't displayed in a specific order, so

\mymacro_{a}^{b}

\mymacro^{b}_{a}


have the same output, even if the intended behavior is not the typical
one (I could redefine it so subscripts change colors, for instance).
Although I could just port the macro using xparse-generic because it
works in ConTeXt too, how to define a macro like that the ConTeXt way,
i.e., using only ConTeXt macros?

Thank you in advance.

Jairo :)
___
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] French interface

2020-06-25 Thread Wolfgang Schuster

Garulfo schrieb am 25.06.2020 um 21:34:

Hi,

If I understand, the translation file mult-def.lua provides 5 families
for translations:
1- commands
2- constants
3- variables
4- elements (prefix or suffix of commands) like
   - \completeREGISTER and \completeindex
    
   - \startmakeup and \stopmakeup
  ^^  ^^
5- setupstrings, to describe the syntaxe and the type of the arguments


1/ I don't understand how to impact, for example, FLOAT and chemical in:

 \placeFLOAT   becomes \placerFLOAT
 \startplaceFLOAT  becomes \debutplacerFLOAT
 \placerchemical   becomes \placerchemical
 \startplacerchemical  becomes \debutplacerchemical


\placefigure is a combination of the element "place" (\e!place) and the 
variable "figure" (\v!figure)


\startplacefigure is a combination of the elements "start" (\e!start) 
and "place" (\e!place) and the variable "figure" (\v!figure.)



2/ I don't understand the following

RUN OK:

% interface=fr
\debuttexte
\debutsection[titre=test] This is a test \finsection
\codelua{context("Foo Bar 1")}
\fintexte

\ctxlua?

% interface=fr
\debuttexte
\debutsection[titre=test] This is a test \finsection
\debutcodelua  context("Foo Bar 2") \fincodelua
\fintexte

with:
tex error   > error not related to input file:
tex error   >   tex: ?
tex error   >   lua: ?
tex error   >   mps: -
mtx-context | fatal error: return code: 256


I suppose that some complementary modifications may be required with
\start \stop and lua


Delimited command are problematic (especially when they change 
catcodes), e.g. \startluacode use \stopluacode as hard coded delimiter 
for the environment. While it is easy to create a synonym for 
\startluacode this isn't the case for \stopluacode because the 
environment always look for \stopluacode as stopper and alternative 
names are ignored.


There are ways to work around this (e.g. \startfootnote) but for the 
english interface they aren't needed in most cases.


Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] French interface

2020-06-25 Thread Garulfo

Hi,

If I understand, the translation file mult-def.lua provides 5 families
for translations:
1- commands
2- constants
3- variables
4- elements (prefix or suffix of commands) like
   - \completeREGISTER and \completeindex
    
   - \startmakeup and \stopmakeup
  ^^  ^^
5- setupstrings, to describe the syntaxe and the type of the arguments


1/ I don't understand how to impact, for example, FLOAT and chemical in:

 \placeFLOAT   becomes \placerFLOAT
 \startplaceFLOAT  becomes \debutplacerFLOAT
 \placerchemical   becomes \placerchemical
 \startplacerchemical  becomes \debutplacerchemical

2/ I don't understand the following

RUN OK:

% interface=fr
\debuttexte
\debutsection[titre=test] This is a test \finsection
\codelua{context("Foo Bar 1")}
\fintexte

DOESNT RUN
% interface=fr
\debuttexte
\debutsection[titre=test] This is a test \finsection
\debutcodelua  context("Foo Bar 2") \fincodelua
\fintexte

with:
tex error   > error not related to input file:
tex error   >   tex: ?
tex error   >   lua: ?
tex error   >   mps: -
mtx-context | fatal error: return code: 256


I suppose that some complementary modifications may be required with
\start \stop and lua


Once again, thanks a lot for your support.


Le 24/06/2020 à 23:35, Hans Hagen a écrit :

On 6/24/2020 11:01 PM, Garulfo wrote:

Hi,

I try to update and to fill the french content of mult-def.lua.

Currently, I have an updated "mult-def.lua" file. 3 questions :

1/ which commands should be executed in order to make the new local
    interface effective with context


context --make fr

btw, top lines of files can have % interface=fr


2/ which commands should be executed in order to build a local version
    of setup-fr.pdf


context --interface=fr --global --result=mysetup x-setups-overview.mkiv


3/ many commands in setup-fr.pdf are not documented in mult-def.lua
    where does the additionnal translations should come from ?

users who know the language

Hans

-
   Hans Hagen | PRAGMA ADE
   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
    tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] spacing before items

2020-06-25 Thread David Rogers

Mike Cooper  writes:


Thanks David!

I don't think I've ever been quite so frustrated at trying to 
learn anything else in my life!  If it wasn't required by my 
job, I wouldn't have made it past the first day or two (3 months 
ago).  But I'm slogging away and it's gradually coming together 
(I think).  I spent my whole day yesterday figuring out how to 
do some very basic formatting/layout that would have taken 5-10 
minutes in Word or HTML/CSS.


People have been very helpful and patient with me!!  Thanks to 
all of you for that!


And thanks David for this explanation of the situation.

regards,
Mike


You may already be doing what I'm about to suggest. If so, please 
disregard.


One source that has helped me a lot is the archive of this mailing 
list, where I've searched for any messages that mention whatever 
it is that I'm looking for. Of course such a search is slower than 
scrolling through the index of a manual, and sometimes it's hard 
to figure out "What keyword do I search on? If I knew the correct 
keyword, I'd be done this already!" - but quite often I've "hit 
the jackpot" and found exactly what I needed, or close enough that 
I only had to change some details.


You will soon notice that there are some people on the list who 
consistently see through the problems that are presented, and who 
say something like "I think you probably want something like 
this:" - followed by a solution that makes you say confidently 
"A-ha! So THAT'S how that's done!".


The really good problem-solving sessions on the list, both the 
elegant answers and the questions that precede them, could form a 
pretty good start on a manual. Of course such a method is 
hit-or-miss, but in this case there are quite a few hits. Just 
watch out (in much older messages) that you're not fully relying 
on an answer based on ConTeXt Mk II, because many of those 
solutions no longer work in the newer versions.


... which has accidentally led me to another documentation 
comment. Hans's programming philosophy is not something I'm an 
expert on, but it seems clear that he values "usability, good 
function, and getting the job done well" much higher than he 
values "backward compatibility forever". In other words, if 
something is broken or not good enough, he doesn't hesitate to fix 
it or improve it in the best way he can see. This is good for the 
software in that it is constantly improving in every direction, 
but it does also make it a bit more of a challenge to document, 
and a bit more of a challenge to find someone who *wants* to 
document it - "How ConTeXt Used To Work Last Year" is clearly not 
going to be a top-selling title. :) But despite that, the majority 
of what you want to know has not changed in quite some time, and 
usually only *very* old solutions will fail completely.


I want to finish this message by saying: When you read through 
"SomeFile.tex" that you've created, every switch and command in it 
should make sense to you. In the beginning that might not always 
be the case, but it's easier for you to get there than it might 
sound, and you'll see that all the best solutions you get from 
others share that quality of "Ah, I see, that makes sense, I get 
how this works". Most of the time, a solution that doesn't give 
you that feeling is not quite the right way to do it. Of course a 
poor solution is better than nothing, but please don't stay 
satisfied with hairy-looking clusters of commands that sort of 
work but no one knows why. (I've written lots of those, that's why 
I say this.) :) Simple and direct writing means the mistakes will 
soon become obvious; the worst thing to do in ConTeXt is to make a 
complicated mysterious mistake that you can't even find.


Well. THAT turned out longer than I intended. :)

--
David
___
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] error running wiki example with labels

2020-06-25 Thread Jan-Erik Hägglöf
It is difficult to see the differences in this case, but I supply both logfiles

test-by-shell-context.log
Description: Binary data


test-inside-with-mtxrun.log
Description: Binary data
Now I also upgraded lmtx to latest version.Thanks/Janne25 juni 2020 kl. 09:38 skrev Taco Hoekwater :Hi,On 24 Jun 2020, at 23:13, Jan-Erik Hägglöf  wrote:Is the difference when I’m running mtxrun … inside macvimI would suspect PATH problems. Try running this bit of code both ways,and compare the differences:\starttext\startluacodefor a,v in pairs(os.env) do  logs.report('ENV', a .. '=' ..v)end\stopluacode\stoptextinstead of just context ? in the terminal24 juni 2020 kl. 21:05 skrev Jan-Erik Hägglöf :lua error   > lua error on line 70 in file ./labels3.tex:function call [801]: ...-64/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:435: attempt to index a nil value (upvalue 'filehandle')___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-contextwebpage  : http://www.pragma-ade.nl / http://context.aanhet.netarchive  : https://bitbucket.org/phg/context-mirror/commits/wiki : http://contextgarden.net___Taco HoekwaterElvenkind BV___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-contextwebpage  : http://www.pragma-ade.nl / http://context.aanhet.netarchive  : https://bitbucket.org/phg/context-mirror/commits/wiki : http://contextgarden.net__
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] Which lua XML library is embedded in LMTX?

2020-06-25 Thread Gerben Wierda
According to the XML manual:

<< 2.1 >> TEX versus LUA

It will not come as a surprise that we can access xml files from TEX as well as 
from Lua. In fact there are two methods to deal with xml in Lua. First there 
are the low level xml functions in the xml namespace. On top of those functions 
there is a set of functions in the lxml namespace that deals with xml in a more 
TEXie way.

<< 3.7 >> manipulation

You can use Lua code to manipulate the tree and it makes no sense to duplicate 
this in TEX. In the future we might provide an interface to some of this 
functionality. Keep in mind that manipuating the tree might have side effects 
as we maintain several indices into the tree that also needs to be updated 
then. 


Having read that, I was loooking for the documentation of the commands that are 
available in the xml namespace. I want to manipulate a XML tree in LMTX lua. 
But looking online gives me all kinds of different XML-solutions that are 
proposed for lua. Which one is embedded in LMTX and available in the xml 
namespace? But then I get confused because other elements like xml.first, 
xml.collected are in the xml namespavce and mentioned.

So, maybe I misunderstand things and is the documentation in 

<< 5.5 >> selectors and injectors

This section describes a bit special feature, one that we needed for a project 
where we could not touch the original content but could add specific sections 
for our own purpose. Hopefully the example demonstrates its useability. 

But that part I do not understand.

What I need (in LMTX lua) to add (sub)nodes to the XML node (that I read with 
xml.first()) because the data I get is broken and I need to fix it before I can 
use it (and I cannot get good data) The easiest way is to add the correct data 
to the XML and then use it in my code. If I cannot do that I need to write 
parallel code that largely does the same as what I already have (ugh)..

G___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] update

2020-06-25 Thread Hans Hagen

Hi,

I uploaded a new version (both mkiv and lmtx). We removed some low level 
no longer used code (older engines), normalized some in the process, 
fixed a few things, etc.


=== lmtx only ===

While updating the cld manual I decided to also add an other table 
mechanism (in addition to the one already reported in an earlier mail). 
I have no clue how useful it is, but as usual with tex, users find ways 
to (ab)use it. This one behaves a bit more like registers. A hashed one 
is defined as:


\newhashedtable\somehashtable

\somehashtable{ foo = 123, bar = "foo" }
[123 = \the\somehashtable{foo}] [123 = \the\somehashtable foo ]
[foo = \the\somehashtable{bar}] [foo = \the\somehashtable bar ]

\bgroup
\somehashtable{ foo = 456, bar = "oof" }
[456 = \the\somehashtable{foo}]
[oof = \the\somehashtable{bar}]
\egroup

[123 = \the\somehashtable{foo}]
[foo = \the\somehashtable{bar}]

\bgroup
\global\somehashtable{ foo = 456 }
   \somehashtable{ bar = "oof" }
[456 = \the\somehashtable{foo}]
[oof = \the\somehashtable{bar}]
\egroup

[456 = \the\somehashtable{foo}]
[foo = \the\somehashtable{bar}]

or an indexed one:

\newindexedtable\someindextable

\someindextable{ 123, "foo" }
[123 = \the\someindextable 1] [123 = \the\someindextable \numexpr 2 - 
1\relax]
[foo = \the\someindextable 2] [foo = \the\someindextable \numexpr 1 + 
1\relax]


\bgroup
\someindextable{ 456, "oof" }
[456 = \the\someindextable 1]
[oof = \the\someindextable 2]
\egroup

[123 = \the\someindextable 1]
[foo = \the\someindextable 2]

\bgroup
\global\someindextable{ [1] = 456 }
   \someindextable{ [2] = "oof" }
[456 = \the\someindextable 1]
[oof = \the\someindextable 2]
\egroup

[456 = \the\someindextable 1]
[foo = \the\someindextable 2]

In both cases, local and global assignments are supported.

At the Lua end you can access these tables too:

context.hashedtables.somehashtable.bar
context.indexedtables.someindextable[2]

There is some overhead involved but performance and memory usage is 
quiite okay.


Hans



-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] error running wiki example with labels

2020-06-25 Thread Taco Hoekwater
Hi,

> On 24 Jun 2020, at 23:13, Jan-Erik Hägglöf  wrote:
> 
> Is the difference when I’m running mtxrun … inside macvim

I would suspect PATH problems. Try running this bit of code both ways,
and compare the differences:

\starttext
\startluacode
for a,v in pairs(os.env) do
   logs.report('ENV', a .. '=' ..v)
end
\stopluacode
\stoptext


> 
> instead of just context ? in the terminal
> 
>> 24 juni 2020 kl. 21:05 skrev Jan-Erik Hägglöf :
>> 
>> lua error   > lua error on line 70 in file ./labels3.tex:
>> 
>> function call [801]: 
>> ...-64/tex/texmf-context/tex/context/base/mkiv/node-syn.lua:435: attempt to 
>> index a nil value (upvalue 'filehandle')
> 
> ___
> 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
> ___

Taco Hoekwater
Elvenkind BV




___
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] .jpeg not recognised in LMTX

2020-06-25 Thread Hans Hagen

On 6/25/2020 12:00 AM, Sytse Knypstra wrote:
Today I discovered that my LMTX version (2020.06.20) does not render an 
\externalfigure with .jpeg extension. After renaming to .jpg the picture 
is correctly shown. I would suggest to add the .jpeg extension to the 
list of allowed graphic types in LMTX.

hm, it should work (alternative suffixes), but it i'll check it

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___