I need to put an image inside table. I can't use figure inside table. Will not work even if I add minipage.
But can add \includegraphics OK inside table. But now I am not able to use \caption any more. It looks like \caption{} only works with figure.
The question is, how to add caption, but without using figure? Here is MWE.
First the version that does not work
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{longtable}
\begin{document}
\begin{longtable}{p{2in}}
\begin{figure}
\includegraphics[width=0.3\textwidth]{example-image-a}
\caption{my caption}
\end{figure}
\end{longtable}
\end{document}
so removed figure. But like to use caption, or caption like thing
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{longtable}
\begin{document}
\begin{longtable}{p{2in}}
%\begin{figure}
\includegraphics[width=0.3\textwidth]{example-image-a}
\caption{my caption} %only when commenting this will it compile
%\end{figure}
\end{longtable}
\end{document}
The idea is to get something similar to what is obtained when using figure but without using figure, since figure can't be used inside tables.
Is there something that has same semantics as \caption but does not need figure to use?
What is the best way to do this? Please note I only use lualatex to compile.
TL 2020.
\begin{document}
\begin{longtable}{p{2in}}
\noindent \begin{minipage}{\columnwidth} \makeatletter \def@captype{figure} \makeatother \centering \includegraphics[width=0.3\textwidth]{example-image-a} \caption{Two figures}\label{Fig} \end{minipage} \end{longtable} \end{document}`
– Nasser May 23 '20 at 02:05captionpackage and use\captionof{figure}{...}. But even this requires some work, see https://tex.stackexchange.com/a/148646/194703. – May 23 '20 at 03:32