ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Fwd: Continued fractions in ConTeXt
       [not found] <CAKyqqaY8rVabkw4NmsVnP27UJo9AQX5L+iLoAjX=8eyN=hQ6cg@mail.gmail.com>
@ 2020-06-28 16:06 ` Jairo A. del Rio
  2020-06-29 14:51   ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Jairo A. del Rio @ 2020-06-28 16:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1577 bytes --]

Hi list! I've tried adapting the following code for continued fractions:

%https://tex.stackexchange.com/questions/73195/how-to-typeset-a-continued-fraction-in-the-following-format
\documentclass{article}\usepackage{amsmath}
\begin{document}\newcommand*{\cofrac}[2]{%
  {%
    \rlap{$\dfrac{1}{\phantom{#1}}$}%
    \genfrac{}{}{0pt}{0}{}{#1+#2}%
  }%}\[
  a_0 +
  \cofrac{a_1}{
    \cofrac{a_2}{
      \cofrac{a_3}{
        \genfrac{}{}{0pt}{0}{}{\ddots}
  }}}\]\end{document}

As I could read from the mailing list, ConTeXt no longer supports
\genfrac, so I've tried

the following using \definemathfraction

\definemathfraction[gefrac][cfrac]
\setupmathfraction[gefrac][rule=no]
\def\cofrac#1#2{%
  {%
    \rlap{\cfrac{1}{\displaystyle\phantom{#1}}}%
    \gefrac{}{\displaystyle\gefrac{#1+}{}#2}%
  }%
}
\def\cofracnorule#1#2{%
	{%
		\rlap{\gefrac{\displaystyle\phantom{1}}{\displaystyle\phantom{#1}}}%
		\gefrac{}{\displaystyle\gefrac{#1}{}#2}%
	}%
}
\def\endfrac#1{\cofracnorule{#1}{\phantom{1}}}
\startTEXpage
\startplacefigure[location=force,number=no]
\externalfigure[cofrac.png]
\stopplacefigure
\startformula
\alpha +
\cofrac{\alpha'}{\cofrac{\alpha''}{\cofrac{\alpha'''}{{\endfrac{\ddots}}}}}
\frac{1}{\alpha'''}
\stopformula
\stopTEXpage

Mmm, superscripts and fraction rules superpose, so indeed something is
wrong. Any ideas or references to a better result?

I've attached the expected result (it's from Legendre's Théorie des
nombres) and a normal fraction for comparison.

Thank you very much.

Jairo :)

[-- Attachment #1.2: Type: text/html, Size: 3881 bytes --]

[-- Attachment #2: cofrac.png --]
[-- Type: image/png, Size: 12895 bytes --]

[-- Attachment #3: fraccioncontinualegendre.pdf --]
[-- Type: application/pdf, Size: 17836 bytes --]

[-- Attachment #4: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: Continued fractions in ConTeXt
  2020-06-28 16:06 ` Fwd: Continued fractions in ConTeXt Jairo A. del Rio
@ 2020-06-29 14:51   ` Hans Hagen
  2020-06-30  0:27     ` Jairo A. del Rio
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2020-06-29 14:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Jairo A. del Rio

