LaTeX forum ⇒ Generalwhy my newenvironment doesnot accept more than 1 parameters?

LaTeX specific issues not fitting into one of the other forums of this category.
zell08v
Posts: 3
Joined: Mon Aug 17, 2009 8:18 am

why my newenvironment doesnot accept more than 1 parameters?

Postby zell08v » Mon Aug 17, 2009 8:26 am

Hello everyone,

Here is my first question. I am a newbie and trying out the newenvironment.

The following newenvironment does not compile. Anyone can explain me why? Thanks a lot.

  1. \newenvironment{add_head_tail}[2]{Head of \emph{#1}}{Head of \emph{#2}}

Tags:

zell08v
Posts: 3
Joined: Mon Aug 17, 2009 8:18 am

Postby zell08v » Mon Aug 17, 2009 8:30 am

Sorry I had forgotten posting error messages:

ERROR: Illegal parameter number in definition of \endadd_head_tail.

--- TeX said ---
<to be read again>
2
l.10 ...}[2]{Head of \emph{#1}}{Head of \emph{#2}}

--- HELP ---
This is probably caused by a \newcommand, \renewcommand,
\newenvironment, or \renewenvironment command in which a # is used
incorrectly. A # character, except as part of the command name \#,
can be used only to indicate an argument parameter, as in #2, which
denotes the second argument. This error is also caused by nesting one
of the above four commands inside another, or by putting a parameter
like #2 in the last argument of a \newenvironment or \renewenvironment
command.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Postby gmedina » Mon Aug 17, 2009 8:43 am

Hi,

your second post answers the question asked in the first one:

... or by putting a parameter like #2 in the last argument of a \newenvironment or \renewenvironment command.


So, you cannot use parameters like #2 in the ending part of the definition of a new environment. Perhaps, if you describe what you expect to achieve with the environment that you want to define, we could give you some indications.
1,1,2,3,5,8,13,21,34,55,89,144,233,...

zell08v
Posts: 3
Joined: Mon Aug 17, 2009 8:18 am

Postby zell08v » Tue Aug 18, 2009 7:41 am

Thank you for your reply.

You are totally right. Latex doesnot permet the use of parameters in its ending part of definition. Maybe it's a designing issue who knows.

Thank you.

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Postby josephwright » Tue Aug 18, 2009 9:06 am

It is indeed a design issue (which is known about).
Joseph Wright


Return to “General”

Who is online

Users browsing this forum: No registered users and 4 guests