Hi Hans and Taco, Do you think it makes sense to replace {\rm mod} in the definition of bmod and pmod (in math-pln.tex) by \mfunction{mod}? Aditya
On Fri, 2 Feb 2007, Aditya Mahajan wrote:
Hi Hans and Taco,
Do you think it makes sense to replace {\rm mod} in the definition of bmod and pmod (in math-pln.tex) by \mfunction{mod}?
Another request: I am thinking of updating the nath module, and I notice that nath.sty goes into considerable length to make math commands "robust" (whatever that means). Basically \def\makerobust#1{% \expandafter\let\csname @o@\expandafter\gobbleoneargument\string #1\endcsname=#1 \unexpanded\def#1{\csname @o@\expandafter\gobbleoneargument\string #1\endcsname}} % Making composed math symbols robust: \makerobust\cong \makerobust\notin If I understand correctly, this can be achieved by replace \def\cong to \undexpanded\def\cong in math-pln. I do not understand expansion very well, but is there a disadvantage of not defining math characters to be unexpandable to begin with? Aditya
On Fri, 2 Feb 2007, Aditya Mahajan wrote:
On Fri, 2 Feb 2007, Aditya Mahajan wrote:
Hi Hans and Taco,
Do you think it makes sense to replace {\rm mod} in the definition of bmod and pmod (in math-pln.tex) by \mfunction{mod}?
Another request: I am thinking of updating the nath module, and I
Another one: Nath defines \stackrel and \underset. I think that these should go to the core \def\stackrel#1#2{\mathrel{\mathop{#2}\limits^{#1}}} See the note below: \def\overset#1#2{\mathrel{\mathop{#2}\limits^{#1}}} \def\underset#1#2{\mathrel{\mathop{#2}\limits_{#1}}} amsmath.sty goes into a lot of pains to define overset and underset, basically to decide whether to use mathrel or mathbin in the above. Do we need such an elaborate definition? This is amsmath's definition: \def\binrel@#1{\begingroup \setboxz@h{\thinmuskip0mu \medmuskip\m@ne mu\thickmuskip\@ne mu \setbox\tw@\hbox{$#1\m@th$}\kern-\wd\tw@ ${}#1{}\m@th$}% \edef\@tempa{\endgroup\let\noexpand\binrel@@ \ifdim\wdz@<\z@ \mathbin \else\ifdim\wdz@>\z@ \mathrel \else \relax\fi\fi}% \@tempa } \newcommand{\overset}[2]{\binrel@{#2}% \binrel@@{\mathop{\kern\z@#2}\limits^{#1}}} \newcommand{\underset}[2]{\binrel@{#2}% \binrel@@{\mathop{\kern\z@#2}\limits_{#1}}} Aditya
Aditya Mahajan wrote:
Another one: Nath defines \stackrel and \underset. I think that these should go to the core
\def\stackrel#1#2{\mathrel{\mathop{#2}\limits^{#1}}}
See the note below:
\def\overset#1#2{\mathrel{\mathop{#2}\limits^{#1}}} \def\underset#1#2{\mathrel{\mathop{#2}\limits_{#1}}}
amsmath.sty goes into a lot of pains to define overset and underset, basically to decide whether to use mathrel or mathbin in the above. Do we need such an elaborate definition? This is amsmath's definition:
Yes, I believe that is wise. Spacing around ords and bins and rels is different, and \overset and \underset should not influence that spacing. The \binrel@ macro is ugly, but the most efficient and robust way of testing this is through trial typesetting. \binrel@ changes the definition of \binrel@@ to be one of \mathbin, \mathrel, or \relax, as needed. So, better to put the ams definition in the core. Assuming I didn't make any typos, it should look like this: \def\binrel@#1% {\begingroup \setbox0=\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox2=\hbox{$#1\mathsurround0pt$}% \kern -wd2 ${}#1{}\mathsurround0pt$}% \edef\@tempa {\endgroup \let\noexpand\binrel@@ \ifdim\wd0<0pt \mathbin \else \ifdim\wd0>\z@ \mathrel \else \relax \fi\fi }% \@tempa } Best, taco
\def\binrel@#1{\begingroup \setboxz@h{\thinmuskip0mu \medmuskip\m@ne mu\thickmuskip\@ne mu \setbox\tw@\hbox{$#1\m@th$}\kern-\wd\tw@ ${}#1{}\m@th$}% \edef\@tempa{\endgroup\let\noexpand\binrel@@ \ifdim\wdz@<\z@ \mathbin \else\ifdim\wdz@>\z@ \mathrel \else \relax\fi\fi}% \@tempa }
\newcommand{\overset}[2]{\binrel@{#2}% \binrel@@{\mathop{\kern\z@#2}\limits^{#1}}} \newcommand{\underset}[2]{\binrel@{#2}% \binrel@@{\mathop{\kern\z@#2}\limits_{#1}}}
Aditya
_______________________________________________ dev-context mailing list dev-context@ntg.nl http://www.ntg.nl/mailman/listinfo/dev-context
It is cleaner when renamed a little: Taco Hoekwater wrote:
\def\binrel@#1%
\def\preparebinrel#1%
{\begingroup \setbox0=\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox2=\hbox{$#1\mathsurround0pt$}% \kern -wd2 ${}#1{}\mathsurround0pt$}% \edef\@tempa {\endgroup \let\noexpand\binrel@@ \let\noexpand\currentbinrel \ifdim\wd0<0pt \mathbin \else \ifdim\wd0>\z@ \mathrel \else \relax \fi\fi }% \@tempa }
And: \unexpanded\def\overset#1#2% {\preparebinrel{#2}% \currentbinrel{\mathop{\kern\z@#2}\limits^{#1}}} Best, Taco
On Sat, 3 Feb 2007, Taco Hoekwater wrote:
It is cleaner when renamed a little:
So the following macros can go into the core
\def\binrel@#1% \def\preparebinrel#1% {\begingroup \setbox0=\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox2=\hbox{$#1\mathsurround0pt$}% \kern -wd2 ${}#1{}\mathsurround0pt$}% \edef\@tempa {\endgroup \let\noexpand\binrel@@ \let\noexpand\currentbinrel \ifdim\wd0<0pt \mathbin \else \ifdim\wd0>\z@ \mathrel \else \relax \fi\fi }% \@tempa }
And:
\unexpanded\def\overset#1#2% {\preparebinrel{#2}% \currentbinrel{\mathop{\kern\z@#2}\limits^{#1}}}
\unexpanded\def\underset#1#2% {\preparebinrel{#2}% \currentbinrel{\mathop{\kern\z@#2}\limits_{#1}}} \unexpanded\def\stackrel#1#2% {\mathrel{\mathop{#2}\limits^{#1}}} or \unexpanded\def\stackrel#1#2% {\buildrel#1\over#2} And the following definitions in math-pln can be defined as unexpanded \def\doteq \def\cong \def\notin And the following in math-ini should change \rm to \mfunction \definemathcommand [unic@eulerconstant] {{\rm e}} \definemathcommand [unic@eqbydef] {\buildrel \rm def \over =} \definemathcommand [unic@measuredby] {\buildrel \rm m \over =} \definemathcommand [unic@questionedeq] {\buildrel \rm ? \over =} Aditya
On Sat, 3 Feb 2007, Taco Hoekwater wrote:
It is cleaner when renamed a little:
Taco Hoekwater wrote:
\def\binrel@#1%
\def\preparebinrel#1%
{\begingroup \setbox0=\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox2=\hbox{$#1\mathsurround0pt$}% \kern -wd2 ${}#1{}\mathsurround0pt$}% \edef\@tempa {\endgroup \let\noexpand\binrel@@ \let\noexpand\currentbinrel \ifdim\wd0<0pt \mathbin \else \ifdim\wd0>\z@ \mathrel \else \relax \fi\fi }% \@tempa }
And:
\unexpanded\def\overset#1#2% {\preparebinrel{#2}% \currentbinrel{\mathop{\kern\z@#2}\limits^{#1}}}
There was another request (although misguided) for overset in the mailing list today. I think that the following macros can go into the core: (Taco's version, with a typo corrected). %D \macros{overset, underset} %D %D The macros \type{\overset} and \type{\underset} are provided by %D \AMS\ packages in \LATEX. These macro allows you to place a symbol %D above or below another symbol, irrespective of whether the other %D symbol is a relation or something else, and without influencing the %D spacing. For most cases there is a better way to do such things %D (declaring a math command with limop option, or using accents), but %D occasionally these macros can be useful, for example %D %D \startbuffer %D \startformula %D \overset{*}{X} \underset{*}{X} %D \stopformula %D \stopbuffer %D \typebuffer \getbuffer %D %D Use these macros sparingly. Remember, \TEX\ was designed for %D mathematics, so there is usually a proper method for typesetting %D common math notation. %D These macros are a clearer version of \type{\binrel@} and %D \type{\binrel@@} macros in \AMSTEX\ packages. \def\preparebinrel#1% {\begingroup \setbox0=\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox2=\hbox{$#1\mathsurround0pt$}% \kern-\wd2 ${}#1{}\mathsurround0pt$}% \edef\@tempa {\endgroup \let\noexpand\currentbinrel \ifdim\wd0<0pt \mathbin \else \ifdim\wd0>\z@ \mathrel \else \relax \fi\fi}% \@tempa} \unexpanded\def\overset#1#2% {\preparebinrel{#2}% \currentbinrel{\mathop{\kern\z@#2}\limits^{#1}}} \unexpanded\def\underset#1#2% {\preparebinrel{#2}% \currentbinrel{\mathop{\kern\z@#2}\limits_{#1}}} Aditya
Aditya Mahajan wrote:
On Sat, 3 Feb 2007, Taco Hoekwater wrote:
It is cleaner when renamed a little:
Taco Hoekwater wrote:
\def\binrel@#1%
\def\preparebinrel#1%
{\begingroup \setbox0=\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox2=\hbox{$#1\mathsurround0pt$}% \kern -wd2 ${}#1{}\mathsurround0pt$}% \edef\@tempa {\endgroup \let\noexpand\binrel@@
\let\noexpand\currentbinrel
\ifdim\wd0<0pt \mathbin \else \ifdim\wd0>\z@ \mathrel \else \relax \fi\fi }% \@tempa }
And:
\unexpanded\def\overset#1#2% {\preparebinrel{#2}% \currentbinrel{\mathop{\kern\z@#2}\limits^{#1}}}
There was another request (although misguided) for overset in the mailing list today. I think that the following macros can go into the core: (Taco's version, with a typo corrected).
%D \macros{overset, underset} %D %D The macros \type{\overset} and \type{\underset} are provided by %D \AMS\ packages in \LATEX. These macro allows you to place a symbol %D above or below another symbol, irrespective of whether the other %D symbol is a relation or something else, and without influencing the %D spacing. For most cases there is a better way to do such things %D (declaring a math command with limop option, or using accents), but %D occasionally these macros can be useful, for example %D %D \startbuffer %D \startformula %D \overset{*}{X} \underset{*}{X} %D \stopformula %D \stopbuffer %D \typebuffer \getbuffer %D %D Use these macros sparingly. Remember, \TEX\ was designed for %D mathematics, so there is usually a proper method for typesetting %D common math notation.
%D These macros are a clearer version of \type{\binrel@} and %D \type{\binrel@@} macros in \AMSTEX\ packages.
\def\preparebinrel#1% {\begingroup \setbox0=\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox2=\hbox{$#1\mathsurround0pt$}% \kern-\wd2 ${}#1{}\mathsurround0pt$}% \edef\@tempa {\endgroup \let\noexpand\currentbinrel \ifdim\wd0<0pt \mathbin \else \ifdim\wd0>\z@ \mathrel \else \relax \fi\fi}% \@tempa}
ok, added in the following disguise: \def\preparebinrel#1% {\begingroup \setbox\scratchbox\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox\scratchbox\hbox{$#1\mathsurround\zeropoint$}% \kern-\wd\scratchbox ${}#1{}\mathsurround\zeropoint$}% \expanded {\endgroup \let\noexpand\currentbinrel \ifdim\wd\scratchbox<\zeropoint \mathbin \else\ifdim\wd\scratchbox>\zeropoint \mathrel \else \relax \fi\fi}} ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Tue, 20 Feb 2007, Hans Hagen wrote:
Aditya Mahajan wrote:
On Sat, 3 Feb 2007, Taco Hoekwater wrote:
It is cleaner when renamed a little:
Taco Hoekwater wrote:
\def\binrel@#1%
\def\preparebinrel#1%
{\begingroup \setbox0=\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox2=\hbox{$#1\mathsurround0pt$}% \kern -wd2 ${}#1{}\mathsurround0pt$}% \edef\@tempa {\endgroup \let\noexpand\binrel@@
\let\noexpand\currentbinrel
\ifdim\wd0<0pt \mathbin \else \ifdim\wd0>\z@ \mathrel \else \relax \fi\fi }% \@tempa }
And:
\unexpanded\def\overset#1#2% {\preparebinrel{#2}% \currentbinrel{\mathop{\kern\z@#2}\limits^{#1}}}
There was another request (although misguided) for overset in the mailing list today. I think that the following macros can go into the core: (Taco's version, with a typo corrected).
%D \macros{overset, underset} %D %D The macros \type{\overset} and \type{\underset} are provided by %D \AMS\ packages in \LATEX. These macro allows you to place a symbol %D above or below another symbol, irrespective of whether the other %D symbol is a relation or something else, and without influencing the %D spacing. For most cases there is a better way to do such things %D (declaring a math command with limop option, or using accents), but %D occasionally these macros can be useful, for example %D %D \startbuffer %D \startformula %D \overset{*}{X} \underset{*}{X} %D \stopformula %D \stopbuffer %D \typebuffer \getbuffer %D %D Use these macros sparingly. Remember, \TEX\ was designed for %D mathematics, so there is usually a proper method for typesetting %D common math notation.
%D These macros are a clearer version of \type{\binrel@} and %D \type{\binrel@@} macros in \AMSTEX\ packages.
\def\preparebinrel#1% {\begingroup \setbox0=\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox2=\hbox{$#1\mathsurround0pt$}% \kern-\wd2 ${}#1{}\mathsurround0pt$}% \edef\@tempa {\endgroup \let\noexpand\currentbinrel \ifdim\wd0<0pt \mathbin \else \ifdim\wd0>\z@ \mathrel \else \relax \fi\fi}% \@tempa}
ok, added in the following disguise:
\def\preparebinrel#1% {\begingroup \setbox\scratchbox\hbox {\thinmuskip 0mu \medmuskip -1mu \thickmuskip -1mu \setbox\scratchbox\hbox{$#1\mathsurround\zeropoint$}% \kern-\wd\scratchbox ${}#1{}\mathsurround\zeropoint$}% \expanded {\endgroup \let\noexpand\currentbinrel \ifdim\wd\scratchbox<\zeropoint \mathbin \else\ifdim\wd\scratchbox>\zeropoint \mathrel \else \relax \fi\fi}}
Ah! So that is why \expanded is useful. Thanks, Aditya
Aditya Mahajan wrote:
On Fri, 2 Feb 2007, Aditya Mahajan wrote:
Hi Hans and Taco,
Do you think it makes sense to replace {\rm mod} in the definition of bmod and pmod (in math-pln.tex) by \mfunction{mod}?
Another request: I am thinking of updating the nath module, and I notice that nath.sty goes into considerable length to make math commands "robust" (whatever that means). Basically
\def\makerobust#1{% \expandafter\let\csname @o@\expandafter\gobbleoneargument\string #1\endcsname=#1 \unexpanded\def#1{\csname @o@\expandafter\gobbleoneargument\string #1\endcsname}}
% Making composed math symbols robust:
\makerobust\cong \makerobust\notin
If I understand correctly, this can be achieved by replace
\def\cong to \undexpanded\def\cong in math-pln.
The \makerobust command is simply \let\@o@cong=\cong \unexpanded\def\cont{\@o@cong}
I do not understand expansion very well, but is there a disadvantage of not defining math characters to be unexpandable to begin with?
Every (or almost every, let's be a bit careful) macro in math mode could be make unexpandable. Taco
Taco Hoekwater wrote:
Aditya Mahajan wrote:
Hi Hans and Taco,
Do you think it makes sense to replace {\rm mod} in the definition of bmod and pmod (in math-pln.tex) by \mfunction{mod}?
Yes. It would even better to move the definitions to math-tex, where the other named operators live.
makes sense, rather encoding independent eh? ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Aditya Mahajan wrote:
Hi Hans and Taco,
Do you think it makes sense to replace {\rm mod} in the definition of bmod and pmod (in math-pln.tex) by \mfunction{mod}?
\ifx\mfunction\undefined \def\mfunction{\mathbin{\rm#1}} \fi \def\bmod {\nonscript \mskip-\medmuskip \mkern5mu \mfunction{mod}% \penalty900 \mkern5mu \nonscript \mskip-\medmuskip} \def\pmod#1% {\allowbreak \mkern18mu (\mfunction{mod}\,\,#1)} i changed it (wondering what it does in pln) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Sat, 3 Feb 2007, Taco Hoekwater wrote:
Aditya Mahajan wrote:
Hi Hans and Taco,
Do you think it makes sense to replace {\rm mod} in the definition of bmod and pmod (in math-pln.tex) by \mfunction{mod}?
Yes. It would even better to move the definitions to math-tex, where the other named operators live.
On Sat, 3 Feb 2007, Hans Hagen wrote:
makes sense, rather encoding independent eh?
\ifx\mfunction\undefined \def\mfunction{\mathbin{\rm#1}} \fi
Why the mathbin? In math-ini.tex \mfunction is defined as \def\mfunction#1{{\mr#1}}.
\def\bmod {\nonscript \mskip-\medmuskip \mkern5mu \mfunction{mod}% \penalty900 \mkern5mu \nonscript \mskip-\medmuskip}
\def\pmod#1% {\allowbreak \mkern18mu (\mfunction{mod}\,\,#1)}
How about replacing \, with \mskup\thinskip? That will be the macro more readable.
i changed it
Thanks.
(wondering what it does in pln)
Probably because it is defined by plain.tex Aditya
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Taco Hoekwater