[latexrefman-commits] r346 - in /trunk: ChangeLog latex2e.texi

jhefferon at domain.hid jhefferon at domain.hid
Wed May 27 21:06:33 CEST 2015


Author: jhefferon
Date: Wed May 27 21:06:32 2015
New Revision: 346

URL: http://svn.gna.org/viewcvs/latexrefman?rev=346&view=rev
Log:
\newenvironment

Modified:
    trunk/ChangeLog
    trunk/latex2e.texi

Modified: trunk/ChangeLog
URL: http://svn.gna.org/viewcvs/latexrefman/trunk/ChangeLog?rev=346&r1=345&r2=346&view=diff
==============================================================================
--- trunk/ChangeLog	(original)
+++ trunk/ChangeLog	Wed May 27 21:06:32 2015
@@ -1,3 +1,8 @@
+2015-05-27  Jim Hefferon  <jhefferon at domain.hid>
+
+	* latex2e.texi (\newcommand & \renewcommand): Copy recent edits to
+	\newcommand over to \newenvironment; make needed adjustments.
+
 2015-05-26  Jim Hefferon  <jhefferon at domain.hid>
 
 	* latex2e.texi (\newcommand & \renewcommand): Add two fine points

Modified: trunk/latex2e.texi
URL: http://svn.gna.org/viewcvs/latexrefman/trunk/latex2e.texi?rev=346&r1=345&r2=346&view=diff
==============================================================================
--- trunk/latex2e.texi	(original)
+++ trunk/latex2e.texi	Wed May 27 21:06:32 2015
@@ -3722,10 +3722,10 @@
 command, respectively.  Synopses:
 
 @example
-  \newcommand at domain.hid}@}
-  \newcommand*@{@var{cmd}@}[@var{nargs}][@var{optargval}]@{@var{defn}@}
-\renewcommand at domain.hid}@}
-\renewcommand*@{@var{cmd}@}[@var{nargs}][@var{optargval}]@{@var{defn}@}
+  \newcommand at domain.hid}@}
+  \newcommand*@{@var{cmd}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@}
+\renewcommand at domain.hid}@}
+\renewcommand*@{@var{cmd}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@}
 @end example
 
 The @code{*}-form of these two commands requires that the arguments
@@ -3746,21 +3746,21 @@
 command, the new version can have a different number of arguments than
 the old version.
 
- at domain.hid optargval
-Optional; if this argument is present then the first argument of
-defined command @var{\cmd} is optional, with default value
- at domain.hid} (which may be the empty string).  If this argument is not
-present, then @var{\cmd} does not take an optional argument.
+ at item optargdefault
+Optional; if this argument is present then the first argument of defined
+command @var{\cmd} is optional, with default value @var{optargdefault}
+(which may be the empty string).  If this argument is not present then
+ at var{\cmd} does not take an optional argument.
 
 That is, if @var{\cmd} is used with square brackets following, as in
 @code{\@var{cmd}[@var{myval}]}, then within @var{defn} @code{#1}
 expands @var{myval}.  While if @var{\cmd} is called without square
 brackets following, then within @var{defn} the @code{#1} expands to
-the default @var{optargval}.
+the default @var{optargdefault}.
 
 Omitting @code{[@var{myval}]} in the call is different from having the
 square brackets with no contents, as in @code{[]}.  The former results
-in @code{#1} expanding to @var{optargval}; the latter results in
+in @code{#1} expanding to @var{optargdefault}; the latter results in
 @code{#1} expanding to the empty string.
 
 @item defn
@@ -3770,6 +3770,14 @@
 
 @end table
 
+A command with no arguments that is followed in the source by a space
+will swallow that space.  The solution is to type @code{@{@}} after the
+command and before the space.
+
+The braces around @var{defn} do not delimit the scope of the result of
+expanding @var{defn}.  So @code{\newcommand at domain.hid #1@}}
+is wrong since in the sentence
+
 A simple example of defining a new command:
 @code{\newcommand at domain.hid Hef at domain.hid@}} causes the abbreviation
 @code{\JH} to be replaced by the longer text.
@@ -3800,14 +3808,6 @@
 Then, @code{\salutation} gives @samp{Dear Sir or Madam:} while
 @code{\salutation[John]} gives @samp{Dear John:}.  And
 @code{\salutation[]} gives @samp{Dear :}.
-
-A command with no arguments that is followed in the source by a space
-will swallow that space.  The solution is to type @code{@{@}} after the
-command and before the space.
-
-The braces around @var{defn} do not delimit the scope of the result of
-expanding @var{defn}.  So @code{\newcommand at domain.hid #1@}}
-is wrong since in the sentence
 
 @example
 The \shipname at domain.hid@} met the \shipname at domain.hid@}.
@@ -3887,47 +3887,114 @@
 @cindex defining new environments
 @cindex redefining environments
 
-Synopses:
-
- at domain.hid
-  \newenvironment[*]@{@var{env}@}[@var{nargs}][@var{default}]@{@var{begdef}@}@{@var{enddef}@}
-\renewenvironment[*]@{@var{env}@}[@var{nargs}]@{@var{begdef}@}@{@var{enddef}@}
- at domain.hid example
-
 These commands define or redefine an environment @var{env}, that is,
- at domain.hid}@} @dots{} \end at domain.hid}@}}.
+ at code{\begin at domain.hid}@} @dots{} \end at domain.hid}@}}.  Synopses:
+
+ at example
+  \newenvironment at domain.hid}@}
+  \newenvironment*@{@var{env}@}[@var{nargs}][@var{optargdefault}]@{@var{begdefn}@}@{@var{enddefn}@}
+\renewenvironment at domain.hid}@}
+\renewenvironment*@{@var{env}@}[@var{nargs}][@var{optargdefault}]@{@var{begdefn}@}@{@var{enddefn}@}
+ at end example
+
+Unlike @code{\newcommand} and @code{\renewcommand}, the starred forms
+ at code{\newenvironment*} and @code{\renewcommand*} have the same effect
+as the non-starred forms.
 
 @table @var
