Re: Pringsheim Notation for continued fractions

Matthias Weber <[email protected]> Mon, 15 Jun 2026 07:14:56 -0400
Newsgroups gmane.comp.tex.context
Message-ID <[email protected]>
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] <mailto:[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] <mailto:[email protected]> / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
>> webpage  : https://www.pragma-ade.nl <https://www.pragma-ade.nl/> / https://context.aanhet.net <https://context.aanhet.net/> (mirror)
>> archive  : https://github.com/contextgarden/context
>> wiki     : https://wiki.contextgarden.net <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
___________________________________________________________________________________