4

I have the following longtable :

\begin{longtable}{|p{10cm}|}
    \hline
    some text

    \includegraphics[width=10cm,keepaspectratio]{\basedir some.png} 

    some text\\
    \hline
\end{longtable}

Is there a way to insert a caption and a label to a graphic inside a longtable?

Or

How can I insert a figure into a longtable cell?

I have been searching for a while but couldn't find any solution. Thanks in advance.

1
  • 1
    Please note that graphicx offers the \graphicspath macro, which does what you try with \basedir ;-) Furthermore always provide minimal working examples (MWE) illustration your problem – you may use the demo option of graphicx since no other have your image files. There’s also the mwe package, that comes with some example images …
    – Tobi
    Commented Dec 7, 2012 at 12:12

2 Answers 2

7

define

\makeatletter
\def\figcaption{%
    \refstepcounter{figure}%
     \@dblarg{\@caption{figure}}}
\makeatother

Then you can use

\figcaption{my caption}

where you have some text

1
  • That's what I was looking for, it really helped. Thank you so much...
    – Alper
    Commented Dec 7, 2012 at 12:12
0

David's wise answer guided me to the solution. I am just improving his answer but I lack reputation points to add a comment.

First, it works also for longtabu.

Second, we can also add a table caption with:

\makeatletter
\def\tabcaption{%
\refstepcounter{table}%
\@dblarg{\@caption{table}}}
\makeatother

Then use:

\tabcaption{my caption}

Third, I strongly believe that one has to use p{} columns to get it working. In longtabu, I was using X[] columns and it didn't work.

You must log in to answer this question.

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