title: \newcommand / \newenvironment - optional parameters
body: <p>I'm experimenting with my own commands and environments and now I'm facing those problems:</p>
  
  <ol>
  <li>How to create command <code>\foo{parameter}[optional]</code> or environment called <code>\begin{bar}{parameter}[optional]</code>?</li>
  <li>How to create command <code>\foo[optional_1]...[optional_n]{parameter}</code></li>
  </ol>
  
  <p>I've tried</p>
  
  <pre><code>\newcommand{\foo}[3][][]{#1#2#3}    - failed
  \newcommand{\foo}[3][2][][]{#1#2#3} - failed
  </code></pre>
  
  <p>Does anyone know some hint? Thanks a lot.</p>