# why beamer requires multiple compilation to get slide numbers correct?

I don't actually have a real problem, but I'd like to understand why beamer requires multiple compilations to get the slide count right.

I'm writing a presentation, so I often add a new frame, write something, and then compile the presentation to see how it looks. But every time a new frame is added the total number of slides isn't updated, so the last slide shows a n+1/n label instead of n+1/n+1 as I'd expect(where n is the previous number of slides).

I've tried to search a bit but I couldn't find anything mentioning this behaviour.

Is this supposed to be the normal behaviour?

edit: I can reproduce this by doing the following steps:

1. Create a random beamer presentation(using a style that shows the slide count e.g. AnnArbor) with one frame
2. Compile it
The number of last slide is only known when the last slide is produced (TeX reads your input from start to finish, creating pages as it goes). beamer writes this information to the .aux file as part of the 'tidy up' after the last output page is produced (at \end{document}). On the next run, this information is read back before the first page is produced (at \begin{document}), and is 'read only' during the page creation process. When the number of slides changes, the previous number is used during the typesetting process as that's what was read in. Thus you always need a second run to account correctly for a new slide. (The same is true for many other LaTeX values, for example cross-references, the number of the last page, ...).