0

I have a figure consisting of three subfigures, but they are all contained within a single .png file. There's a blank space in the bottom-right portion of the figure, where I'd like the figure caption to appear. Is it possible to overlay the figure caption on top of the figure, like shown in the figure below? I tried using "overpic", with the MWE below, but it doesn't work as written.

enter image description here

\documentclass[]{article}%
    \usepackage{graphicx}
    \usepackage[demo,abs]{overpic}


\begin{document}

        \begin{figure}[!ht]
        \centering
  \begin{overpic}[width=\textwidth]{TEMP.png}
            \caption{Caption goes here}
        \end{overpic}
        \label{fig}
  \end{figure}

\end{document}
1
\documentclass{article}

\usepackage{graphicx}



\begin{document}

        \begin{figure}[!ht]
        \centering
        \includegraphics[width=\textwidth]{example-image-duck}

        \raisebox{4cm}[0pt][0pt]{%
        \hspace{4cm}%
        \parbox{5cm}{\caption{Caption goes here\label{fig}}}}


  \end{figure}

\end{document}

enter image description here

| improve this answer | |
0

Picture mode! overmypicture is a wrapper around picture that sets up the \unitlength to the width of the reference content (which is the mandatory argument of the environment). The reference content is placed at the coordinates (0,0). Coordinates are in multiples of the width of the reference content. The overall size matches the size of the reference content.

\documentclass{article}

\usepackage{picture}
\usepackage{graphicx}

\newsavebox\mysavebox

\newenvironment{overmypicture}[1]
  {%
    \savebox\mysavebox{#1}%
    \edef\myheight{\the\dimexpr\ht\mysavebox+\dp\mysavebox\relax}%
    \edef\mywidth{\the\wd\mysavebox}%
    \setlength\unitlength{\the\wd\mysavebox}%
    \begin{picture}(\unitlength,\myheight)
      \put(0,0){\unhbox\mysavebox}%
  }
  {%
    \end{picture}%
  }


\begin{document}

\begin{figure}[!ht]
\centering
\begin{overmypicture}{\includegraphics[width=\textwidth]{example-image-duck}}
  \put(.5,.2){\parbox{.45\textwidth}{\caption{Caption goes here\label{fig}}}}%
\end{overmypicture}
\end{figure}

\end{document}

enter image description here

| improve this answer | |

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