[NTG-context] \placeformula and $$ doesn't work anymore

Aditya Mahajan adityam at umich.edu
Tue Dec 5 23:09:44 CET 2006


On Tue, 5 Dec 2006, Aditya Mahajan wrote:

> On Mon, 4 Dec 2006, Hubertus Schmidt wrote:
> 
> > Hi all,
> > for some weeks I need to tex formulas again and tried the way I used to do it:
> > 
> > \placeformula
> > $$
> > f(t)={1\over2\pi}\int_0^\infty e^{i(\omega t-kx)} dx
> > $$
> > 
> > It didn't work anymore?!? It doesn't place a number nor does it do the spacing
> > properly. It does work the "context" way using
> > 
> > \placeformula
> > \startformula
> > f(t)={1\over2\pi}\int_0^\infty e^{i(\omega t-kx)} dx
> > \stopformula
> 
> This is a bug in doplaceformula. I do not know how to avoid it, but 
> the next code illustrates what is happening.
> 
> \def\dotest{
>    \def\nextnext{$}%
>    \ifx\next\nextnext
>      Inside dispplaceformula\ldots % This always fails
>    \else
>      Inside dodoplaceformula\ldots
>   \fi}
> 
> \def\test{\futurelet\next\dotest}
> 
> \test$$A = B$$
> 
> This prints "Inside dodoplaceformula" even though the next character 
> is \$.
> 
> So, the \next=\nextnext branch never matches. I do not know why this 
> happens, but a more robust check is needed in doplaceformula.

\ifcat seems to be working, but I do not really know how robust this 
is?

\unprotect

\def\doplaceformula[#1][#2]% #2 = dummy, gobbles spaces
   {\def\redoplaceformula
      {\bgroup
       \ifx\next\bgroup
         \egroup \@EA\moreplaceformula % [ref]{}
       \else
%      \def\nextnext{$}%
%      \ifx\next\nextnext
       \ifcat\next$%
           \egroup \@EAEAEA\dispplaceformula % [ref]$$
         \else
           \egroup \@EAEAEA\dodoplaceformula % [ref]\start
         \fi
       \fi[#1]{}}%
    \futurelet\next\redoplaceformula}

\long\def\moreplaceformula[#1]#2#3#4% #2 dummy #4 gobbles spaces
   {\def\redoplaceformula
      {\bgroup
%      \def\nextnext{$}%
%      \ifx\next\nextnext
       \ifcat\next$%
         \egroup \@EA\dispplaceformula % [ref]$$
       \else
         \egroup \@EA\dodoplaceformula % [ref]\start
       \fi
       [#1]{#3}}%
    \futurelet\next\redoplaceformula#4}

\protect

\starttext

\placeformula[eq:test]  $$A = B$$

\stoptext


Aditya


More information about the ntg-context mailing list