[texhax] tex goes into infinite loop

Ross Moore ross at maths.mq.edu.au
Mon Oct 11 02:11:46 CEST 2004

Hello Tom,

On 10/10/2004, at 11:19 PM, tomfool at as220.org wrote:

> Can anyone help me understand why the following doesn't work?

I see 2 distinct problems:

>   \documentclass[twocolumn]{article}
>   \makeatletter
>   \newbox\IN at topfig
>   \newbox\IN at topfiga
>   \newtoks\IN at output
>   \global\IN at output\expandafter{\the\output}

>   \global\output{%
>     \expandafter\the\IN at output%
       ^^^^^^^^^^^ --------  this is wrong, surely!

>     \ifvoid\IN at topfig \else\unvbox\IN at topfig\fi%
>     \global\setbox\IN at topfig \vbox{\hbox{Hola!}}
>   }

Firstly, don't you want here either:

   \global\output\expandafter{\the\IN at output ... }

or simply just

   \global\output{\the\IN at output ... }

since \IN at output  is constant, so expanding it can
be delayed until you are actually going to use it.

Secondly, your use of \unvbox  places material back onto
the vertical-list, every time the \output routine is called
(except perhaps for the first time).
Hence TeX will *always* think that there is more work to do.

In short, you have created an algorithm for which the stopping
criterion is never satisfied. Hence it keeps looping through
the \output, never able to stop...

>   \makeatother
>   ...
> When I try to compile, TeX goes into an infinite loop.  Not that I've

  ... as you observe.

> waited long enough to confirm it's infinite, but it's long, and more
> to the point, silent:

But it's actually a little more complicated than this, in that LaTeX's
own \output routine (which you use as \IN at output) actually gets caught
in a loop, trying to clear out the new stuff.
This prevents TeX from ever getting to \shipout anything.

> The log is not more informative.  Is there something about re-using a
> box that I'm not understanding?  This works fine if I \unvbox a
> different box than the one I \setbox, so it isn't the commands
> themselves that aren't working, but somehow \setboxing a box right
> after I've \unvboxed it in an \output routine is a problem.  Can
> anyone tell me what I've done wrong here?

It looks like you are trying to place constant material on every page,
by having the \output routine from the previous page place it there.
Apart from the logical flaw in this approach, whereby TeX can never
finish, working with \output  routines in this way is *very* tricky.

It's much easier to redefine \shipout to position the new material
as a box of zero size. This is what the  {everyshi}  package does.
Have you tried this ?
Is there a reason that isn't suitable for your needs ?

> Many thanks,

Hope this helps,

	Ross Moore

> -tom
>  ------------------------
>  tomfool at as220 dot org
>  http://sgouros.com
>  http://whatcheer.net
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> TeX newsgroup: http://groups.google.com/groups?group=comp.text.tex
> 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
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia                                  fax: +61 +2 9850 8114

More information about the texhax mailing list