[texhax] Is redefining primitives a good idea?

Khaled Hosny khaledhosny at eglug.org
Tue Apr 24 05:26:21 CEST 2012


No problem here:

\input ifxetex.sty
\input ifluatex.sty
\ifxetex\else\ifluatex\else\let\primitive\pdfprimitive\fi\fi

$$ a+b=\sqrt{c+d} \eqno(1)$$
\let\eqno\relax
$$ a+b=\sqrt{c+d} \eqno(2)$$
$$ a+b=\sqrt{c+d} \primitive\eqno(3)$$
\bye

On Tue, Apr 24, 2012 at 01:13:45PM +1000, Vafa Khalighi wrote:
> TeX (PDFTeX, XeTeX, luatex) complains that:
> 
> You can't use \eqno in vertical mode.
> 
> On Tue, Apr 24, 2012 at 3:38 AM, Khaled Hosny <khaledhosny at eglug.org> wrote:
> 
>     On Mon, Apr 23, 2012 at 12:48:16PM +1000, Vafa Khalighi wrote:
>     > As an example amsmath.sty redefines \eqno and \leqno. Would not it be
>     better to
>     > define new macros rather than redefining existing primitives? and how one
>     can
>     > (if a package already redefines some primitives), restore the original
>     > definition of the primitive? so that a primitive is really a primitive?
> 
>     PdfTeX has \pdfprimitive that can be used to access the original
>     definition of any primitive, e.g. \pdfprimitive\eqno. LuaTeX and XeTeX
>     have it under \primitive name.
> 
>     Regards,
>      Khaled
> 
> 


More information about the texhax mailing list