[texhax] keyval options in the closing part of an environment
Heiko Oberdiek
heiko.oberdiek at googlemail.com
Mon Apr 26 03:38:51 CEST 2010
On Sun, Apr 25, 2010 at 10:01:12PM -0300, José Romildo Malaquias wrote:
> 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}}
\newenvironment*{env}[1][]{%
\def\envparam{#1}%
\begin{quote}%
}{%
\expandafter\includegraphics\expandafter
[\expandafter{\envparam}]{/usr/share/pixmaps/xchat.png}%
\end{quote}%
}
Package keyval looks for '=' and ','. Therefore these
syntax characters must not be hidden inside a macro.
(The additional curly braces have the purpose to prevent
syntax problems, if #1 contains ']'.)
Another possibility:
\newenvironment*{env}[1][]{%
\def\envgraphics{%
\includegraphics[{#1}]{/usr/share/pixmaps/xchat.png}%
}%
\begin{quote}%
}{%
\envgraphics
\end{quote}%
}
Yours sincerely
Heiko Oberdiek
More information about the texhax
mailing list