Re: [NTG-context] Convertnumber with \ref[number] fails in MkIV, works in LMTX

2021-10-28 Thread Rik Kabel via ntg-context


On 10/28/2021 02:56, Hans Hagen wrote:

On 10/28/2021 4:58 AM, Rik Kabel via ntg-context wrote:
Following up on my own note, I see that this fails under LMTX if 
compiled in a clean directory, but succeeds if first compiled with 
the troublesome line removed, and then, restoring the line, compiled 
a second time. It also works by placing a .tuc file from an older 
version of the document into the directory before compiling. Very 
strange indeed. The expected output, from one of those successful 
compilations:


So. I am clearly doing something wrong, but sometimes LMTX is letting 
me get away with it.


--
Rik

On 10/27/2021 21:47, Rik Kabel via ntg-context wrote:


Hello list,

The following fails with ConTeXt  ver: 2021.10.24 21:45 MKIV but 
works with the companion LMTX. The error message is:tex error   
> tex error on line 6 in file G:/TestConTeXt/convert.tex: ! 
Incompatible glue units , pointing to the second \convertnumber line.


\definelabel[XX]%[text=,before=,after=,alternative=inright]
    \startTEXpage[offset=2em]
     abc\XX[xx]\par
     \ref[number][xx] ·
     \convertnumber{r}{1} ·
     \convertnumber{R}{\ref[number][xx]}
    \stopTEXpage

In this case I am trying to display with roman numerals the number 
generated in the label created through \definelabel.


Suggestions welcomed.

the conmversion is (partly) done in lua so at some point the

  \ref[number][xx]

gets scanned which is more robust in lmtx than in mkiv

normally one does the conversion differently:

\definelabel[XX][numberconversion=R]
\definelabel[YY][XX][numberconversion=A]

\startTEXpage[offset=2em]
    1: \XX[xx]\par 2: \YY[xx]
\stopTEXpage

Hans



(Resending because attachment was too large.)

That generates a new labeled item albeit with a roman numeral label. I 
am trying to get the value of a previously generated numeric label 
converted roman numerals. So, consider that I have a numeric label 
identifying a paragraph of text. I want to reference that label in 
another place but need to do it in Latin.


