This seems like a bit of a strange request- are you sure you don't want to have LaTeX
generate the figure numbers for you?
If you really do want to do this, then here's one way- note that
- I have changed
\newenvironment
to \newcommand
- I have removed
[,]
which means something different from what you intended
- I have used
\setcounter
to change the figure number to what you want
Here's a complete MWE
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{article}
\usepackage[demo]{graphicx}
\newcommand{\insertmyimages}[2]{%
\setcounter{figure}{\numexpr#2-1\relax}
\figure[!htb]
\centering
\includegraphics[width=\textwidth]{#1}%
\caption{}
\endfigure
}
\begin{document}
\insertmyimages{./Image.gif}{17}
\end{document}
Perhaps you might have wanted
\newcommand{\insertmyimages}[2]{%
\figure[!htb]
\centering
\includegraphics[width=\textwidth]{#1}%
\caption{}
\label{#2}
\endfigure
}
to be used as, for example
\insertmyimages{./Image.gif}{mylabel}
\centering
won't do anything if you usewidth=\textwidth
; the image has nowhere to go.