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}}

1
  • 1
    Is something stopping you from writing \caption{$\displaystyle x=y$}?
    – Mico
    May 19, 2017 at 4:36

2 Answers 2

7

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

\caption[]{
  \begin{minipage}{\linewidth}
     \begin{equation}
        x=y
     \end{equation}
  \end{minipage}
}
1
  • 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. May 19, 2017 at 5: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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .