Re: [NTG-context] How to make something appear to the right of every paragraph?

2022-10-13 Thread Max Chernoff via ntg-context
Hi Joel,
> When I use the code given, it compiles and displays fine. But when I
> try replacing \everypar with \EveryPar, it halts during compiling

It looks like \EveryPar is a macro and not a token list.

> These both work great, but do that for the whole document? Is there a
> way to restrict it to only apply the lines to some parts of the file,
> not every single paragraph?

Option 1:

   \newif\ifprintlines
   
   \EveryPar{%
   \ifprintlines%
   \vbox to 0pt{%
   \dorecurse{3}{%
   \rlap{%
   \hskip\dimexpr\hsize+1em%
   \vrule height 0.4pt width 3cm%
   \relax%
   }%
   }%
   }%
   \fi%
   }
   
   \parskip=\baselineskip
   
   \starttext
   \printlinestrue
   One line paragraph
   
   Two line paragraph \\
   Two line paragraph
   
   Three line paragraph \\
   Three line paragraph \\
   Three line paragraph
   \printlinesfalse
   
   Four line paragraph \\
   Four line paragraph \\
   Four line paragraph \\
   Four line paragraph
   
   \samplefile{bryson}
   
   \printlinestrue
   \samplefile{knuth}
   \stoptext

Option 2:

   \startluacode
   -- Constants
   local RULE_OFFSET= tex.sp "1em"
   local RULE_THICKNESS = tex.sp "0.4pt"
   local RULE_LENGTH= tex.sp "3cm"
   
   local show_lines = true
   
   -- Callback
   function userdata.lines(head)
   if status.output_active or
  tex.nest.ptr > 1 or
  not show_lines
   then
   return head
   end
   
   local i = 0
   for n in node.traverseid(node.id "hlist", head) do
   i = i + 1
   if i > 3 then
   break
   end
   
   local offset = node.new "glue"
   offset.width = RULE_OFFSET
   node.slide(n.list).next = offset
   
   local rule = node.new "rule"
   rule.width = RULE_LENGTH
   rule.height = RULE_THICKNESS
   rule.depth = 0
   offset.next = rule
   end
   
   return head
   end
   
   nodes.tasks.appendaction(
   "finalizers",
   "after",
   "userdata.lines"
   )
   
   interfaces.implement {
   name  = "showlines",
   public= true,
   arguments = { "boolean" },
   actions   = function(x)
   show_lines = x
   end,
   }
   \stopluacode
   
   \parskip=\baselineskip
   
   \starttext
   \showlines true
   One line paragraph
   
   Two line paragraph \\
   Two line paragraph
   
   Three line paragraph \\
   Three line paragraph \\
   Three line paragraph
   
   \showlines false
   Four line paragraph \\
   Four line paragraph \\
   Four line paragraph \\
   Four line paragraph
   
   \samplefile{bryson}
   
   \showlines true
   \samplefile{knuth}
   \stoptext

These are both kind of hacky though. I'd recommend that you use Hans's
solution instead:

   \starttext
   
   \def\StartHack
 {\margintext
   [location=right,style=]
   {\thinrules[n=3]}}
   
   \def\StopHack
 {\par \ifnum\prevgraf<3
\blank[\the\numexpr4-\prevgraf\relax*line]
  \fi}
   
   \StartHack \input tufte \StopHack
   
   \StartHack test test \StopHack
   
   \StartHack test test \StopHack
   
   \stoptext

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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] atan2 function

2022-10-13 Thread Max Chernoff via ntg-context

Hi,

> The angle function doesn't appear to provide the same calculation as
> my atantwo in all cases.

