title: Adding an equation or formula to a figure caption in LaTeX
body: <p>I have a figure in LaTeX with a caption to which I need to add a formula (<code>equation*</code> or <code>displaymath</code> environments). For example:</p>
  
  <pre><code>\documentclass[12pt]{article}
  \begin{document}
  \begin{figure}[tbph]
      \begin{center}
          %...
      \end{center}
      \caption{As you can see
              \begin{displaymath}4 \ne 5\end{displaymath}
      }
      \label{fig:somefig}
  \end{figure}
  \end{document}
  </code></pre>
  
  <p>This makes pdflatex angry, though it will produce a PDF.</p>
  
  <pre><code>! Argument of \@caption has an extra }.
  &lt;inserted text&gt; 
                  \par 
  l.9    }
  </code></pre>
  
  <p>What's the right way to go about adding an equation to a figure caption?</p>
  
  <p><strong>NOTE</strong>: Please do not suggest simply using the <code>$ ... $</code> math environment;
  the equation shown is a <em>toy</em> example; my real equation is much more intricate.</p>
  
  <p><strong>See also</strong>:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/149479/adding-a-caption-to-an-equation-in-latex">Adding a caption to an equation in LaTeX</a> (the reverse of this question)</li>
  </ul>