[texhax] TeX vs LaTeX primitives

jfbu jfbu at free.fr
Mon Dec 30 13:09:55 CET 2013


Le 30 déc. 2013 à 12:26, Ulrike Fischer <news3 at nililand.de> a écrit :

> Am Mon, 30 Dec 2013 10:55:57 +0000 schrieb Philip Taylor:
> 
>> Ulrike Fischer wrote:
> 
>>>> 2) How in general distinguish truly LaTeX macros?
> 
>>> By looking in the code or the documentation. 
> 
>> Factually accurate, but hardly satisfactory.  
> 
> Well one could also use \show to identify the primitives

Hi,

Here is a not thoroughly tested attempt as a LaTeX command:

\documentclass{article}

\makeatletter

\newcommand\IfPrimitive [1]{%
     \expandafter\def\expandafter\IfPrimitive at a\expandafter{\string #1}%
     \expandafter\def\expandafter\IfPrimitive at b\expandafter{\meaning #1}%
     \ifx\IfPrimitive at a\IfPrimitive at b
     \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi }

\newcommand\SayifPrimitive [1]{\IfPrimitive {#1}%
    {\string#1 is a primitive}%
    {\string#1 isn't a primitive}}

\makeatother

\begin{document}

\ttfamily

\makeatletter
\@tfor\x:=a\hrule\begin\string\meaning\empty\hbox\end\x\catcode%
          \mbox\par\if\clearpage\endgraf\ifcase$\equation\vfill\eqno\pageno
\do {\expandafter\SayifPrimitive\x\par }
\makeatother

\end{document}

Best,
Jean-François



> 
>> If LaTeX 3 is to
>> be a new language which does not carry with it the legacy of
>> TeX primitives, then it should also have a new syntax so that
>> its macros can be immediately distinguishable from TeX primitives.
> 
> Latex 3 commands can be easily recognized. It also copies and hides
> TeX primitives so when latex 3 takes over (will be a real format)
> things like \hbox will no longer refer to tex primitives but are
> either undefined or user commands. See the documentation source3.
> 
> But currently nothing prevents people from using (inadvertendly or
> by intention) tex primitives.
> 
> -- 
> Ulrike Fischer 
> http://www.troubleshooting-tex.de/
> 
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
> 
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org




More information about the texhax mailing list