[NTG-context] Re: \intertext and highlighting with \alignhere/\breakhere

2024-03-13 Thread Max Chernoff
Hi Hans, Mikael,

On Wed, 2024-03-13 at 13:06 +0100, Hans Hagen wrote:
> On 3/13/2024 12:26 PM, Mikael Sundqvist wrote:
> > I can confirm that it works over \alignhere. Hans is doing some black
> > magic, but I guess he did not want to show off by including the whole
> > line.
> Indeed, no need to show of the obvious
> 
> \definebar
>[mybar]
>[backgroundbar]
>[height=\strutht,depth=\strutdp,offset=.250ex,color=red]
> 
> [...]

That looks perfect, thanks!
-- Max
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: \intertext and highlighting with \alignhere/\breakhere

2024-03-13 Thread Hans Hagen via ntg-context

On 3/13/2024 12:26 PM, Mikael Sundqvist wrote:

Hi,

On Wed, Mar 13, 2024 at 11:37 AM Max Chernoff  wrote:


Hi Hans,

On Tue, 2024-03-12 at 15:21 +0100, Hans Hagen wrote:

the next upload will support the attached ... so no ugly hacky code needed


"\texthere[inbetween]" looks perfect, thanks!

The "\definebar[...][inlined]" doesn't look quite right though -- the
issue that I'm having is that I can't figure out how to highlight across
both sides of an \alignhere without any questionable hacks. Unless the
new "inlined" does work across an \alignhere and I'm just not seeing it
in the example.

Thanks again,
-- Max


I can confirm that it works over \alignhere. Hans is doing some black
magic, but I guess he did not want to show off by including the whole
line.

Indeed, no need to show of the obvious

\definebar
  [mybar]
  [backgroundbar]
  [height=\strutht,depth=\strutdp,offset=.250ex,color=red]

\definebar
  [yourbar]
  [backgroundbar]
  [height=\strutht,depth=\strutdp,offset=.125ex,color=blue]

\definebar
  [ourbar]
  [backgroundbar]
  [height=\strutht,depth=\strutdp,offset=.125ex,color=green]

\starttext

\startTEXpage[width=4cm]
\startformula
a \alignhere= b + c \breakhere
    \mybar {d + \yourbar{e \alignhere=} f \breakhere
g \alignhere \ourbar{=} h} + i
\stopformula
\stopTEXpage

\stoptext

Especially when it would not pass the rigourous accessibility check (esp 
wrt color) of your university,


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
-


inter-001.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 / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: \intertext and highlighting with \alignhere/\breakhere

2024-03-13 Thread Mikael Sundqvist
Hi,

On Wed, Mar 13, 2024 at 11:37 AM Max Chernoff  wrote:
>
> Hi Hans,
>
> On Tue, 2024-03-12 at 15:21 +0100, Hans Hagen wrote:
> > the next upload will support the attached ... so no ugly hacky code needed
>
> "\texthere[inbetween]" looks perfect, thanks!
>
> The "\definebar[...][inlined]" doesn't look quite right though -- the
> issue that I'm having is that I can't figure out how to highlight across
> both sides of an \alignhere without any questionable hacks. Unless the
> new "inlined" does work across an \alignhere and I'm just not seeing it
> in the example.
>
> Thanks again,
> -- Max

I can confirm that it works over \alignhere. Hans is doing some black
magic, but I guess he did not want to show off by including the whole
line.

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: \intertext and highlighting with \alignhere/\breakhere

2024-03-13 Thread Max Chernoff
Hi Hans,

On Tue, 2024-03-12 at 15:21 +0100, Hans Hagen wrote:
> the next upload will support the attached ... so no ugly hacky code needed

"\texthere[inbetween]" looks perfect, thanks!

The "\definebar[...][inlined]" doesn't look quite right though -- the
issue that I'm having is that I can't figure out how to highlight across
both sides of an \alignhere without any questionable hacks. Unless the
new "inlined" does work across an \alignhere and I'm just not seeing it
in the example.

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: \intertext and highlighting with \alignhere/\breakhere

2024-03-12 Thread Hans Hagen

On 3/12/2024 8:57 AM, Max Chernoff wrote:

Hi all,

Often I want to include a sentence/paragraph in the middle of a long
multipart formula. With the old \startalign/\stopalign formulas, I could
use \intertext{...} to do this, but this doesn't work with the new
\alignhere/\breakhere formulas. I've managed to find a "solution" for
this, although I'd prefer something a bit less hacky. Any ideas?

Also, is there a way to highlight an equation across an \alignhere? Once
again, I've found a "solution", but like before, it's pretty hacky.

Example files are attached.

the next upload will support the attached ... so no ugly hacky code needed

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
-


inter-001.pdf
Description: Adobe PDF document
\definebar[mybar][inlined][offset=.25ex,color=red]

\starttext

\startformula
    a  \alignhere= b + c \breakhere
\mybar {d + e} \alignhere= f \breakhere
    g  \alignhere= h + i
\stopformula

\page

\samplefile{knuth}
\startformula
\text{something} + \text{really} + \text{really} + \text{long} 
\alignhere= \sqrt{x} \numberhere
\texthere[inbetween]{\input{knuth}}
d \alignhere= e + f \numberhere \breakhere
g \alignhere= h + i \breakhere
j \alignhere= k + l
\stopformula
\samplefile{knuth}

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

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: \intertext and highlighting with \alignhere/\breakhere