- at domain.hid @code{*}
- at domain.hid @code{*}-form of environment commands
-The @code{*}-form of these commands requires that the arguments (not
-the contents of the environment) not contain multiple paragraphs of
-text.
-
 @item env
-The name of the environment.  For @code{\newenvironment}, @var{env}
-must not be an existing environment, and the command @code{\@var{env}}
-must be undefined.  For @code{\renewenvironment}, @var{env} must be
-the name of an existing environment.
+Required; the environment name.  It does not begin with @code{\}.  It
+must not begin with the string @code{end}.  For @code{\newenvironment},
+the name @var{env} must not be the name of an already existing
+environment, and also the command @code{\@var{env}} must be undefined.
+For @code{\renewenvironment}, @var{env} must be the name of an existing
+environment.
 
 @item nargs
-An integer from 1 to 9 denoting the number of arguments of
-the newly-defined environment.  The default is no arguments.
-
- at domain.hid default
-If this is specified, the first argument is optional, and @var{default}
-gives the default value for that argument.
-
- at domain.hid begdef
-The text expanded at every occurrence of @code{\begin at domain.hid}@}}; a
-construct of the form @code{#@var{n}} in @var{begdef} is replaced by
-the text of the @var{n}th argument.
-
- at domain.hid enddef
-The text expanded at every occurrence of @code{\end at domain.hid}@}}.  It
-may not contain any argument parameters.
+Optional; an integer from 0 to 9 denoting the number of arguments of
+that the environment will take.  If this argument is not present, the
+default is for the environment to have no arguments.  When redefining an
+environment, the new version can have a different number of arguments
+than the old version.
+
+ at item optargdefault
+Optional; if this argument is present then the first argument of the
+defined environment is optional, with default value @var{optargdefault}
+(which may be the empty string).  If this argument is not present then
+the environment does not take an optional argument.
+
+That is, if @code{\begin at domain.hid}@}} is used with square brackets
+following, as in @code{\begin at domain.hid}]}, then within
+the enviroment @code{#1} expands @var{myval}.  If
+ at code{\begin at domain.hid}@}} is called without square brackets following,
+then within the environment the @code{#1} expands to the default
+ at var{optargdefault}.
+
+Omitting @code{[@var{myval}]} in the call is different from having the
+square brackets with no contents, as in @code{[]}.  The former results
+in @code{#1} expanding to @var{optargdefault}; the latter results in
+ at code{#1} expanding to the empty string.
+
+ at item begdefn
+Required; the text expanded at every occurrence of
+ at code{\begin at domain.hid}@}}; a construct of the form @code{#@var{n}} in
+ at var{begdef} is replaced by the text of the @var{n}th argument.
+
+ at item enddefn
+Required; the text expanded at every occurrence of
+ at code{\end at domain.hid}@}}.  Note that it may not contain any argument
+parameters, so @code{#@var{n}} cannot be used here.
 
 @end table
+
+The braces around @var{defn} do not delimit the scope of the result of
+expanding @var{defn}.
+
+This example gives an environment like @LaTeX{}'s @code{quotation} except that
+it will be set in smaller type.
+
+ at example
+\newenvironment at domain.hid@}@{%
+  \small\begin at domain.hid@}
+@}@{%
+  \end at domain.hid@}
+@}
+ at end example
+
+This shows the use of arguments; it gives a quotation environment that
+cites the author.
+
+ at example
+\newenvironment at domain.hid]@{%
+  \begin at domain.hid@}
+  \noindent\textit at domain.hid@}: 
+@}@{%
+  \end at domain.hid@}
+@}
+ at end example
+
+ at noindent The author's name is optional, and defaults to Shakespeare.
+In the document, use the environment as here:
+
+ at example
+\begin at domain.hid]
+  ..
+\end at domain.hid@}
+ at end example
+
+The final example shows how to save the value of an argument to use in 
+ at var{enddefn}.
+
+ at example
+\newsavebox at domain.hid@}
+\newenvironment at domain.hid]@{%
+  \sbox\quoteauthor at domain.hid@}%
+  \begin at domain.hid@} 
+@}@{%
+  \hspace at domain.hid plus 1fill at domain.hid@}
+  \end at domain.hid@}
+@}
+ at end example
 
 
 @node \newtheorem





More information about the latexrefman-commits mailing list