5

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}
     \begin{equation}
        x=y
     \end{equation}
  \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}}

Hanmyo
  • 1,203

2 Answers2

7

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

\caption[]{
  \begin{minipage}{\linewidth}
     \begin{equation}
        x=y
     \end{equation}
  \end{minipage}
}
Morgoth
  • 233
MadyYuvi
  • 13,693
  • 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_is_at_topanswers.xyz May 19 '17 at 05:46
1

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

enter image description here

Option: 2

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

to get as follows,

enter image description here

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.