# Equation environment in caption

Is it possible to put an equation environment in a table caption? Here is an outdated answer that does not compile for me with the code

\documentclass[12pt]{report}
\usepackage{caption}
\begin{document}
\begin{table}
\caption{
\begin{minipage}{\linewidth}
$$x=y$$
\end{minipage}
}
\end{table}
\end{document}


which gives the error

! Argument of \caption@ydblarg has an extra }.<inserted text>\par \end{minipage}} ! Paragraph ended before \caption@ydblarg was complete.<to be read again>\par \end{minipage}}

• your document is missing \begin{document} @Hanmyo – Biki Teron May 19 '17 at 3:53
• @BikiTeron oops, it was in my code, sorry about that...added it in above – Hanmyo May 19 '17 at 4:19
• Is something stopping you from writing \caption{$\displaystyle x=y$}? – Mico May 19 '17 at 4:36

Keeping empty square brackets after \caption tag will solve the error:

\caption[]{
\begin{minipage}{\linewidth}
$$x=y$$
\end{minipage}
}

• Well, when I tried your code, it for some reason affects the equation counter (always results in the count being ''+1''), so implicitly affecting the overall equation counter. – Raaja May 19 '17 at 5:46

I think this might suit your need

Option: 1

\documentclass[12pt]{report}
\usepackage{caption}
\begin{document}
\begin{table}
\begin{center}
...
\captionsetup{singlelinecheck=off}
\caption[.]{
\begin{displaymath}
E=mc^2
\end{displaymath} That's a great invention}
\end{center}
\end{table}
\end{document}


to get

Option: 2

\documentclass[12pt]{report}
\usepackage{caption}
\begin{document}
\begin{table}
\begin{center}
...
\captionsetup{singlelinecheck=off}
\caption[.]{\label{q}
$$E = mc^2$$ That's great invention.}
\end{center}
\end{table}
\end{document}


to get as follows,

The advantage with this Option 2 is that you can even render the various equation environment by simply adding the amsmath package, and also get the equation numbering for free!!

As a last note, it is worth mentioning that you will see a [.] near the caption, that is just to make the code working.

• Don't use center within a table. It adds unwanted vertical spacing. Use the command \centering instead. – Bernard May 19 '17 at 8:46
• @Bernard Thanks for pointing out, I shall note that and will adopt my future answers :) – Raaja May 19 '17 at 9:04