Re: Pringsheim Notation for continued fractions

Bruce Horrocks <[email protected]> Mon, 15 Jun 2026 12:54:53 +0100
Newsgroups gmane.comp.tex.context
Message-ID <[email protected]>

> On 14 Jun 2026, at 17:18, Matthias Weber <[email protected]> wrote:
> 
> 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?

It can be hacked using a mathmatrix and the (under-documented) \GL command. It puts quite a lot of horizontal space in though because of the need to use empty \NC columns and I don't know a way to force them to be narrower, so maybe Florent's solution is better for you?

\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


Alternate:

\starttexdefinition PCN #1 #2
  \startmathmatrix
    \NC \GL[1][d]             \NC #1 \NC \GL[1][d,c]\GL[2][d]\GL[2][t,c]  \NC\NR
    \NC \GL[3][t]\GL[3][d,c]  \NC #2 \NC                                  \NC\NR
  \stopmathmatrix
\stoptexdefinition


\startformula
a = \PCN{a_0}{1} - \PCN{a_1}{1+a_1} - \PCN{a_2}{1+a_2} - \PCN{a_3}{1+a_3} - \cdots
\stopformula
\stoptext


Regards,
—
Bruce Horrocks
Hampshire, UK

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