[texhax] fmt to cls conversion

Philip TAYLOR P.Taylor at rhul.ac.uk
Thu Jun 21 23:53:16 CEST 2012



Reinhard Kotucha wrote:

> I fear that it's impossible.  TeX evaluates (expands) macros before
> dumping a format file.  With other words, if the source file contains
> the expression
>
>    3 + 4
>
> , the format file contains only the number 7 and there is no way to
> find out whether it was 3 + 4 or 5 + 2 in the source code.
>
> The purpose of a format file is to avoid that all calculations have to
> be done at runtime.  Hence it only contains the results of such
> calculations and macro expansions.

Isn't that something of an over-simplification, Reinhard ?
Leaving aside the highly dubious assertion that "if the source
file contains the expression 3 + 4, the format file contains
only the number 7" (3 + 4 is /highly/ unlikely to involve macro
expansion), consider something as simple as the following :

	\def \foo {\bar \baz}
	\dump

In the format file, the macro \foo will be defined but /not/
expanded.  If the user at run-time then interrogates \foo :

	\message {\meaning \foo}

he will be provided with the original definition, which may well
help him enormously with his task of re-creating the format source.

To demonstrate this, please try the following with VirTeX :

	\message {\meaning \centerline}
	\end

This will yield :

	macro:#1->\line {\hss #1\hss }

and that information has effectively been retrieved from the
format file.

Philip Taylor




More information about the texhax mailing list