在定义某些东西时,这个必需的空参数是什么意思?

What does this required empty parameter mean, when defining something?

\newenvironment{nameOfEnvironment}[1][]%

有人可以解释空括号吗?

您应该考虑阅读 Is there a comprehensive and complete LaTeX reference?,在那里您可以找到有关各种 LaTeX2e 源的信息。

从技术上讲,\newenvironment{<cmd>}[<num>][<default>]{<beg-def>}{<end-def>}\newcommand 为基础,因此了解后者将有助于您了解前者。

针对您的情况,LaTeX2e for authors user guide 提及以下关于 \newcommand 的内容:

...the command:

\newcommand{<cmd>}[<num>][<default>]{<definition>}

defines <cmd> to be a command with <num> arguments, the first of which is optional and has default value <default>.

Note that there can only be one optional argument but, as before, there can be up to nine arguments in total.

所以,

\newenvironment{nameOfEnvironment}[1][]%
  {<beg-def>}
  {<end-def>}

定义了一个环境 nameOfEnvironment,它接受一个参数(作为 [1] 的结果)。此单个参数是一个可选参数(作为第二个 [] 的结果),如果未指定,则具有 empty 默认值。

您可以将其用作

\begin{nameOfEnvironment}
  <stuff>
\end{nameOfEnvironment}

\begin{nameOfEnvironment}[something]
  <stuff>
\end{nameOfEnvironment}

在前一种情况下,可选参数 #1 为空,而第二种情况的可选参数值为 something


以下解释摘自LaTeX: Structured documents for TeX (unofficial LaTeX reference manual):

13.5 \newenvironment & \renewenvironment

Synopses:

\newenvironment[*]{env}[nargs][default]{begdef}{enddef}
\renewenvironment[*]{env}[nargs]{begdef}{enddef}

These commands define or redefine an environment env, that is, \begin{env} ... \end{env}.

  • *
    The *-form of these commands requires that the arguments (not the contents of the environment) not contain multiple paragraphs of text.

  • env
    The name of the environment. For \newenvironment, env must not be an existing environment, and the command \env must be undefined. For \renewenvironment, env must be the name of an existing environment.

  • nargs
    An integer from 1 to 9 denoting the number of arguments of the newly-defined environment. The default is no arguments.

  • default
    If this is specified, the first argument is optional, and default gives the default value for that argument.

  • begdef
    The text expanded at every occurrence of \begin{env}; a construct of the form #n in begdef is replaced by the text of the nth argument.

  • enddef
    The text expanded at every occurrence of \end{env}. It may not contain any argument parameters.