2024-03-12 Thread Hans Hagen

On 3/12/2024 8:57 AM, Max Chernoff wrote:

Hi all,

Often I want to include a sentence/paragraph in the middle of a long
multipart formula. With the old \startalign/\stopalign formulas, I could
use \intertext{...} to do this, but this doesn't work with the new
\alignhere/\breakhere formulas. I've managed to find a "solution" for
this, although I'd prefer something a bit less hacky. Any ideas?

Also, is there a way to highlight an equation across an \alignhere? Once
again, I've found a "solution", but like before, it's pretty hacky.

Example files are attached.

maybe

\starttexdefinition protected newintertext #1
\leftparbox [global] {
\vadjust pre \bgroup
\forgetall
\vskip.5\strutdp % needs to be more clever in the end
\dontleavehmode\vtop\bgroup
#1
\egroup
\egroup
}
\breakhere
\stoptexdefinition

but i need to discuss it with Mikael as we might integrate something 
better and then it needs to be documented (in the upcoming manual) as well


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 / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] \intertext and highlighting with \alignhere/\breakhere

2024-03-12 Thread Max Chernoff
Hi all,

Often I want to include a sentence/paragraph in the middle of a long
multipart formula. With the old \startalign/\stopalign formulas, I could
use \intertext{...} to do this, but this doesn't work with the new
\alignhere/\breakhere formulas. I've managed to find a "solution" for
this, although I'd prefer something a bit less hacky. Any ideas?

Also, is there a way to highlight an equation across an \alignhere? Once
again, I've found a "solution", but like before, it's pretty hacky.

Example files are attached.

Thanks,
-- Max
\setupindenting[yes, 3em]
\setuphead[section][page=yes]

\unprotect
\newbox\intertext_tmp_box
\newdimen\intertext_tmp_dimen

\starttexdefinition protected newintertext #1
\texthere[left]{
\setbox\intertext_tmp_box=\hbox{
\startframedtext[
offset=none,
width=\hsize,
frame=off,
]
\parindent = \v_spac_indentation_normal
\noindent
#1
\stopframedtext
}
\global\intertext_tmp_dimen = \ht\intertext_tmp_box
\vbox to 0pt{
\vskip\dimexpr 1ex - \baselineskip \relax
\box\intertext_tmp_box
\vss
}
\aftergrouped{
\aftergrouped{
\vadjust{
\penalty 1
\vskip\dimexpr \intertext_tmp_dimen - \baselineskip \relax
}
}
}
}
\breakhere
\stoptexdefinition
\protect

\starttext
\section{Old alignment}
\samplefile{knuth}
\placeformula\startformula\startalign
\NC \text{something} + \text{really} + \text{really} + \text{long} \NC= \sqrt{x} \NR[+]
\intertext{\samplefile{knuth}}
\NC d \NC= e + f \NR[+]
\NC g \NC= h + i
\stopalign\stopformula
\samplefile{knuth}


\section{“I expect to see \tex{noalign} only after the \tex{cr} of an alignment.”}
\starttyping
\samplefile{knuth}
\startformula
\text{something} + \text{really} + \text{really} + \text{long} \alignhere= \sqrt{x} \numberhere \breakhere
\intertext{\samplefile{knuth}}
d \alignhere= e + f \numberhere \breakhere
g \alignhere= h + i
\stopformula
\samplefile{knuth}
\stoptyping


\section{Alignment not kept}
\samplefile{knuth}
\startformula
\text{something} + \text{really} + \text{really} + \text{long} \alignhere= \sqrt{x} \numberhere
\stopformula
\samplefile{knuth}
\startformula
d \alignhere= e + f \numberhere \breakhere
g \alignhere= h + i
\stopformula
\samplefile{knuth}


\section{My hack}
\samplefile{knuth}
\startformula
\text{something} + \text{really} + \text{really} + \text{long} \alignhere= \sqrt{x} \numberhere \breakhere
\newintertext{\samplefile{knuth}}
d \alignhere= e + f \numberhere \breakhere
g \alignhere= h + i
\stopformula
\samplefile{knuth}
\stoptext
\unprotect
\newbox\hightlight_tmp_box

\definemathframed[_highlight][
location=mathematics,
frame=off,
background=color,
backgroundcolor=lightred,
backgroundoffset=0.25ex,
]

\tolerant\def\highlighthere#1\alignhere#2#3\breakhere{%
\setbox\hightlight_tmp_box=\hbox{%
\m{%
\forcedisplaymath%
#1#2\null%
    }%
    }%
\alignhere%
\phantom{%
\null#2\null%
}%
\mskip -8mu%
\hskip -\wd\hightlight_tmp_box%
\lower 1ex \hbox{%
\_highlight[
loffset=\wd\hightlight_tmp_box,
location=keep
]{%
\hskip -\wd\hightlight_tmp_box%
\forcedisplaymath%
#1#2#3%
}%
}%
\breakhere%
}
\protect

\starttext
\startformula
a \alignhere= b + c \breakhere
\highlighthere d + e \alignhere= f \breakhere
g \alignhere= h + i
\stopformula
\stoptext
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___