title: LaTeX Optional Arguments
body: <p>How do you create a command with optional arguments in LaTeX?
  Something like:</p>
  
  <pre><code>\newcommand{\sec}[2][]{
      \section*{#1
          \ifsecondargument
              and #2
          \fi}
      }
  }
  </code></pre>
  
  <p>Then, I can call it like</p>
  
  <pre><code>\sec{Hello}
  %Output: Hello
  \sec{Hello}{Hi}
  %Output: Hello and Hi
  </code></pre>