LaTeX forum ⇒ Text FormattingNewcommand works but newenvironment fails to wrapfig

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
yiorgosb
Posts: 30
Joined: Mon Aug 02, 2010 11:56 pm

Newcommand works but newenvironment fails to wrapfig

Postby yiorgosb » Mon Feb 28, 2011 12:52 am

I place this topic here since it is in essence a formatting issue.
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
  1. \newenvironment{yfifg}[1][] {
  2. \begin{wrapfigure}{r}{0.2\textwidth}
  3. \begin{center}
  4. \includegraphics[width=0.18\textwidth]{images/c\thechapter /\thecntfig}
  5. \end{center}
  6. \caption{#1}
  7. \end{wrapfigure}
  8.  
  9. \stepcounter{cntfig}} {}


New command
  1. \newcommand{\yfig}[1]{
  2.  
  3. \begin{wrapfigure}{r}{0.2\textwidth}
  4.  
  5. \begin{center}
  6.  
  7. \includegraphics[width=0.18\textwidth]{images/c\thechapter /\thecntfig}
  8.  
  9. \end{center}
  10.  
  11. \caption{#1}
  12.  
  13. \end{wrapfigure}}


Obviously in text they are called as
  1. \begin{yfifg} {acaption} \end{yfifg}
  2. and
  3. \fig{acaption}

respectively.


PS: (A simple question for not open a new topic) both environment and command may accept only one default value?

Tags:

Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 4 guests