On 6/28/2020 6:06 PM, Jairo A. del Rio wrote:
> |Hi list! I've tried adapting the following code for continued fractions:|
> ||
> 
> |%https://tex.stackexchange.com/questions/73195/how-to-typeset-a-continued-fraction-in-the-following-format
> \documentclass{article}\usepackage{amsmath}\begin{document}\newcommand*{\cofrac}[2]{%{%\rlap{$\dfrac{1}{\phantom{#1}}$}%\genfrac{}{}{0pt}{0}{}{#1+#2}%}%}\[a_0 
> + 
> \cofrac{a_1}{\cofrac{a_2}{\cofrac{a_3}{\genfrac{}{}{0pt}{0}{}{\ddots}}}}\]\end{document}
> 
> |
> 
> |As I could read from the mailing list, ConTeXt no longer supports 
> \genfrac, so I've tried
> |
> 
> |the following using \definemathfraction
> 
> \definemathfraction[gefrac][cfrac]
> \setupmathfraction[gefrac][rule=no]
> \def\cofrac#1#2{%
>    {%
>      \rlap{\cfrac{1}{\displaystyle\phantom{#1}}}%
>      \gefrac{}{\displaystyle\gefrac{#1+}{}#2}%
>    }%
> }
> \def\cofracnorule#1#2{%
> {%
> \rlap{\gefrac{\displaystyle\phantom{1}}{\displaystyle\phantom{#1}}}%
> \gefrac{}{\displaystyle\gefrac{#1}{}#2}%
> }%
> }
> \def\endfrac#1{\cofracnorule{#1}{\phantom{1}}}
> \startTEXpage
> \startplacefigure[location=force,number=no]
> \externalfigure[cofrac.png]
> \stopplacefigure
> \startformula
> \alpha +
> \cofrac{\alpha'}{\cofrac{\alpha''}{\cofrac{\alpha'''}{{\endfrac{\ddots}}}}} 
> \frac{1}{\alpha'''}
> \stopformula
> \stopTEXpage
> 
> |
> 
> |Mmm, superscripts and fraction rules superpose, so indeed something is 
> wrong. Any ideas or references to a better result?
> |
In the next version this will look okay:

\definemathfraction
   [gefrac]
   [d:frac]

\setupmathfraction
   [gefrac]
   [mathstyle=display,
    alternative=inner,
    rule=hidden]

\unexpanded\def\cofrac#1#2{%
     \rlap{\cfrac{1}{\phantom{#1}}}%
     \gefrac{}{\gefrac{#1+}{}#2}%
}

\unexpanded\def\endfrac#1{%
     \rlap{\phantom{\cfrac{1}{#1}}}%
     \gefrac{}{#1}%
}

\starttext

\startTEXpage
\startformula \showmakeup[kern]
         \alpha
         +
         \cofrac {\alpha'}
             {\cofrac {\alpha''}
                 {\cofrac {\alpha'''}
                     {\endfrac {\ddots}}}}
         +
         \frac{1}{\alpha'''}
     \stopformula
\stopTEXpage

\stoptext


-----------------------------------------------------------------
                                           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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: Continued fractions in ConTeXt
  2020-06-29 14:51   ` Hans Hagen
@ 2020-06-30  0:27     ` Jairo A. del Rio
  2020-06-30 15:56       ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Jairo A. del Rio @ 2020-06-30  0:27 UTC (permalink / raw)
  To: Hans Hagen, mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 3258 bytes --]

I've just tested it and it looks w a y better than before (thanks!). Btw,
where could I read about key-value pairs for ConTeXt fractions
(\definemathfraction)? I've seen keys like "threshold" and other weird ones
in the command list, so I ask about a reference (maybe somewhere in a
manual; the Garden doesn't say a lot about it). Thank you very much.

Sincerely,

Jairo :)

El lun., 29 de jun. de 2020 a la(s) 09:51, Hans Hagen (j.hagen@xs4all.nl)
escribió:

> On 6/28/2020 6:06 PM, Jairo A. del Rio wrote:
> > |Hi list! I've tried adapting the following code for continued
> fractions:|
> > ||
> >
> > |%
> https://tex.stackexchange.com/questions/73195/how-to-typeset-a-continued-fraction-in-the-following-format
> >
> \documentclass{article}\usepackage{amsmath}\begin{document}\newcommand*{\cofrac}[2]{%{%\rlap{$\dfrac{1}{\phantom{#1}}$}%\genfrac{}{}{0pt}{0}{}{#1+#2}%}%}\[a_0
>
> > +
> >
> \cofrac{a_1}{\cofrac{a_2}{\cofrac{a_3}{\genfrac{}{}{0pt}{0}{}{\ddots}}}}\]\end{document}
> >
> > |
> >
> > |As I could read from the mailing list, ConTeXt no longer supports
> > \genfrac, so I've tried
> > |
> >
> > |the following using \definemathfraction
> >
> > \definemathfraction[gefrac][cfrac]
> > \setupmathfraction[gefrac][rule=no]
> > \def\cofrac#1#2{%
> >    {%
> >      \rlap{\cfrac{1}{\displaystyle\phantom{#1}}}%
> >      \gefrac{}{\displaystyle\gefrac{#1+}{}#2}%
> >    }%
> > }
> > \def\cofracnorule#1#2{%
> > {%
> > \rlap{\gefrac{\displaystyle\phantom{1}}{\displaystyle\phantom{#1}}}%
> > \gefrac{}{\displaystyle\gefrac{#1}{}#2}%
> > }%
> > }
> > \def\endfrac#1{\cofracnorule{#1}{\phantom{1}}}
> > \startTEXpage
> > \startplacefigure[location=force,number=no]
> > \externalfigure[cofrac.png]
> > \stopplacefigure
> > \startformula
> > \alpha +
> >
> \cofrac{\alpha'}{\cofrac{\alpha''}{\cofrac{\alpha'''}{{\endfrac{\ddots}}}}}
> > \frac{1}{\alpha'''}
> > \stopformula
> > \stopTEXpage
> >
> > |
> >
> > |Mmm, superscripts and fraction rules superpose, so indeed something is
> > wrong. Any ideas or references to a better result?
> > |
> In the next version this will look okay:
>
> \definemathfraction
>    [gefrac]
>    [d:frac]
>
> \setupmathfraction
>    [gefrac]
>    [mathstyle=display,
>     alternative=inner,
>     rule=hidden]
>
> \unexpanded\def\cofrac#1#2{%
>      \rlap{\cfrac{1}{\phantom{#1}}}%
>      \gefrac{}{\gefrac{#1+}{}#2}%
> }
>
> \unexpanded\def\endfrac#1{%
>      \rlap{\phantom{\cfrac{1}{#1}}}%
>      \gefrac{}{#1}%
> }
>
> \starttext
>
> \startTEXpage
> \startformula \showmakeup[kern]
>          \alpha
>          +
>          \cofrac {\alpha'}
>              {\cofrac {\alpha''}
>                  {\cofrac {\alpha'''}
>                      {\endfrac {\ddots}}}}
>          +
>          \frac{1}{\alpha'''}
>      \stopformula
> \stopTEXpage
>
> \stoptext
>
>
> -----------------------------------------------------------------
>                                            Hans Hagen | PRAGMA ADE
>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>         tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
>

[-- Attachment #1.2: Type: text/html, Size: 4402 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: Continued fractions in ConTeXt
  2020-06-30  0:27     ` Jairo A. del Rio
@ 2020-06-30 15:56       ` Hans Hagen
  2020-06-30 16:22         ` Jairo A. del Rio
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2020-06-30 15:56 UTC (permalink / raw)
  To: Jairo A. del Rio, mailing list for ConTeXt users

On 6/30/2020 2:27 AM, Jairo A. del Rio wrote:
> I've just tested it and it looks w a y better than before (thanks!). 
> Btw, where could I read about key-value pairs for ConTeXt fractions 
> (\definemathfraction)? I've seen keys like "threshold" and other weird 
> ones in the command list, so I ask about a reference (maybe somewhere in 
> a manual; the Garden doesn't say a lot about it). Thank you very much.
There is a manual about math but it's not complete (of course, otherwise 
there's nothing to complain and we have to protect our reputation of not 
having manuals). But ... contributions (examples etc, as I can blabla 
the rest) are welcome.

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fwd: Continued fractions in ConTeXt
  2020-06-30 15:56       ` Hans Hagen
@ 2020-06-30 16:22         ` Jairo A. del Rio
  0 siblings, 0 replies; 5+ messages in thread
From: Jairo A. del Rio @ 2020-06-30 16:22 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 582 bytes --]

> There is a manual about math but it's not complete
>

If you mean math-mkiv, it doesn't shed lights about fractions. I'm seeing
it's more illustrating about subjects as integrals and other stuff, tho.
Reading the mailing list, I realized there's a simplecommand key for
matrices, among other nice things which maybe should be... if not
documented, at least mentioned.


> we have to protect our reputation of not
> having manuals


lmao

But ... contributions (examples etc, as I can blabla
> the rest) are welcome.
>

I'll take note of that. Thank you very much, Hans.

Jairo :)

[-- Attachment #1.2: Type: text/html, Size: 1258 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-30 16:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAKyqqaY8rVabkw4NmsVnP27UJo9AQX5L+iLoAjX=8eyN=hQ6cg@mail.gmail.com>
2020-06-28 16:06 ` Fwd: Continued fractions in ConTeXt Jairo A. del Rio
2020-06-29 14:51   ` Hans Hagen
2020-06-30  0:27     ` Jairo A. del Rio
2020-06-30 15:56       ` Hans Hagen
2020-06-30 16:22         ` Jairo A. del Rio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).