They both give the same results, but "angle" gives a result in degrees
while "atantwo" gives a result in radians. This demo:

   \startMPpage
   vardef atantwo( expr dy, dx ) =
   save theta;
   
   numeric theta;
   
   theta := 0;
   
   if (dx > 0):
   theta := atan( dy / dx );
   elseif (dx < 0) and (dy >= 0):
   theta := atan( dy / dx ) + pi;
   elseif (dx < 0) and (dy < 0):
   theta := atan( dy / dx ) - pi;
   elseif (dx == 0) and (dy > 0):
   theta := pi / 2;
   elseif (dx == 0) and (dy < 0):
   theta := -pi / 2;
   fi;
   
   theta
   enddef;
   
   def showangles(expr dx, dy) =
   message "---"
   message "atantwo " & decimal atantwo(dy, dx)
   message "angle " & decimal (angle(dx, dy) * pi / 180)
   message "angle " & decimal angle(dx, dy)
   message "(" & decimal dx & ", " & decimal dy & ")"
   enddef;
   
   showangles(1, 0);
   showangles(1, 1);
   showangles(0, 1);
   showangles(-1, 1);
   showangles(-1, 0);
   showangles(-1, -1);
   showangles(0, -1);
   showangles(1, -1);
   \stopMPpage

gives:

   (1, 0)
   angle 0
   angle 0
   atantwo 0
   ---
   (1, 1)
   angle 45
   angle 0.78539816339744828
   atantwo 0.78539816339744828
   ---
   (0, 1)
   angle 90
   angle 1.5707963267948966
   atantwo 1.5707963267948966
   ---
   (-1, 1)
   angle 135
   angle 2.3561944901923448
   atantwo 2.3561944901923448
   ---
   (-1, 0)
   angle 180
   angle 3.1415926535897931
   atantwo 3.1415926535897931
   ---
   (-1, -1)
   angle -135
   angle -2.3561944901923448
   atantwo -2.3561944901923448
   ---
   (0, -1)
   angle -90
   angle -1.5707963267948966
   atantwo -1.5707963267948966
   ---
   (1, -1)
   angle -45
   angle -0.78539816339744828
   atantwo -0.78539816339744828
   ---
   
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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] LMTX generates PDFs with non-working fonts on real printers

2022-10-13 Thread Hans Hagen via ntg-context

On 10/13/2022 8:36 PM, Henning Hraban Ramm via ntg-context wrote:

Am 13.10.22 um 19:41 schrieb Pablo Rodriguez via ntg-context:

On 10/13/22 00:50, Max Chernoff via ntg-context wrote:

On Wed, 2022-10-12 at 13:14 +0200, Leah Neukirchen wrote:

[...]
The last version of font-cff.lua should also copy the hinting-related
values of the CFF properly (/BlueScale, /StemSnap[HV] etc).
We fixed that on the side. ;)


Yay!


Many thanks for your work fixing this, Leah and Hans.

The only remaining question is then when the new version will be be
released.


They who attended the latest online meeting know that there’s a secret 
project going on that needs to be completed first.
let's keep it a secret till at least the next meetup .. after all it 
relates to a more that 30 year old sort of secret


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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] LMTX generates PDFs with non-working fonts on real printers

2022-10-13 Thread Hans Hagen via ntg-context

On 10/13/2022 7:41 PM, Pablo Rodriguez via ntg-context wrote:

On 10/13/22 00:50, Max Chernoff via ntg-context wrote:

On Wed, 2022-10-12 at 13:14 +0200, Leah Neukirchen wrote:

[...]
The last version of font-cff.lua should also copy the hinting-related
values of the CFF properly (/BlueScale, /StemSnap[HV] etc).
We fixed that on the side. ;)


Yay!


Many thanks for your work fixing this, Leah and Hans.

The only remaining question is then when the new version will be be
released.
some day soon ... the apple m1 has to come online first (afaik apple 
didn't release a robust vm yet so the machine has to be kicked into 
action every now and then) and we only release when we can do all 
platforms ... apart from ms and me wanting to finish something first


it's not that no-one can print, right?

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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] \text{...} inside \sqrt is tiny

2022-10-13 Thread Hans Hagen via ntg-context

On 10/13/2022 2:38 PM, Gavin via ntg-context wrote:

Hi List,

When I use text inside a radical, the text is script-script size.

$\text{Radius} = \sqrt{\text{Area}/\pi}$

It should be normal size. Any ideas for a fix?

I stumbled on this issue when working with \units, but it is not specific to 
units.

