# [Tex/LaTex] How to force a picture’s location and still use overpic

graphicsmemoirpositioning

I want to insert a picture, and use overpic to label it, in between two paragraphs of text, like so:

Here is my first paragraph of text.
\begin{figure}[htb] \centering
\begin{overpic}[width=0.5\textwidth]{./figure/mypicture.pdf}
\put(20, 20){$A$}
\end{overpic}
\caption{This is mypicture.pdf, with the label $A$.}
\end{figure}
Here is my second paragraph of text.
In order to understand this paragraph, you first need to see the picture.


But depending on the content of those paragraphs, and on other pictures that are inserted before or after them, mypicture.pdf doesn't always end up in the right place. Is there a way to force it to be there (as in \includegraphic), while still being able to use overpic?

You can use simply a center environment instead of the floating figure environment; if a caption is required, you can use \captionof from the caption or capt-of packages:

\documentclass{book}
\usepackage{graphicx}
\usepackage{overpic}
\usepackage{caption}

\begin{document}

Here is my first paragraph of text.
\begin{center}
\begin{overpic}[width=0.5\textwidth]{./figure/mypicture.pdf}
\put(20, 20){$A$}
\end{overpic}
\captionof{figure}{This is mypicture.pdf, with the label $A$.}
\end{center}
Here is my second paragraph of text.
In order to understand this paragraph, you first need to see the picture.

\end{document}


If the memoir document class is used, then there's no need to use additional packages to produce the caption outside a floating environment, since the class has a built-in mechanism (the \newfixedcaption command) to this effect:

\documentclass{memoir}
\usepackage{graphicx}
\usepackage{overpic}

% we declare a new type of caption for captioning images outside
% the figure environment,
\newfixedcaption{\figcaption}{figure}

\begin{document}

Here is my first paragraph of text.
\begin{center}
\begin{overpic}[width=0.5\textwidth]{./figure/mypicture.pdf}
\put(20, 20){$A$}
\end{overpic}
\figcaption{This is mypicture.pdf, with the label $A$.}
\end{center}
Here is my second paragraph of text.
In order to understand this paragraph, you first need to see the picture.

\end{document}