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
Code: Select all
\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}} {}
Code: Select all
\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}}
Code: Select all
\begin{yfifg} {acaption} \end{yfifg}
and
\fig{acaption}
PS: (A simple question for not open a new topic) both environment and command may accept only one default value?