Fwd: Continued fractions in ConTeXt
Hi list! I've tried adapting the following code for continued fractions: %https://tex.stackexchange.com/questions/73195/how-to-typeset-a-continued-fra... \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 :)
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-fra... \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 -----------------------------------------------------------------
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-fra...
\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 -----------------------------------------------------------------
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
On 6/30/2020 2:27 AM, Jairo A. del Rio wrote: 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 -----------------------------------------------------------------
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 :)
participants (2)
-
Hans Hagen
-
Jairo A. del Rio