%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% ENVIRONMENTS
%
%

% definition
\NewDocumentEnvironment{definition}{ s o }{
  \IfBooleanTF {#1} {
    % if starred: with logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@def1}
        \noindent
    }{
      % if subtitle
      \begin{@def1}[#2]
        \noindent
    }
  }{
    % if not starred: without logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@def2}
        \noindent
    }{
      % if subtitle
      \begin{@def2}[#2]
        \noindent
    }
  }
}{
  \IfBooleanTF {#1} {
    \end{@def1}
  }{
    \end{@def2}
  }
}

% theoreme
\NewDocumentEnvironment{theoreme}{ s o }{
  \IfBooleanTF {#1} {
    % if starred: with logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@thm1}
        \noindent
    }{
      % if subtitle
      \begin{@thm1}[#2]
        \noindent
    }
  }{
    % if not starred: without logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@thm2}
        \noindent
    }{
      % if subtitle
      \begin{@thm2}[#2]
        \noindent
    }
  }
}{
  \IfBooleanTF {#1} {
    \end{@thm1}
  }{
    \end{@thm2}
  }
}

% propriete
\NewDocumentEnvironment{propriete}{ s o }{
  \IfBooleanTF {#1} {
    % if starred: with logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@ppt1}
        \noindent
    }{
      % if subtitle
      \begin{@ppt1}[#2]
        \noindent
    }
  }{
    % if not starred: without logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@ppt2}
        \noindent
    }{
      % if subtitle
      \begin{@ppt2}[#2]
        \noindent
    }
  }
}{
  \IfBooleanTF {#1} {
    \end{@ppt1}
  }{
    \end{@ppt2}
  }
}

% demonstration
\NewDocumentEnvironment{demonstration}{ s o }{
  \IfBooleanTF {#1} {
    % if starred: with logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@dem1}
        \noindent
    }{
      % if subtitle
      \begin{@dem1}[#2]
        \noindent
    }
  }{
    % if not starred: without logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@dem2}
        \noindent
    }{
      % if subtitle
      \begin{@dem2}[#2]
        \noindent
    }
  }
}{
  \IfBooleanTF {#1} {
    \end{@dem1}
  }{
    \end{@dem2}
  }
}

% vocabulaire
\NewDocumentEnvironment{vocabulaire}{ s o }{
  \IfBooleanTF {#1} {
    % if starred: with logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@voc1}
        \noindent
    }{
      % if subtitle
      \begin{@voc1}[#2]
        \noindent
    }
  }{
    % if not starred: without logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@voc2}
        \noindent
    }{
      % if subtitle
      \begin{@voc2}[#2]
        \noindent
    }
  }
}{
  \IfBooleanTF {#1} {
    \end{@voc1}
  }{
    \end{@voc2}
  }
}

% citation
\NewDocumentEnvironment{commentaire}{ o }{
    \IfNoValueTF {#1} {
      % if no subtitle
      \begin{@com}
        % \vspace{-.5cm}
        \noindent
    }{
      % if subtitle
      \begin{@com}[#1]
        \noindent
    }
}{
  \end{@com}
}

% remarque
\NewDocumentEnvironment{remarque}{ s o }{
  \IfBooleanTF {#1} {
    % if starred: without title
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@rmq2}
        % \vspace{-.3cm}
        \noindent
    }{
      % if subtitle
      \begin{@rmq2}[#2]
        % \vspace{-.3cm}
        \noindent
    }
  }{
    % if not starred: with title
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@rmq1}
        \vspace{-.5cm}
        \noindent
    }{
      % if subtitle
      \begin{@rmq1}[#2]
        \vspace{-.5cm}
        \noindent
    }
  }
}{
  \IfBooleanTF {#1} {
    \end{@rmq2}
  }{
    \end{@rmq1}
  }
}

% exemple
\NewDocumentEnvironment{exemple}{ s o }{
  \IfBooleanTF {#1} {
    % if starred: without title
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@exe2}
        \noindent
    }{
      % if subtitle
      \begin{@exe2}[#2]
        \noindent
    }
  }{
    % if not starred: with title
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@exe1}
        \noindent
    }{
      % if subtitle
      \begin{@exe1}[#2]
        \noindent
    }
  }
}{
  \IfBooleanTF {#1} {
    \end{@exe2}
  }{
    \end{@exe1}
  }
}

% application
\NewDocumentEnvironment{application}{ s o }{
  \IfBooleanTF {#1} {
    % if starred: without logo and title
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@app2}
        \noindent
    }{
      % if subtitle
      \begin{@app2}[#2]
        \noindent
    }
  }{
    % if not starred: with logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@app1}
        \noindent
    }{
      % if subtitle
      \begin{@app1}[#2]
        \noindent
    }
  }
}{
  \IfBooleanTF {#1} {
    \end{@app2}
  }{
    \end{@app1}
  }
}

% methode
\NewDocumentEnvironment{methode}{ s o }{
  \IfBooleanTF {#1} {
    % if starred: without logo and title
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@met2}
        \noindent
    }{
      % if subtitle
      \begin{@met2}[#2]
        \noindent
    }
  }{
    % if not starred: with logo
    \IfNoValueTF {#2} {
      % if no subtitle
      \begin{@met1}
        \noindent
    }{
      % if subtitle
      \begin{@met1}[#2]
        \noindent
    }
  }
}{
  \IfBooleanTF {#1} {
    \end{@met2}
  }{
    \end{@met1}
  }
}

% rappel
\NewDocumentEnvironment{rappel}{ o }{
  \IfNoValueTF {#1} {
    \begin{bclogo}[logo=\bclivre, noborder=true]{Rappel}
  }{
    \begin{bclogo}[logo=\bclivre, noborder=true]{#1}
  }
}{
  \end{bclogo}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
