Open main menu

Changes

= Fractions =
{{cmd|frac}} switches typeset fraction, according to the math current style while others .Others commands enforce a certain style :* {{cmd|tfrac}} for textstyle, text style* {{cmd|dfrac}} for display style), * {{cmd|xfrac}} for script style.* {{cmd|sfrac}} and {{cmd|xxfrac}} for script of script style.* {{cmd|cfrac}} for continued style* {{cmd|vfrac}} for semi-horizontal style* {{cmd|hfrac}} for horizontal style 
<context source="yes">
\starttabulate[|l|rl|l|]\HL\NC {\bf Size or style} \NC {\bf Code} \NC {\bf Typesetting} \NC\NR\HL\NC math style \NC \textype{\frac{1}{3}} \NC \m{\frac{1}{3}} \NC\NR\NC math style display \NC \textype{\xfracdfrac{1}{3}} \NC \m{\xfracdfrac{1}{3}} \NC\NR\NC script \NC \textype{\xxfracxfrac{1}{3}} \NC \m{\xxfracxfrac{1}{3}} \NC\NR\NC scriptscript \NC \textype{\tfracsfrac{1}{3}} \NC \m{\tfracsfrac{1}{3}} \NC\NR\NC scriptscript \NC \textype{\sfracxxfrac{1}{3}} \NC \m{\sfracxxfrac{1}{3}}\NC\NR\NC semi-horizontal \NC \textype{\dfracvfrac{1}{3}} \NC \m{\dfracvfrac{1}{3}} \NC\NR\NC horizontal \NC \textype{\cfrachfrac{1}{3}} \NC \m{\cfrachfrac{1}{3}} \NC\NR\NC continued \NC \textype{\vfraccfrac{1}{3}} \NC \m{\vfraccfrac{1}{3}} \NC\NR\NC text \NC \textype{\hfractfrac{1}{3}} \NC \m{\hfractfrac{1}{3}} \NC\NR
\stoptabulate
 
</context>
 
== Different behaviors for inline and display mode ==
<context source="yes">
\startbuffer[frac]
\frac{1}{2} + \dfrac{1}{2} - \sfrac{1}{2} - \xfrac{1}{2} - \xxfrac{1}{2} + \vfrac{1}{2} + \hfrac{1}{2} + \tfrac{1}{2}
\stopbuffer
\framed[frame=off,align=normal]{% <=== just to improve wiki rendering
Each time, we display consecutivelythe different style: math style, display style, script style, and text style.
With \tex{startformula} (display mode)
\stopformula
With \tex{m} (inline mode): \m{\getbuffer[frac]}}</context>  == Fractions of fractions == <context source="yes">\startbuffer[frac]\frac{1}{2} + \dfrac{1}{2} - \sfrac{1}{2} - \xfrac{1}{2} - \xxfrac{1}{2} + \vfrac{1}{2} + \hfrac{1}{2} + \tfrac{1}{2}\stopbuffer \framed[frame=off,align=normal]{% <=== just to improve wiki renderingNow fraction of fractions:
With \tex{startformula} (display mode)
\stopformula
 With \tex{m} (inline mode)and \tex{frac}:
\m{\frac
{\getbuffer[frac]}
{\getbuffer[frac]}}
With \tex{m} (inline mode) and \tex{cfrac} (continued):\m{\cfrac {\getbuffer[frac]} {\getbuffer[frac]}}}</context> == Formatting with {{cmd|definemathfraction}} == Just an example from [https://www.mail-archive.com/ntg-context@ntg.nl/msg69987.html mailing list] <context source="yes">\startformula \frac {a} { \frac{b}{c} } \stopformula \definemathfraction [wfrac] [margin=.25em] \startformula \wfrac {a} { \frac{b}{c} } \stopformula</context> Just an second example from [https://www.mail-archive.com/ntg-context@ntg.nl/msg68782.html mailing list] <context source="yes">\definemathfraction [myfrac] [mathstyle=script]\definemathfraction [myfracx][mathstyle=script,alternative=outer] \framed[frame=off,align=normal]{% <=== just to improve wiki rendering${a^{2^{2^2}}\over a}$$\frac{a^{2^{2^2}}}{a}$$\frac{a^{2}}{b}$$\myfrac{a^{2}}{b}$$\myfracx{a^{2}}{b}$}</context>
= Binomial coefficients =
{{cmd|setupmathfractions}}.
The default look of the binomial coefficients look good in several fonts, but for example not perfect in Latin Modern. You can play with {{cmd|setupmathfractions}}, and in particular, you can try
<texcode>\setupmathfractions[Below we show some of the often used fonts, together with the default setting and the one just suggested. The default look of the binomial][fences=parenthesiscoefficients look good in several fonts,%threshold=1but for example not perfect in Latin Modern. You may want to play with {{cmd|definemathfraction}}.5,]</texcode>
Below we show some of the often used fonts, together with the default setting and the one just suggested. You can also play with the
threshold key.
<texcodecontext source="yes">
\setuphead[chapter][align=middle]
\setuphead[section][style=\bfa]
\setuphead[subsection][style=\it]
 
\setuplayout[
\getbuffer
%\switchtobodyfont[lucidaot]%\subsubject{Lucida}%\getbuffer
\column[yes]
\setupmathfractionsdefinemathfraction[binomial] [binom] [fences=parenthesis,rule=no]\definemathfraction[tbinomial][binomial] [mathstyle=text]\definemathfraction[dbinomial] [binomial] [mathstyle=display] \startbuffer\type{\binomial{n}{k}}: $\binomial{n}{k}$\par\type{\tbinomial{n}{k}}: $\tbinomial{n}{k}$\par\type{\dbinomial{n}{k}}: $\dbinomial{n}{k}$\par\stopbuffer
\switchtobodyfont[modern]
\subject{With fences=parenthesis\tex{definemathfraction}}
\subsubject{Latin Modern}
\getbuffer
\getbuffer
%\switchtobodyfont[lucidaot]%\subsubject{Lucida}%\getbuffer
\stopcolumns
\stoptext
 </texcodecontext>
The result of the code above, with the standalone from 2017-09-05 is given below.
[[File:binomialcoefficients.png|700px]]
 
[[Category:Math]]
1,047

edits