How can I define a function call \StepFrame that accepts default arguments, as well as optional arguments for more complex behavior? I would like to define a LaTeX command \StepFrame that behaves differently depending on the number of arguments passed to it. Specifically, I want:
- A default case, where the command is called with two arguments (title and image file), and it generates a frame with a single image.
- An optional case, where the command is called with three arguments (title, main image, and overlay image), and it generates a frame with the second image overlaid on the first image.
Here's a basic version of my code:
\documentclass{beamer}
\newcommand{\StepFrame}[2]
{
%% default case:
\begin{frame}{#1}
\includegraphics[width=\textwidth]{#2}
\end{frame}
%% optinal case:
%\begin{frame}{#1}
% \includegraphics[width=\textwidth]{example-image}\llap{\includegraphics[width=0.4\textwidth]{example-image}}
%\end{frame}
}
\begin{document}
%% call the function \StepFrame with default arguments (single image)
\StepFrame{my title 1}{example-image}
\StepFrame{my title 2}{example-image}
\StepFrame{my title 3}{example-image}
%% call the function \StepFrame with optional arguments (image inside another image)
%\StepFrame{my title 4}{example-image}{example-image-b}
%\StepFrame{my title 5}{example-image}{example-image-b}
%\StepFrame{my title 6}{example-image}{example-image-b}
\end{document}

\StepFrame{my title 4}{example-image}[example-image-b], with brackets for optional arguments?\StepFrame[example-image-b]{my title 4}{example-image}, if that makes sense in your code.