[Tex/LaTex] Linebreak in overlaid figure text

graphicsline-breaking

As a simple example, consider this MWE:

\documentclass{memoir}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.4\columnwidth]{example-image}
    \put(-80,20){some text}
\end{figure}

\end{document}

resulting in

MWE_result

Primary question: How do I make a linebreak inside put such as some\\ text?

Secondary questions: What enables the put command? Is it something implicitly loaded with memoir or graphicx? Where do I find the documentation?

I know a similar output can be created using the overpic or tikz package, which apparently are not necessary for this MWE. Also, overpic does not allow for linebreaks either (at least not in the simple \\ way).

Best Answer

Replace "some text" with a \parbox. The \parbox will wrap automatically, or linebreaks \\ can be manually added.

\documentclass{memoir}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h]
    \centering
    \includegraphics[width=0.4\columnwidth]{example-image}
    \put(-80,20){\parbox{.5in}{some text}}
\end{figure}

\end{document}

enter image description here

Alternately, you could use the same approach with a \stackinset, which allows you to specify the inset as an offset from the picture's left, center, right (horizontally) or top, center, bottom (vertically):

\documentclass{memoir}
\usepackage{graphicx,stackengine}

\begin{document}

\begin{figure}[h]
    \centering
    \stackinset{c}{.2in}{c}{-.4in}{\parbox{.5in}{some text}}{
    \includegraphics[width=0.4\columnwidth]{example-image}}
\end{figure}

\end{document}

enter image description here

As to \put, it is part of LaTeX's native picture environment.