Version : work with Mathematica 5.2
June, 25th 2006

How to - Automatic Slide Show

Benjamin Collas
Université Paris 6 - France
benjamin.collas@telaxo.com

During the International Mathematica Symposium 06 at Avignon (France), someone wanted to use a Mathematica slide show combined with a video projector in an all automatic way : the slides have to scroll automatically in an infinite loop without the help of anybody.
This feature seems to be needed by a lots of Mathematica users. They can now project their own work with a video projector (like a poster), or show it on free acces computers during seminars.
This short notebook explains how to do this and gives a paste and ready code.

How to

Opening of the slideshow notebook file

Open the notebook containing your presentation using the file browser,

MyNbSlideName = NotebookOpen[Experimental`FileBrowse[False]]

Initialisation

The following variables get the number of pages of the presentation and the pause timing between each slide,

{nbPages = 
          Length[Position[NotebookGet[MyNbSlideName], 
              CellTags -> "SlideShowHeader"]], 
        pauseTime = 2};

Nota :  the number of pages is counted using the cells tagged by SlideShowHeader.

Then we apply options to the presentation notebook to make it fullscreen sized with a SlideShow view environment,

SetOptions[MyNbSlideName, WindowSize -> {Automatic, Automatic}, 
      WindowMargins -> {{0, 0}, {0, 0}}, 
      ScreenStyleEnvironment -> "SlideShow"]

Slide in a loop

The following command make the slides to cycle - use the Kernel/Abort evaluation command in the menu to stop it.

page = 1;
FrontEndExecute[{FrontEndToken[
            MyNbSlideName, "ScrollPageFirst"]}];
While[
      True, 
If[page <= nbPages, 
        Pause[pauseTime]; 
FrontEndExecute[{FrontEndToken[
              MyNbSlideName, "ScrollPageNext"]}]; page++;, 
        FrontEndExecute[{FrontEndToken[
              MyNbSlideName, "ScrollPageFirst"]}]; page = 1; 
        Pause[pauseTime]]]

Nota : you can use the option below to hide this notebook and view the presentation (to make the hidden notebook to appear, select it in the Windows menu),

SetOptions[SelectedNotebook[], Visible -> False]

The code

You can use the following code to automatically open the file containing the presentation with the file browser, make it full screen, hide this notebook, and start the slide to cycle.

MyCommanderName = SelectedNotebook[];
MyNbSlideName = 
        NotebookOpen[Experimental`FileBrowse[False]];
{nbPages = 
          Length[Position[NotebookGet[MyNbSlideName], 
              CellTags -> "SlideShowHeader"]], 
        pauseTime = 5};
SetOptions[MyNbSlideName, WindowSize -> {Automatic, Automatic}, 
      WindowMargins -> {{0, 0}, {0, 0}}]
SetOptions[MyNbSlideName, 
      ScreenStyleEnvironment -> "SlideShow"]
SetOptions[MyCommanderName, Visible -> False];
page = 1;
FrontEndExecute[{FrontEndToken[
            MyNbSlideName, "ScrollPageFirst"]}];
While[
      True, 
If[page <= nbPages, 
        Pause[pauseTime]; 
FrontEndExecute[{FrontEndToken[
              MyNbSlideName, "ScrollPageNext"]}]; page++;, 
        FrontEndExecute[{FrontEndToken[
              MyNbSlideName, "ScrollPageFirst"]}]; page = 1; 
        Pause[pauseTime]]]

Further development