I want to convert the original label number to a roman numeral for use 
in that one place, not generate a new label displayed as a roman 
numeral. So,


   \definelabel[XX][text=¶]
   \define\Naa{\ref[number][aa]}
   \define[1]\Nnn{\ref[number][#1]}
   \define\Raa{\convertnumber{R}{\ref[number][aa]}}
   \define[1]\Rnn{\convertnumber{R}{\ref[number][#1]}}
   \startTEXpage[offset=2em]
    Paragraph\XX[aa]\par
    Paragraph\XX[bb]\par
    Paragraph\XX[cc]\par
    1: \Naa\par
    2: \Nnn{bb}\par
   % these fail without an existing tuc file:
    I: {\la Vide paragraphum \Raa.}\par
    II: {\la Vide paragraphum \Rnn{bb}.}
   \stopTEXpage

should produce:

   Paragraph *¶ 1
   *Paragraph *¶ 2*
   Paragraph *¶ 3*
   1: 1
   2: 2
   I: Vide paragraphum I.
   II: Vide paragraphum II.

but this fails without an existing good tuc file. If I comment out the 
two latin lines, compile (to failure), and then uncomment the lines and 
try again, it compiles without error. Does this mean that 
\ref[number][label] does not really return a number as \convertnumber 
expects?


This is the case with today's upload as well (ConTeXt  ver: 2021.10.28 
10:19 LMTX).


--
Rik
___
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 number from context.figurewidth

2021-10-28 Thread Pablo Rodriguez via ntg-context
On 10/27/21 10:06 PM, Hans Hagen via ntg-context wrote:
> On 10/27/2021 9:20 PM, Pablo Rodriguez via ntg-context wrote:
>> On 10/26/21 6:31 PM, Pablo Rodriguez via ntg-context wrote:
>>> [...]
>>loader_times:write('.box placeholder width=' .. context.figurewidth
>>   .. ' height=' .. context.figureheight)
>>
>> I cannot concatenate string and function (and I need the number, not the
>> unit).
>>
>> Is there no way of doing it?
> i'm pretty sure this has been asked before
>
> \ctxlua{local f = figures.getinfo("cow.pdf") print(f and f.used and
> f.used.width)}
>
> so .. time to wikify it

Many thanks for your reply, Hans.

Already wikified at
https://wiki.contextgarden.net/Image_Placement#Measures_in_Lua.

Many thanks again for your help,

Pablo
--
http://www.ousia.tk
___
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] new upload, new trickery

2021-10-28 Thread Hans Hagen via ntg-context

Hi,

Among the 'can they be made better' candidates in the engine are 
\vadjust and \local[left|right]box primitives that are not really used 
in context (okay, vadjust is used in mkii).


The \vadjust vertical injector can be illustrated with

\starttext
\ignorespaces\input tufte \removeunwantedspaces
we want a break before this line \vadjust pre {\break}%
\ignorespaces\input tufte \removeunwantedspaces

\page

\ignorespaces\input tufte \removeunwantedspaces
we want seperate lines now \leftparbox{\vadjust post {\break}}%
\ignorespaces\input tufte \removeunwantedspaces
\resetleftparbox{}
\stoptext

It's a signal that injects something in a vertical list without 
interupting the horizontal text flow. One can inject before (pre) or 
after (post which is default). New is that we can also influence the 
order: after vs before preceding \vadjust in the same line.  Also new is 
that deeply nested adjustments can migrate (so the hole los: marks, 
inserts and vadjust are now in sync) which is demonstrated with the next 
example:


\starttext
\showstruts
\input tufte \removeunwantedspaces\space
\localleftbox  par {%
   \hbox to 0pt{%
  \llap{L}%
  \vadjust{\strut\blackrule[width=1cm,color=red]}%
  \hbox{\vadjust pre{\strut\blackrule[width=1cm,color=green]}}%
   }\hss
}%
\localrightbox par {}%
\input tufte \removeunwantedspaces\space
\vadjust pre{\strut BEFORE 1}%
\vadjust pre{\strut BEFORE 2}%
\vadjust before {\strut AFTER  1}%
\vadjust before {\strut AFTER  2}%
\ignorespaces
\input tufte
\stoptext

Indeed it looks bad (ugly) but it illustrates the idea. What makes 
vadjust sort of useless for content is that it messes up spacing (but if 
there is real demand and usage i can sort that out at some point, maybe 
some new options or so). Thsi example also brings us to local boxes:


\showframe

\starttext

\showmakeup[hbox]

\startnarrower[2*left] \raggedleft
{\localleftbox par {L1}\input tufte  \par}
\stopnarrower
\blank

\startnarrower[2*middle] \raggedcenter
{\localrightbox par {R1}\input tufte  \par}
\stopnarrower
\blank

\stoptext

New is the par keyword that forces the setting to be applied from the 
first line downards (fyio: these commands, when display set registers, 
when inline they set registers and inject a node). Watch out: one needs 
to use grouping in order not to bleed into other mechanisms.


Also new is that we can query the content of these registers using \the, 
as in:


\dorecurse{10}{
\showboxes
\localleftbox{\ruledhbox {\smallinfofont\setstrut\strut[L #1.0]}}%
\localleftbox{\ruledhbox {\smallinfofont\setstrut\strut[L 
#1.1]}\the\localleftbox}%
\localleftbox{\ruledhbox {\smallinfofont\setstrut\strut[L 
#1.2]}\the\localleftbox}%
\localleftbox{\ruledhbox {\smallinfofont\setstrut\strut[L 
#1.3]}\the\localleftbox}%

%
\localrightbox{\ruledhbox 
{\smallinfofont\setstrut\strut[R #1.0]}}%


\localrightbox{\the\localrightbox\ruledhbox{\smallinfofont\setstrut\strut[R 
#1.1]}}%


\localrightbox{\the\localrightbox\ruledhbox{\smallinfofont\setstrut\strut[R 
#1.2]}}%

\localrightbox{\the\localrightbox\ruledhbox{\smallinfofont[R #1.3]}}%
% \localrightbox{}%
\samplefile{tufte}
}

Flushing permits us to append and prepend but it's still ugly so that is 
why we now have a new interface (context layer on top of engine):


\dorecurse{10}{
\showboxes
%
\resetleftparbox
\resetrightparbox
%
\prependleftparbox {\ruledhbox{\smallinfofont\setstrut\strut[L #1.0]}}%
\prependleftparbox {\ruledhbox{\smallinfofont\setstrut\strut[L #1.1]}}%
\prependleftparbox {\ruledhbox{\smallinfofont\setstrut\strut[L #1.2]}}%
\prependleftparbox {\ruledhbox{\smallinfofont\setstrut\strut[L #1.3]}}%
%
\appendrightparbox{\ruledhbox{\smallinfofont\setstrut\strut[R #1.0]}}%
\appendrightparbox{\ruledhbox{\smallinfofont\setstrut\strut[R #1.1]}}%
\appendrightparbox{\ruledhbox{\smallinfofont\setstrut\strut[R #1.2]}}%
\appendrightparbox{\ruledhbox{\smallinfofont[R #1.3]}}%
%
\samplefile{tufte}
}

But as this is not really user friendly, there is more: a mechanism for 
hooking in handlers.


\definelocalboxes
  [linenumber]
  [command=\LeftNumber,
   location=left,
   width=3em,
   style=\bs,
   color=darkred]

\definelocalboxes
  [linenumbertwo]
  [linenumber]
  [command=\RightNumber,
   location=right,
   width=6em,
   style=\bf,
   color=darkgreen]

\definelocalboxes
  [linetext]
  [command=\LeftText,
   location=lefttext,
   style=\bs,
   color=darkblue]

\definelocalboxes
  [linetexttwo]
  [linetext]
  [command=\RightText,
   location=righttext,
   style=\bf,
   color=darkgray]

% just using the content

% \protected\def\LeftNumber {\hbox to 
\localboxesparameter{width}{\strut\box\localboxcontentbox\hss)}}
% \protected\def\RightNumber{\hbox to 
\localboxesparameter{width}{\strut(\hss\box\localboxcontentbox)}}


% using the 

Re: [NTG-context] Convertnumber with \ref[number] fails in MkIV, works in LMTX

2021-10-28 Thread Hans Hagen via ntg-context

On 10/28/2021 4:58 AM, Rik Kabel via ntg-context wrote:
Following up on my own note, I see that this fails under LMTX if 
compiled in a clean directory, but succeeds if first compiled with the 
troublesome line removed, and then, restoring the line, compiled a 
second time. It also works by placing a .tuc file from an older version 
of the document into the directory before compiling. Very strange 
indeed. The expected output, from one of those successful compilations:


So. I am clearly doing something wrong, but sometimes LMTX is letting me 
get away with it.


--
Rik

On 10/27/2021 21:47, Rik Kabel via ntg-context wrote:


Hello list,

The following fails with ConTeXt  ver: 2021.10.24 21:45 MKIV but works 
with the companion LMTX. The error message is:tex error   > tex 
error on line 6 in file G:/TestConTeXt/convert.tex: ! Incompatible 
glue units , pointing to the second \convertnumber line.


\definelabel[XX]%[text=,before=,after=,alternative=inright]
\startTEXpage[offset=2em]
 abc\XX[xx]\par
 \ref[number][xx] ·
 \convertnumber{r}{1} ·
 \convertnumber{R}{\ref[number][xx]}
\stopTEXpage

In this case I am trying to display with roman numerals the number 
generated in the label created through \definelabel.


Suggestions welcomed.

the conmversion is (partly) done in lua so at some point the

  \ref[number][xx]

gets scanned which is more robust in lmtx than in mkiv

normally one does the conversion differently:

\definelabel[XX][numberconversion=R]
\definelabel[YY][XX][numberconversion=A]

\startTEXpage[offset=2em]
1: \XX[xx]\par 2: \YY[xx]
\stopTEXpage

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
___