1

I would like to put a frame/box around an image including some text which is below it. In addition I want to be able to add a caption afterwards.

So far I manage to put a box around the image, but I want that it encapsulates the text as well.

I want to achieve this:

Image + text encapsulated with a frame, and caption below it

But I only managed this (to put the text where I want it and put a frame around the image):

\documentclass[11pt, a4paper, oneside]{report}

\usepackage[left=4cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{ragged2e}

\begin{document}


\begin{figure}[!htb]
\centering
    \fbox{\includegraphics[width=\textwidth]{example.jpg}}
\justify \setstretch{0.75}{
\vspace{-1ex}\footnotesize Something long about the image which should be "part" of the image and bla-bla-bla. Maybe some more text so that it breaks the line sometime.}
    \caption{This is a caption of a Figure which includes an image and some text below it.}
\label{fig:employment}
\end{figure}

\end{document}

I've read that as images are floats and texts are not, it is kind of tricky to do something like this. Is there any way to manage to do it? To me, it doesn't seem like a very strange thing to want to do.

1 Answer 1

1

You can simply use a tabular.

\documentclass[11pt, a4paper, oneside]{report}

\usepackage[left=4cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{graphicx}

\begin{document}


\begin{figure}[!htb]
  \centering
  \fbox{%
    \begin{tabular}{p{0.8\textwidth}}
      \includegraphics[width=0.8\textwidth]{example-image}\\
      \footnotesize Something long about the image which should be "part" of the image and bla-bla-bla. Maybe some more text so that it breaks the line sometime.
    \end{tabular}}
  \caption{This is a caption of a Figure which includes an image and some text below it.}
  \label{fig:employment}
\end{figure}

\end{document}

enter image description here

3
  • Wow, thanks! Especially for using easy-to-understand coding for the solution :)
    – Miquel
    Commented Jun 10, 2020 at 5:05
  • Why do you comment after \fbox{%? Does it have a use?
    – Miquel
    Commented Jun 10, 2020 at 5:37
  • 2
    @Miquel This was kindly added by muzimuzhi Z. It avoids a spurious space. The original version \fbox{\begin{tabular}{p{0.8\textwidth}}... also does that. If you drop the % in the above, you will create an additional space, and hence an asymmetric padding.
    – user194703
    Commented Jun 10, 2020 at 5:40

You must log in to answer this question.

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