2

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

  • 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
  • 1
    Is something stopping you from writing \caption{$\displaystyle x=y$}? – Mico May 19 '17 at 4:36
2

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

\caption[]{
  \begin{minipage}{\linewidth}
     \begin{equation}
        x=y
     \end{equation}
  \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
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.