fixed in next upload (better radical scanner in engine)

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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] atan2 function

2022-10-13 Thread Thangalin via ntg-context
Thank you, Max.

The angle function doesn't appear to provide the same calculation as
my atantwo in all cases.

https://pdfhost.io/v/Oqj7XmibJ_scaled

The shorter line segment should be directed towards the vertex closest
to the longer line segment. I tried using both:

theta := angle( dx, dy );
theta := angle( dy, dx );

Neither made a difference, in some cases the angle differs from what I'd expect.

My implementation is based on the first version given here:

https://en.wikipedia.org/wiki/Atan2#Definition_and_computation

I have something that works, so this is more of a curiosity as to
there being a difference between my implementation of atantwo and the
angle function.

Here's an example with many lines and the angle function:
https://pdfhost.io/v/1T4jgBnxh_scaled

On Wed, Oct 12, 2022 at 11:42 PM Max Chernoff  wrote:
>
> Hi,
>
> > How is atan2 called? I rolled my own as follows:
>
> > Is atan with two parameters supposed to behave like atan2?
>
> At mp-math.mpxl:167 there is:
>
>vardef atan   primary x = angle(1,x)   enddef ;
>
> The MetaPost manual says:
>
>The angle operator takes a pair and computes the two-argument
>arctangent; i.e., angle is the inverse of the dir operator
>
> So it looks like "angle" is the function that you want for "atan2".
>
> 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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] LMTX generates PDFs with non-working fonts on real printers

2022-10-13 Thread Willi Egger via ntg-context
Now! I am astonished about this blog! Super that you, Leah and Hans, insisted 
to find out what the culprit was! Thank you both so much for your effort!

Kind regards
Willi

> On 11 Oct 2022, at 21:07, Leah Neukirchen via ntg-context 
>  wrote:
> 
> Hans Hagen via ntg-context  writes:
> 
>> On 10/9/2022 8:03 AM, Max Chernoff via ntg-context wrote:
>>> Hi all,
>>> 
 I use LuaMetaTeX 2.10 20220918 + ConTeXt LMTX 2022.09.11.
 
 Here's a tiny test document, I disabled PDF compression but it also
 doesn't work with the default settings.
 
 \setupbackend[level=0,compresslevel=0]
 \starttext
 Just a line of text.
 \stoptext
 
 When I print this "directly" (i.e. sending the raw PDF to the printer)
 on a Ricoh MP3053 or on a Samsung CLP-680DW, I just get an empty page.
>>> Just to add some more data points, I tested the attached MkXL file
>>> on
>>> two printers, and the file printed perfectly on both.
>>> Printer 1:
>>>Brother HL-3170CDW
>>>Printed via running "cat test.mkxl.pdf | nc Colour-Printer.local 9100"
>>>Printer 2:
>>>HP M227f LaserJet
>>>Printed from the PDF file on a USB stick
>>>Neither printer is anything fancy; they're both fairly
>>> inexpensive home
>>> laser printers. I've got a much older Brother laser printer that I may be
>>> able to test with next week.
>>> Sorry I can't be of more help.
>> Leah and I are zooming in on the issue. It might relate to wrong font
>> matrix default behavior in the pdf printer driver, and GS got a fix
>> for that long ago, so maybe old printers with not-updated drivers can
>> be affected.
>> 
>> Once we're confident that we can catch it Leah (who does the low level
>> introspective testing with viewers, printers and tools) likely will
>> report on it and there will be a test file for users to test if what
>> we do is okay before we apply the safeguard.
> 
> There's a write up now on the issue:
> https://leahneukirchen.org/blog/archive/2022/10/50-blank-pages-or-black-box-debugging-of-pdf-rendering-in-printers.html
> 
> -- 
> Leah Neukirchenhttps://leahneukirchen.org/
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl / 
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> ___

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

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


Re: [NTG-context] LMTX generates PDFs with non-working fonts on real printers

2022-10-13 Thread Henning Hraban Ramm via ntg-context

Am 13.10.22 um 19:41 schrieb Pablo Rodriguez via ntg-context:

