I've created a newenvironment for wrapping a figure but it fails to wrap text (text overlaps figure). When I place the same code to a newcommand everything works fine and I can't figure out why.
I quote the two code excerpts below.
New envrironment
\newenvironment{yfifg}[1][] { \begin{wrapfigure}{r}{0.2\textwidth} \begin{center} \includegraphics[width=0.18\textwidth]{images/c\thechapter /\thecntfig} \end{center} \caption{#1} \end{wrapfigure} \stepcounter{cntfig}} {}
New command
\newcommand{\yfig}[1]{ \begin{wrapfigure}{r}{0.2\textwidth} \begin{center} \includegraphics[width=0.18\textwidth]{images/c\thechapter /\thecntfig} \end{center} \caption{#1} \end{wrapfigure}}
Obviously in text they are called as
\begin{yfifg} {acaption} \end{yfifg} and \fig{acaption}
respectively.
PS: (A simple question for not open a new topic) both environment and command may accept only one default value?