# Making a macro with \newcommand not responding as I expect [closed]

I am trying to abstract code to make an image by making a macro. Could someone please explain why this does not work?

\newcommand[1]{\custpic}{\begin{figure}[H]\begin{center}\includegraphics[width=0.5\textwidth]{#1}\end{center}\caption{}\end{figure}} % url

\custpic{4b.png}


What is confusing me is that this does work as expected.

\newcommand[1]{\custpic}{\begin{figure}[H]\begin{center}\includegraphics[width=0.5\textwidth]{4b.png}\end{center}\caption{}\end{figure}}

\custpic


Thank you very much

-
Yes, in the definition, the optional argument, which indicates the number of arguments of your new command, comes after the name of your command. – Jubobs Mar 6 at 0:29
It does indeed fix it. Thank you very much PaulGaborit and Jubobs. – superbriggs Mar 6 at 0:30
\centering is usually better than \begin{center}... for figures: tex.stackexchange.com/questions/23650/… – Ethan Bolker Mar 6 at 1:01
@PaulGaborit please either post an answer, or vote to close – cmhughes Mar 6 at 1:48

## closed as too localized by Paul Gaborit, Kurt, Thorsten, Martin Schröder, lockstepMar 6 at 6:44

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.