On 10/13/22 00:50, Max Chernoff via ntg-context wrote:

On Wed, 2022-10-12 at 13:14 +0200, Leah Neukirchen wrote:

[...]
The last version of font-cff.lua should also copy the hinting-related
values of the CFF properly (/BlueScale, /StemSnap[HV] etc).
We fixed that on the side. ;)


Yay!


Many thanks for your work fixing this, Leah and Hans.

The only remaining question is then when the new version will be be
released.


They who attended the latest online meeting know that there’s a secret 
project going on that needs to be completed first.


Hraban

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

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


Re: [NTG-context] LMTX generates PDFs with non-working fonts on real printers

2022-10-13 Thread Pablo Rodriguez via ntg-context
On 10/13/22 00:50, Max Chernoff via ntg-context wrote:
> On Wed, 2022-10-12 at 13:14 +0200, Leah Neukirchen wrote:
>> [...]
>> The last version of font-cff.lua should also copy the hinting-related
>> values of the CFF properly (/BlueScale, /StemSnap[HV] etc).
>> We fixed that on the side. ;)
>
> Yay!

Many thanks for your work fixing this, Leah and Hans.

The only remaining question is then when the new version will be be
released.

Many thanks again for your work,

Pablo

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

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


Re: [NTG-context] Spacing in \unit - degrees

2022-10-13 Thread Alan Braslau via ntg-context
On Wed, 12 Oct 2022 21:14:52 -0600
Gavin  wrote:

> As a recovering string theorist, I cannot help but speculate that
> this rule extends to spherical coordinates in any number of
> dimensions. However, if you don’t want the space, you can use
> 135\unit{℃}, which does not add a space.

Will 135\unit{℃} ever break between the digits 135 and the "unit"?
I agree that \unit should probably use an \mbox to prevent unwanted
breaks.

The other role of \unit, I understand, is to uniformize the
representation of numbers (digits).

> > Related,
> > \unit{90°} does not seem to introduce a space, as indeed it should
> > not.  

So ℃ needs to be registered as a degree and prevent any spacing.

> Also related, using \unit for just the units, and not the number, is
> useful when they follow something that is not a number, like a
> vector: $ \vec v = (4.0, -3.2, 1.5)\unit{m/s} $. You frequently do
> not want a space in that situation.

Why would one not want a (small) space before m/s in the above
example?

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

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


[NTG-context] \text{...} inside \sqrt is tiny

2022-10-13 Thread Gavin via ntg-context
Hi List,

When I use text inside a radical, the text is script-script size.

$\text{Radius} = \sqrt{\text{Area}/\pi}$

It should be normal size. Any ideas for a fix?

I stumbled on this issue when working with \units, but it is not specific to 
units.

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

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


Re: [NTG-context] Spacing in \unit - SOLVED

2022-10-13 Thread Gavin via ntg-context
Hi Oli,

> Thank four your effort. I found out, that the following definition of a new 
> unit, i called it SI, results also in a correct spaceing in the math 
> environment:
> 
> \defineunit[SI][alternative=text]
> 
> It seems, that the option alternative=text solves the problem with no spaces 
> between value and unit in the math environment.

That is a terrific solution that doesn’t require any messing with 
phys-dim.mkxl. You do not need to define a new unit. I got your result using 
this line:

\setupunits[alternative=text]

This fixed the most significant problems with \unit in most situations. I’m 
still applying some of my solutions as well.

Thanks!
Gavin

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

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


Re: [NTG-context] How to make something appear to the right of every paragraph?

2022-10-13 Thread Joel via ntg-context
 These both work great, but do that for the whole document? Is there a way to 
restrict it to only apply the lines to some parts of the file, not every single 
paragraph?
Thanks!
--Joel

On Monday, October 10, 2022 at 04:57:07 PM MDT, Max Chernoff 
 wrote:  
 
 Hi Joel,

On Mon, 2022-10-10 at 12:46 +, Joel wrote:
>  Hello Max,
> It is preferred if the solution is just three lines per paragraph,
> rather than some content parallel to the text

