\newenvironment - Tex Command


Advertisements

newenvironment

\newenvironment - Used to create your own environments.

SYNOPSIS

{ \newenvironment{myEnvironmentName}
  [ <optional # of arguments, from 1 to 9> ]
  { <replacement text for each occurrence of \begin{myEnvironmentName}> }
  { <replacement text for each occurrence of \end{myEnvironmentName}> }}

DESCRIPTION

\newenvironment command is used for defining your own environment. \newenvironment must appear (within math delimiters) before it is used. The bracketed # of arguments is omitted when there are no arguments. There must not be a command having the same name as the environment.

EXAMPLE

  1. \newenvironment{myHeartEnv}
      {\color{purple}{\heartsuit}\kern-2.5pt\color{green}{\heartsuit}}
      {\text{ forever}}
    
    \begin{myHeartEnv}
    \end{myHeartEnv}
    
    $ \newenvironment{myHeartEnv} {\color{purple}{\heartsuit}\kern-2.5pt\color{green}{\heartsuit}} {\text{ forever}} \begin{myHeartEnv} \end{myHeartEnv} $
  2. \newenvironment{myHeartEnv}[2]
      {\color{#1}{\heartsuit}\kern-2.5pt\color{#2}{\heartsuit}}
      {\text{ forever}}
      
    \begin{myHeartEnv}{red}{blue}
    \end{myHeartEnv}
    
    $ \newenvironment{myHeartEnv}[2] {\color{#1}{\heartsuit}\kern-2.5pt\color{#2}{\heartsuit}} {\text{ forever}} \begin{myHeartEnv}{red}{blue} \end{myHeartEnv} $
Print