Re: Pringsheim Notation for continued fractions
Florent Michel <[email protected]> Mon, 15 Jun 2026 12:35:47 +0100
| Newsgroups | gmane.comp.tex.context |
|---|---|
| Message-ID | <CALOhoeLZk-1m2ejy59dy67qC_1PYTOcn93h-H6+piKMJg0z2UQ@mail.gmail.com> |
No worries!
> The vertical bars look good, but the numerators and denominators are
placed flush left instead of centered, which looks odd in cases like
\cFrac{99999}{1}.
Good point! Maybe this is better (although still hack-y)?
\define[2]\cFrac{%
\vcenter{
\newdimen\WidthOfFirst
\newdimen\WidthOfSecond
\newdimen\TrueWidth
\WidthOfFirst=\widthofstring{\strut$#1$\,}
\WidthOfSecond=\widthofstring{\strut\vrule\,$#2$}
\startluacode
trueWidth = math.max(tex.dimen.WidthOfFirst, tex.dimen.WidthOfSecond)
context("\\TrueWidth=" .. trueWidth .. "sp")
\stopluacode
\hbox{\framed[frame=off,width=\TrueWidth,offset=overlay]{\strut$#1$\,}\vrule}%
\hrule%
\hbox{\strut\vrule\framed[frame=off,width=\TrueWidth,offset=overlay]{\,$#2$}}}%
}
\starttext
First test:
\startformula
\startalign
\NC a_0+a_0a_1+a_0 a_1 a_2+a_0 a_1 a_2 a_3 \NC =
\cfrac{a_0}{1-\cfrac{a_1}{1+a_1-\cfrac{a_2}{1+a_2-\cfrac{a_2}{1+a_2-\cfrac{a_3}{1+a_3-\cdots}}}}}\NR
\NC \NC =
\cFrac{a_0}{1}-\cFrac{a_1}{1+a_1}-\cFrac{a_2}{1+a_2}-\cFrac{a_3}{1+a_3}-\cdots\NR
\stopalign
\stopformula
Second test:
\startformula
\cFrac{99999}{1} = 99999
\stopformula
\stoptext
Cheers,
Florent
Le lun. 15 juin 2026 à 12:19, Matthias Weber <[email protected]> a
écrit :
> Thanks, Florent,
>
> The vertical bars look good, but the numerators and denominators are
> placed flush left instead of centered, which looks odd in cases like
> \cFrac{99999}{1}.
>
> Matthias
>
> On Jun 14, 2026, at 1:13 PM, Florent Michel <[email protected]> wrote:
>
> Hi,
>
> This is a bit of a hack (and I'm sure there are better solutions), but
> maybe something like the following?
>
> \define[2]\cFrac{%
> \vcenter{
> \newdimen\WidthOfFirst
> \newdimen\WidthOfSecond
> \newdimen\TrueWidth
> \WidthOfFirst=\widthofstring{\strut$#1$\,}
> \WidthOfSecond=\widthofstring{\strut\vrule\,$#2$}
> \startluacode
> trueWidth = math.max(tex.dimen.WidthOfFirst, tex.dimen.WidthOfSecond)
> context("\\TrueWidth=" .. trueWidth .. "sp")
> \stopluacode
>
> \hbox{\offset[width=\TrueWidth]{\strut$#1$\,}\vrule}\hrule\hbox{\strut\vrule\,$#2$}}%
> }
>
> \starttext
> \startformula
> \startalign
> \NC a_0+a_0a_1+a_0 a_1 a_2+a_0 a_1 a_2 a_3 \NC =
> \cfrac{a_0}{1-\cfrac{a_1}{1+a_1-\cfrac{a_2}{1+a_2-\cfrac{a_2}{1+a_2-\cfrac{a_3}{1+a_3-\cdots}}}}}\NR
> %\NC \NC =
> \frac{a_0|}{|1}-\frac{a_1|}{|1+a_1}-\frac{a_2|}{|1+a_2}-\frac{a_3|}{|1+a_3}-\cdots\NR
> \NC \NC =
> \cFrac{a_0}{1}-\cFrac{a_1}{1+a_1}-\cFrac{a_2}{1+a_2}-\cFrac{a_3}{1+a_3}-\cdots\NR
> \stopalign
>
> \stopformula
> \stoptext
>
> Cheers,
> Florent
>
> Le dim. 14 juin 2026 à 17:26, Matthias Weber <[email protected]>
> a écrit :
>
>> Dear All,
>>
>>
>> I would like to typeset continued fractions as attempted and failed in
>> the second line of the following MWE:
>>
>> \def\cFrac#1#2{%
>> \vcenter{\hbox{\strut$#1$\,\vrule}\hrule\hbox{\strut\vrule\,$#2$}}}
>>
>> \starttext
>> \startformula
>> \startalign
>> \NC a_0+a_0a_1+a_0 a_1 a_2+a_0 a_1 a_2 a_3 \NC =
>> \cfrac{a_0}{1-\cfrac{a_1}{1+a_1-\cfrac{a_2}{1+a_2-\cfrac{a_2}{1+a_2-\cfrac{a_3}{1+a_3-\cdots}}}}}\NR
>> %\NC \NC =
>> \frac{a_0|}{|1}-\frac{a_1|}{|1+a_1}-\frac{a_2|}{|1+a_2}-\frac{a_3|}{|1+a_3}-\cdots\NR
>> \NC \NC =
>> \cFrac{a_0}{1}-\cFrac{a_1}{1+a_1}-\cFrac{a_2}{1+a_2}-\cFrac{a_3}{1+a_3}-\cdots\NR
>> \stopalign
>>
>> \stopformula
>> \stoptext
>>
>>
>> The macro is from
>>
>>
>> https://tex.stackexchange.com/questions/68190/how-do-i-typeset-continued-fractions-in-pringsheims-concise-notation
>>
>> where this question is discussed for LaTeX.
>>
>> Unfortunately, the vertical bars on the top of the fractions do not align
>> with the right end of the fraction bar.
>>
>>
>> Any suggestions?
>>
>> Thanks,
>>
>> Matthias
>>
>>
>>
>>
>>
>> ___________________________________________________________________________________
>> If your question is of interest to others as well, please add an entry to
>> the Wiki!
>>
>> maillist : [email protected] /
>> 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
>>
>> ___________________________________________________________________________________
>>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : [email protected] /
> 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
>
> ___________________________________________________________________________________
>
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : [email protected] /
> 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
>
> ___________________________________________________________________________________
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : [email protected] / 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
___________________________________________________________________________________