A Lua callback solution:

  \startluacode
      -- Constants
      RULE_OFFSET    = tex.sp "1em"
      RULE_THICKNESS = tex.sp "0.4pt"
      RULE_LENGTH    = tex.sp "3cm"
  
      -- Callback
      function userdata.lines(head)
          if status.output_active or
              tex.nest.ptr > 1
          then
              return head
          end
  
          local i = 0
          for n in node.traverseid(node.id "hlist", head) do
              i = i + 1
              if i > 3 then
                  break
              end
  
              local offset = node.new "glue"
              offset.width = RULE_OFFSET
              node.slide(n.list).next = offset
  
              local rule = node.new "rule"
              rule.width = RULE_LENGTH
              rule.height = RULE_THICKNESS
              rule.depth = 0
              offset.next = rule
          end
  
          return head
      end
  
      nodes.tasks.appendaction(
          "finalizers",
          "after",
          "userdata.lines"
      )
  \stopluacode
  
  \parskip=\baselineskip
  
  \starttext
      One line paragraph
  
      Two line paragraph \\
      Two line paragraph
  
      Three line paragraph \\
      Three line paragraph \\
      Three line paragraph
  
      Four line paragraph \\
      Four line paragraph \\
      Four line paragraph \\
      Four line paragraph
  
      \samplefile{bryson}
  
      \samplefile{knuth}
  \stoptext

An \everypar solution:

  \appendtoks%
      \vbox to 0pt{%
          \dorecurse{3}{%
              \rlap{%
                  \hskip\dimexpr\hsize+1em%
                  \vrule height 0.4pt width 3cm%
                  \relax%
              }%
          }%
      }%
  \to\everypar
  
  \parskip=\baselineskip
  
  \starttext
      One line paragraph
  
      Two line paragraph \\
      Two line paragraph
  
      Three line paragraph \\
      Three line paragraph \\
      Three line paragraph
  
      Four line paragraph \\
      Four line paragraph \\
      Four line paragraph \\
      Four line paragraph
  
      \samplefile{bryson}
  
      \samplefile{knuth}
  \stoptext

Neither of these solutions are great though. Both of these solutions are
pretty low-level, so there's presumably a more ConTeXt-y way of doing
this.

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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] How to make something appear to the right of every paragraph?

2022-10-13 Thread Joel via ntg-context
 When I use the code given, it compiles and displays fine. But when I try 
replacing \everypar with \EveryPar, it halts during compiling with this 
complaint:
"A number should have been here; I inserted '0'. (If you can't figure out why I
needed to see a number, look up 'weird error' in the index to The TeXbook.)
mtx-context | fatal error: return code: 1

"

On Monday, October 10, 2022 at 09:58:11 PM MDT, Wolfgang Schuster 
 wrote:  
 
 Max Chernoff via ntg-context schrieb am 11.10.2022 um 00:57:
> Hi Joel,
>
> On Mon, 2022-10-10 at 12:46 +, Joel wrote:
>>  Hello Max,
>> It is preferred if the solution is just three lines per paragraph,
>> rather than some content parallel to the text
> A Lua callback solution:
>
> [...]
>
> An \everypar solution:
>
>    \appendtoks%
>        \vbox to 0pt{%
>            \dorecurse{3}{%
>                \rlap{%
>                    \hskip\dimexpr\hsize+1em%
>                    \vrule height 0.4pt width 3cm%
>                    \relax%
>                }%
>            }%
>        }%
>    \to\everypar

You can use the \EveryPar register but \everypar is off limits.

Wolfgang

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

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


Re: [NTG-context] Spacing in \unit - SOLVED

2022-10-13 Thread Oliver Sieber via ntg-context
Hi Gavin

Thank four your effort. I found out, that the following definition of a new 
unit, i called it SI, results also in a correct spaceing in the math 
environment:

\defineunit[SI][alternative=text]

It seems, that the option alternative=text solves the problem with no spaces 
between value and unit in the math environment.

Maybe this can be used to solve it easier in the code. I will have a look at 
phys-dim to solve it directly, if I find the time.

