Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.)

share|improve this question

1 Answer 1

up vote 9 down vote accepted

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.