I'm writing some macros that need to behave differently after first occurrence. I decided to use the etoolbox package's toggle. My MWE is as follows:
\documentclass{article}
\usepackage{etoolbox}
\newtoggle{SL}
\newcommand{\SL}{%
\textit{SL}%
\nottoggle{SL}{~first}{~second}%
\toggletrue{SL}% switches to true after first occurrence!
}
\begin{document}
A footnote.\footnote{\SL}\par
\SL \par
\SL \par
\SL
\end{document}
As an output I get the following:

The problem, as you can see, is that when using the command in a footnote, the toggle does not occur. (Should the image not be clear enough, the footnote reads "1 SL first".)
What is going on in here? (I tried TeX's \newif with the same result, by the way.)

\newcommand{\SL}{\textit{SL}~first\renewcommand\SL{\textit{SL}~second}}. ...although a global version is easier with plain TeX than with basic LaTeX:\gdef\SL{\textit{SL}~first\gdef\SL{\textit{SL}~second}}. – Stephan Lehmke Jun 11 '12 at 20:00