Best regards
Oli

> Am 12.10.2022 um 23:54 schrieb Gavin via ntg-context - ntg-context at ntg.nl 
> :
> 
> Hi Max, Alan, Bruce, Hans, et.al
> 
> I solved my four issues with \unit spacing. In the process, I prevented 
> unwanted line breaks and removed an overzealous backspace before division 
> symbols. Below is a MWE that shows all of these issues, as well as pictures 
> of the result with the unmodified phys-dim.mkxl and with my modified 
> phys-dim.mkxl. The final result is exactly what I wanted.
> 
> If anyone wants my changes, either for their own use or to improve the 
> distributed phys-dim.mkxl, I’m happy to share.
> 
> Thanks for all of your comments!
> Gavin
> 
> 
> MWE:
> 
> \setuppapersize[A5]
> 
> \starttext
> 
> The \type{\unit} command in text produces \unit{1.23e5 kg m^2/s^2}.
> 
> Inline math \type{$\unit$} produces $\unit{1.23e5 kg m^2/s^2}$.
> 
> Display math produces
> \startformula
> \unit{1.23e5 kg m^2/s^2} + \unit{8.64e5 newton m} = \unit{987,000 joule}
> \stopformula
> 
> Line breaking in math:
> 
> {\hsize=0pt $G = \unit{6.6743e-11 m3 kg-1 s-2}$}
> 
> \blank
> Line breaking in text:
> 
> {\hsize=0pt \unit{6.6743e-11 m3 kg-1 s-2}}
> 
> \stoptext
> 
> Output with unmodified phys-dim.mkxl:
> 
> 
> Output with my modified phys-dim.mkxl:
> 
> 
> 
> 
>> On Oct 10, 2022, at 12:15 AM, Max Chernoff via ntg-context 
>>  wrote:
>> 
>> Hi Alan,
>> 
>>> I would very strongly argue that the space between the number and the
>>> following units be UNBREAKABLE. Perhaps a thin space (preference), but
>>> most certainly non-breakable.
>>> 
>>> Similarly around the times in scientific notation.
>>> 
>>> I further cannot imagine that a line break be acceptable around a \cdot
>>> in composite units.
>>> 
>>> This can possibly lead to overfill and underfill, something that I find
>>> *infinitely* more acceptable then breaking numbers and units.
>> 
>> Yes, I agree completely here.
>> 
>>> I do not know or use the \units command. Maybe it uses unbreakable
>>> spaces, maybe not. I would never use it unless it could be configured
>>> to only use nonbreakable spaces.
>> 
>> The current behaviour doesn't break the unit from the number, but it
>> does split the scientific notation.
>> 
>> This test file:
>> 
>>  \starttext
>>  \hsize=0pt Math: $G = \unit{6.6743e-11 m3 kg-1 s-2}$
>> 
>>  \hsize=0pt Text: \unit{6.6743e-11 m3 kg-1 s-2}
>>  \stoptext
>> 
>> gives:
>> 
>>  Math:
>>  퐺=
>>  6.6743×
>>  10–11m3⋅kg–1⋅s–2
>>  Text:
>>  6.6743
>>  ×
>>  10−11 m3⋅kg−1⋅s−2
>> 
>> which isn't great. In my opinion, the \unit command should be typeset in an
>> \hbox (or similar) since I can't think of any circumstances where breaking
>> it would be reasonable.
>> 
>> 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://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki : https://contextgarden.net
>> ___
> 
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl / 
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> ___



signature.asc
Description: Message signed with OpenPGP
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] atan2 function

2022-10-13 Thread Max Chernoff via ntg-context
Hi,

> How is atan2 called? I rolled my own as follows:

> Is atan with two parameters supposed to behave like atan2?

At mp-math.mpxl:167 there is:

   vardef atan   primary x = angle(1,x)   enddef ;
   
The MetaPost manual says:

   The angle operator takes a pair and computes the two-argument
   arctangent; i.e., angle is the inverse of the dir operator
   
So it looks like "angle" is the function that you want for "atan2". 

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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___