Generalwhy my newenvironment doesnot accept more than 1 parameters?

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

why my newenvironment doesnot accept more than 1 parameters?

Post by zell08v »

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.

Code: Select all

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

Re: why my newenvironment doesnot accept more than 1 parameters?

Post by zell08v »

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

why my newenvironment doesnot accept more than 1 parameters?

Post by gmedina »

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

Re: why my newenvironment doesnot accept more than 1 parameters?

Post by zell08v »

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

Re: why my newenvironment doesnot accept more than 1 parameters?

Post by josephwright »

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