Automation programming is a bit easier if you happen to have a mouse with a middle button. The following discussion assumes you do, but if you don't, just substitute "Ctrl+left-click" for "middle-click".
Middle-click (or Ctrl+left-click) in the pan slider. The "Auto Pan" dialog should appear. Notice that the dialog contains Play, Pause, Stop, and Loop buttons, just like the track. Press the play button. The dialog closes, and the pan slider moves smoothly towards the opposite end. Congratulations! You just programmed an automation.
Middle-click in the pan control to open its automation dialog again, and press the dialog's loop button. This tells the automation to repeat instead stopping when it reaches the end. Now press play. Notice that the pan control moves back and forth. You just created an auto-panner.
Draw a selection within the pan slider, using the same technique you used before with the position slider (right-click and drag). Notice that the pan slider's thumb now moves back and forth within the selection, instead of moving the full width of the slider.
Open the auto pan dialog again, and try moving the automation time slider (the slider at the top of the dialog). Notice that the automation speeds up or slows down accordingly. The time slider normally operates in seconds, but for longer automations, you can switch to minutes, by pressing the button marked 'm'.
The default automation waveform is a triangle wave (back and forth), but other options include ramp up/down, square, and random. Try changing the waveform type, using the drop-down list in the lower left corner of the automation dialog.