[texhax] keyval options in the closing part of an environment

José Romildo Malaquias j.romildo at gmail.com
Mon Apr 26 03:01:12 CEST 2010


I want to define a new environment using an environment from the
fancyvrb.

In order to simplify the problem, let's consider the following LaTeX
document, which demonstrates the original problem:

  \documentclass[a4paper]{article}
  \usepackage{graphicx}

  \newenvironment{env}[1][]
   {\gdef\temp{#1}
    \begin{quote}}
   {\includegraphics[\temp]{/usr/share/pixmaps/xchat.png}
    \end{quote}}


  \begin{document}

  \begin{env}[width=3cm]
    This is a test.
  \end{env}

  \end{document}

The problem is the use of the options in the closing part of the
environment. Here I want to use the \includegraphics command with the
options passed to the env environment.

pdflatex fails with the error:

  ! Package keyval Error: width=3cm undefined.

  See the keyval package documentation for explanation.
  Type  H <return>  for immediate help.
   ...                                              
                                                    
  l.15 \end{env}

How can I solve this problem? Any hints?

Regards,

Romildo


More information about the texhax mailing list