Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

argument in end-part of newenvironment

6 views
Skip to first unread message

Francisco Canedo

unread,
Apr 13, 2001, 2:13:04 PM4/13/01
to
Hi y'all,

I'm trying to make a new environment that uses the verbatim environment
and puts a
line above and under it. The next environment accomplishes that:

\newenvironment{srclist}
{\hline\verbatim}
{\endverbatim
\hline}

Now I want to add a title at the end of this environment and I want to
be able to specify
this title as an argument to the environment command. Here are some
things I tried and
don't work:

% This doesn't work because you can't use the
% argument in the end-part
\newenvironment[1]{srclist}
{\hline\verbatim}
{\endverbatim
\hline #1}

% This doesn't work because LaTeX thinks '#1'
% is the argument to the new '\srctitle' command
% and we didn't specify any
\newenvironment[1]{srclist}
{\newcommand{\srctitle}{#1}\hline\verbatim}
{\endverbatim
\hline\srctitle}

Does anyone have any idea on how to do something like this?

TIA,

Francisco

PS: I'll be monitoring the group but replies to my e-mail are
appreciated.
Don't use the address in the sender/reply to, use this: fcanedo at
mediaport dot organisation

Donald Arseneau

unread,
Apr 14, 2001, 7:42:39 AM4/14/01
to
Francisco Canedo <can...@ano.ano> writes:

> % This doesn't work because LaTeX thinks '#1'
> % is the argument to the new '\srctitle' command
> % and we didn't specify any
> \newenvironment[1]{srclist}
> {\newcommand{\srctitle}{#1}\hline\verbatim}
> {\endverbatim
> \hline\srctitle}

Your statement about what LaTeX "thinks" is incorrect:
The #1 does refer to the environment parameter.

In fact, I expect this really does work.

What you have wrong is using \hline outside of a {tabular}.
Use a \rule command, or raw TeX \hrule (if you understand
the spacing issues).

Donald Arseneau as...@triumf.ca

Francisco Canedo

unread,
Apr 16, 2001, 5:24:17 PM4/16/01
to
Donald Arseneau wrote:

> Francisco Canedo <can...@ano.ano> writes:
>
> > % This doesn't work because LaTeX thinks '#1'
> > % is the argument to the new '\srctitle' command
> > % and we didn't specify any
> > \newenvironment[1]{srclist}
> > {\newcommand{\srctitle}{#1}\hline\verbatim}
> > {\endverbatim
> > \hline\srctitle}
>
> Your statement about what LaTeX "thinks" is incorrect:
> The #1 does refer to the environment parameter.
>
> In fact, I expect this really does work.

You're right! What I was doing wrong, was that I was trying to
use the environment without specifying an argument. Which was
the title that I so desperately wanted!!!!

Someone who replied directly to my e-mail pointed this out to me
after I sent him the rest of my code.

This makes me curious about something else though: What if I was
trying to use an argument for the command also?
i.e.:

\newenvironment{srclist}[1]
{\newcommand{\srctitle}[1]{#1}.......

Thanks for your info,

Francisco

Donald Arseneau

unread,
Apr 17, 2001, 4:07:08 AM4/17/01
to
Francisco Canedo <can...@ano.ano> writes:

> This makes me curious about something else though: What if I was
> trying to use an argument for the command also?
>

> \newenvironment{srclist}[1]
> {\newcommand{\srctitle}[1]{#1}.......


\newenvironment{srclist}[1]
{\newcommand{\srctitle}[1]{The #1 title is ##1}.......

Parameters get their # doubled for every level of nesting
within nested definitions. So ##1 is the parameter for
\srctitle and #1 is the parameter for srclist. A three-deep
definition would have a first parameter marked by ####1.

Donald Arseneau as...@triumf.ca

0 new messages