Метки

Two years ago I wrote my own beamer style for presentations on faculty, conferences etc. It shows current number of frame and total number of frames in the right bottom corner of frame. There was a small disadvantage, when presentation had many appendix frames and number of Conclusions frame did not correspond a value of \inserttotalframenumber variable.

There is two ways for solving this problem. First is very easy. In the last post Tom wrote about beautiful appendixnumberbeamer package which allows to limit \inserttotalframenumber value by \appendix command. The second way is very long and I went by this way 🙂 Really it is not something terrible, but a good experience in $\LaTeX$ programming and in this post I will tell about it.

The main idea consists in using a some «marker» command which remember a current frame number. One can name it \thefinalframe and write it at the frame which must be really final (Conclusions, ThanksForAttention etc). I place the next code in style file:

```\newwrite\numberfile

\newcommand*\thefinalframe{%
\begingroup
\immediate\openout\numberfile=\jobname.num%
\immediate\closeout\numberfile%
\endgroup
}
```

The first line creates a stream \numberfile for writting to external file. At the third line code of \thefinalframe command is placed. One opens a file with name equals a value of \jobname variable and with a «num» extension. Next one writes value of the \insertframenumber variable in \jobname.num and closes this file. On practice, this file will be created (or rewritten) on first run of pdflatex.

Now we must use value from \jobname.num file. The simplest way I know reads

```

Here one checks exsistence of \jobname.num. If file exists, one defines a new command \thefinalframenumber which contains a content of \jobname.num — a number of our final frame. If file does not exists, in fact it redefines \inserttotalframenumber. Next I use

```\insertframenumber~/~\thefinalframenumber
```

for displaying current and total number of frames in presetation. Really I create the new command only due to some internal reasons of my style. For someone it could be more accurate to redefine \inserttotalframenumber without creating \thefinalframenumber command.

Really, my method has one disadvantage: the \jobname.num also includes line feed which results in additional space after number in the \thefinalframenumber command.