我想overpic
在两段文字之间插入一张图片并用它来标记它,如下所示:
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.
但是,根据这些段落的内容以及插入在它们之前或之后的其他图片,mypicture.pdf 并不总是出现在正确的位置。有没有办法强制它出现在那里(如\includegraphic
),同时仍然能够使用overpic
?
答案1
您可以简单地使用center
环境而不是浮动figure
环境;如果需要标题,您可以使用或\captionof
包:caption
capt-of
\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}
如果memoir
使用文档类,则无需使用额外的包在浮动环境之外生成标题,因为该类具有内置机制(命令\newfixedcaption
)来实现此效果:
\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}