7

As comment on Can the extended register pool be used for \newinsert?, there is a reference to Dealing with tons of floats. It is interesting but uses \unexpanded:

\edef\@freelist{%
\unexpanded\expandafter{\@freelist\@elt}\expandafter\noexpand\ExtraFloatCommand}%

How can this be replaced by something like \expandafter, \noexpand, \toks@, which does not require the eTeX extension? (With eTeX probably \etex@unexpanded from the etexcmds package would be better than \unexpanded.)

Stephen
  • 14,890

1 Answers1

10

Without the e-TeX extensions, you need to use a toks to have control of expansion inside an \edef. Usually, this is done using \toks@, and so to avoid any issues with other code a group is normally employed

\begingroup
  \toks@\expandafter{\@freelist\@elt}%
  \edef\@freelist{\the\toks@\expandafter\noexpand\ExtraFloatCommand}%
\expandafter\endgroup
\expandafter\def\expandafter\@freelist\expandafter{\@freelist}%

(You may be able to use \xdef here, but without a careful check I am not sure of the scope of \@freelist.)

You could also achieve the same directly using just \expandafter:

\expandafter\expandafter\expandafter\def
  \expandafter\expandafter\expandafter\@freelist
  \expandafter\expandafter\expandafter{%
  \expandafter\@freelist\expandafter\@elt
  \ExtraFloatCommand}%

which works by first expanding \ExtraFloatCommand, then expanding \@freelist, both inside the new definition of \@freelist.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • Both approaches are in my opinion much less readable than with e-TeX! – Joseph Wright Jan 10 '12 at 17:50
  • Yes, if one has e-TeX, it surely is to be preferred! +1 for the answer. While accepting after a short time might not be good style in general, I think your answer just provides THE "translation" (both ways of it, indeed!), therefore I just accept it now. Thank you! – Stephen Jan 10 '12 at 19:05