Re: Pringsheim Notation for continued fractions

Florent Michel <[email protected]> Sun, 14 Jun 2026 18:13:27 +0100
Newsgroups gmane.comp.tex.context
Message-ID <CALOhoeLd=qF+b+VMGfYM23PB8NVow97qpsr3W7axs8aMYjsyCA@mail.gmail.com>
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
___________________________________________________________________________________