>
> Hi,
>
> I find myself writing a lot of probability expressions where I want
> the delimiters to scale automatically, and | (conditional sign) to
> scale automatically, and the spacing around | to be correct. In LaTeX,
> I used to use braket package to do this. Since moving to ConTeXt, I
> was doing this by hand, but wring a lot of
>
> \EXP\left\{ ... \,\middle\, ...\right\} and \Pr( ... \mid ...)
>
> soon became a pain to read and write. So (thanks to Taco's first hand
> knowledge of why TeX is Turing complete), I have written the following
> macros:
>
> \unprotect
> \definesystemvariable {ms}   % Math Set
>
> \def\mathsetmiddle{\,\middle\mathsetparameter\c!middle\,}
>
> \let\currentmathset\empty
> \def\mathsetparameter#1%
>
> {\executeifdefined{\??ms\currentmathset#1}{\executeifdefined{\??ms#1}\empty}}
>
> \def\definemathset
>    {\dodoubleargument\dodefinemathset}
>
> \def\dodefinemathset[#1][#2]%
>    {\getparameters[\??ms#1]
>      [\c!text=,\c!left={\{},\c!right={\}},\c!middle=\vert,#2]
>     \setvalue{#1}{\dododefinemathset[#1]}}
>
> \def\dododefinemathset[#1]#2#%
>    {\begingroup
>     \def\currentmathset{#1}
>     \mathcode`\|32768
>     \let|\mathsetmiddle
>     \def\mathsetarguments{#2}
>     \dodododefinemathset}
>
> \def\dodododefinemathset#1%
>    {\doifsomething{\mathsetparameter\c!text}
>      {\mathop{\mathsetparameter\c!text\mathsetarguments}}
>     \left\mathsetparameter\c!left#1\right\mathsetparameter\c!right
>     \endgroup}
>
> \protect
>
> which allows me to do
>
> \definemathset[EXP][text={\mfunction{E}}]
> \definemathset[PR][text={\mfunction{Pr}},left=(,right=)]
>
> \starttext
>
> Correct spacing around the vertical bar.
> \startformula
>    \EXP{f(X) | Y} = \sum_{x} f(x) \PR{x|Y}
> \stopformula
>
> Correct scaling of delimiters (as correct as left and right give you)
>
> \startformula
>    \EXP{\sum_z f(X,z) | Y} = \sum_{x,z} f(x,z) \PR{x,z|Y}
> \stopformula
>
> Correct handling of sub|/|super scripts
>
> \startformula
>    \EXP_X{f(X) | Y} = \sum_{x} f(x) \PR{x|Y}
> \stopformula
>
>
> Is there anyone else interested in this kind of stuff? I have not
> ported all the features of braket.sty, but only those that I needed.
> Other should not be too difficult to port.
>
> Hans and Taco: Does it make sense to add these to the core? If so, I
> can polish the macros a bit (add a \setupmathsets command).
>
> Aditya
>

I think I will need it near in the future. Thanks for nice the nice works.

Zulkifli



_______________________________________________
ntg-context mailing list
[email protected]
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to