I have setup a function called quickfigure which has the purpose of inserting a centered image with a one-line command:
\newcommand{\quickfigure}[2] {
\begin{figure}[H]
\centering
\includegraphics[width=0.6\linewidth]{#1}
\caption{#2}
\end{figure}
}
This function is used as follows;
\quickfigure{img/testImage.png}{Test image}
I would like this function to accept optional arguments to define width and height of the image, as well as a label. The syntax is desired to be something like;
\quickfigure[width=0.6, label=img:test]{img/testImage.png}{Test image}
How would I go about setting this up? I need a push in the right direction. Thanks!
Edit: Thanks everyone for the ideas, this is my solution;
\includepackage{keyval}
\includepackage{ifthen}
\newlength{\qf@width}
\define@key{quickfigure}{width}{\setlength\qf@width{#1}}
\define@key{quickfigure}{label}{\def\qf@label{#1}}
\newcommand{\quickfigure}[3][] {
\setkeys{quickfigure}{width=0.6\linewidth,label=\@empty}
\setkeys{quickfigure}{#1}
\begin{figure}[H]
\centering
\includegraphics[width=\qf@width]{#2}
\caption{#3}
\ifthenelse{\equal{\qf@label}{}}{}{\label{\qf@label}}
\end{figure}
}

\includegraphics– egreg Mar 03 '14 at 22:25labeldoesn't exist for\includegraphics. It would have to be managed differently. And true, it was a mild approach at pushing towards a solution. – Werner Mar 03 '14 at 22:53\setkeysas\setkeys{quickfigure}{width=.6\linewidth,label=\@empty,#1}. Note that you are required to use a\makeatletter...\makeatotherpair with your current definition. – Werner Mar 03 '14 at 23:07%at the end of most lines in your definition – David Carlisle Mar 03 '14 at 23:14