Sorry all... the "missing number, treated as zero" error again. I can usually find it and fix it, but this time I need help.

I have a macro \twoup to produce output consisting of two A5 pages on an A4 sheet. It works fine.

I am now trying to write a macro \notatable (i.e., able to be notated... nothing to do with tables) which is intended to output a single A5 page at the left hand side of an A4 sheet, with the right hand side left blank for annotations. It sort of works. I get errors when running TeX but I still get the output I want... but with a tiny vertical line just below the footline on page 1.

The error for each page appears to be flagged at the beginning of the first complete paragraph on the following page.

Any suggestions? Implementation is simply \notatable at the head of the text. Code follows (including \twoup code for reference, although it is not causing problems), and output sample - note the vertical line below left of the page number.

\newcount\finalpageno \newtoks\normalfootline
\def\nomorepagenumbers{\finalpageno=\pageno \normalfootline=\footline
  \footline={\ifnum\pageno>\finalpageno \else \the\normalfootline \fi}}
  \output={\if L\lr \global\setbox\leftpage=\pagebox
           \else \doubleformat \global\let\lr=L\advancepageno \fi
           \ifnum \outputpenalty>-2000\else \dosupereject \fi}%
  \def\doubleformat{\setbox1=\hbox to26truecm{\box\leftpage\kern2truecm%
\def\notatable{\special{papersize=297mm,210mm}% like \twoup but leaves right page blank for notes
  \output={\doubleformat \advancepageno \ifnum \outputpenalty>-2000\else \dosupereject \fi}%
  \def\doubleformat{\setbox1=\hbox to26truecm{\box\pagebox\kern14truecm\hss}\shipout\box1}%

enter image description here

2 Answers 2


You has \box\pagebox in your first attempt of your code and your \pagebox is defined by


the \leftline is defined in Plain TeX by \hbox to\hsize{#1\hss}. Macros expand to

\box\hbox to\hsize{...}

but the primitive \box expects only number as its parameter, no \hbox. Hence there is the error "missing number".

If you want to put the box constructed as \hbox to\hsize... then you can put it directly by

\def\doubleformat{\setbox1=\hbox to26truecm{\pagebox\kern14truecm\hss}\shipout\box1}%

i.e. there is no \box primitive before \pagebox. Moreover, your \doubleformat is over-complicated. It shipouts simply \pagebox. It is irrelevant that it is encapsulated into \hbox to26cm because we don't see the right boundary of a box which is processed by \shipout. Simpler definition which does the same is:


Your code is over-complicated at more places but I don't comment it because this is not a subject of your question.

  • I don't think you are right about the source of the "missing number" error - I have changed other things but left that the same, and the error has disappeared. However, thank you for your suggestions for simplifying the code, I will try them.
    – David
    Commented Sep 1, 2022 at 23:25
  • 2
    I am absolutely sure. \box\pagebox is syntactically wrong if \pagebox expands to \hbox. And the error message shows the place where the problem is at next lines. You can read it.
    – wipet
    Commented Sep 2, 2022 at 5:34
  • 1
    @David wipet is correct here \box\pagebox could never have worked. Commented Sep 3, 2022 at 15:23

I think I have fixed this. I'll leave the question and answer in case it comes up for anyone else. Also perhaps someone who understands these things better can confirm (or not) my explanation. Here is my new code.

\def\notatable{\special{papersize=297mm,210mm}% like \twoup but leaves right page blank for notes
  \output={\global\setbox\leftpage=\pagebox \doubleformat \advancepageno \ifnum \outputpenalty>-2000\else \dosupereject \fi}%
  \def\doubleformat{\setbox1=\hbox to26truecm{\box\leftpage\kern14truecm\hss}\shipout\box1}%

Note that I have added \global\setbox\leftpage=\pagebox and \box\leftpage.

I assume this means that when I set \pagebox in my earlier code, it was not communicated to the "outside world". And I guess it created a "missing number" error because I had \box followed by something unrecognised, which was parsed as \box not followed by a number.

  • \setbox1=\hbox to26truecm{\box\leftpage\kern14truecm\hss}\shipout\box1} you should only use box1 for global assignments box2 would be better here Commented Sep 1, 2022 at 6:41
  • @DavidCarlisle I've never heard of anything like that, can you tell me a bit more please?
    – David
    Commented Sep 1, 2022 at 6:56
  • 2
    see the texbook,registers 0,2,4,6,8 are unallocated and left for scratch local use, 1,3,5,7 are global scratch registers (applies to count dimen etc as well as box registers) Commented Sep 1, 2022 at 7:03
  • Thanks @DavidCarlisle! I have read the TeXbook reasonably carefully but must have missed that. I hope it doesn't hugely matter, otherwise I am going to have a lot of code to fix, not just this bit :)
    – David
    Commented Sep 1, 2022 at 7:07
  • look for save stack in the index. You should fix really. Two things can go wrong, you can flood the save stack (this used to be critical, modern tex builds us bigger stack space, but it is still a finite resource, and in general (not here, probably) using an unexpected global assignment to a shared local register will break outer code. Commented Sep 1, 2022 at 7:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .