6

I need to fake a caption under an image, since you can't use figure/caption inside tabular/longtable environments (afaik). The data inside the table are generated dynamically so I don't know the height of the image from time to time. I know the width though.

So, to fake the caption I use a parbox inside a table cell to encapsulate the image and caption.

Finally, the problem: I need more padding in the top of the cell. In the following minimal example the rule clamps to the top of the cell with no padding at all.

\documentclass[10pt,a4paper]{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{| p{105 mm} |}
\hline
HEADER \\
\hline
\parbox[t]{10cm}{
\rule{100mm}{50mm}
Fake caption
\strut}\\
\hline
\end{longtable}
\end{document}

Possible solutions include removing parbox and use something else. The important part here is that I want to fake the caption under the image and I need it to be in an tabular environment.

Edit1: Added vertical borders to the example code.

  • I have added a solution. :-) – user11232 Nov 28 '13 at 9:52
6

You can add \vspace{.5\baselineskip} soon after \parbox[t]{10cm}{. Adjust .5\baselineskip suitably.

\documentclass[10pt,a4paper]{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{| p{105 mm} |}
\hline
HEADER \\
\hline
\parbox[t]{10cm}{
\vspace{.5\baselineskip}  %% this line added
\rule{100mm}{50mm}
Fake caption
\strut}\\
\hline
\end{longtable}
\end{document} 

enter image description here

1

You can add the vertical space manually. For instance:

\documentclass[10pt,a4paper]{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{| p{105 mm} |}
\hline
HEADER \\
\hline\\[-5pt]
\parbox[t]{10cm}{
\rule{100mm}{50mm}
Fake caption
\strut}\\
\hline
\end{longtable}
\end{document}

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.