[Tex/LaTex] How to include eqnarray in caption of figure

captionsequationsmath-mode

I want to write a set of equations in a caption of a figure. I implemented the answer of this question but it did not work out. The error I got is:

 ! Argument of \Hy@tempa has an extra }.

For example I want to write:

\begin{figure}
\includegraphics[scale=1]{test.pdf}
\caption{\leavevmode\\\begin{minipage}{\linewidth}
  \begin{align}
    a &= b \\ c &= d
  \end{align}
  \end{minipage}
}
\end{figure}

How can I do this? Thanks!

EDIT

I want to write a text, and then write the equations.
For example:

The equations are:
a = b 
c = d

Best Answer

You need to either \protect the minipage and the align or to use the optional argument for caption (which is a good idea if you are going to generate a list of figures to give an entry for the LoF without the equation); loading the caption package also gives you line breaks:

\documentclass{article}  
\usepackage{amsmath}
\usepackage{caption}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\centering
\includegraphics[width=4cm]{example-image-a}
\caption{Some explanatory text goes here\\\protect\begin{minipage}{\linewidth}\protect\begin{align}
    a &= b \\ c &= d
  \protect\end{align}\protect\end{minipage}}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=4cm]{example-image-a}
\caption[text for the LoF]{Some explanatory text goes here\\\begin{minipage}{\linewidth}\begin{align}
    a &= b \\ c &= d
  \end{align}\end{minipage}}
\end{figure}

\end{document}

enter image description here

Related Question