如何将文本放置在图像周围的任意位置?

如何将文本放置在图像周围的任意位置?

我想要得到如下的东西:

在此处输入图片描述

我在 Adob​​e Illustrator 中制作了矢量图。我也可以在其中制作标签 (X_3、X_2、..),但将它们导入 latex 后,它们与整个文档不一致。

所以我想知道我该怎么做。

我以为 Tikz 可以帮助我。但它会产生一个新区域,该区域应该位于图像下方,而不是图像附近,例如:(我不太熟悉它)

在此处输入图片描述

代码:

\documentclass[a4paper,10pt, reqno]{amsbook}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,trees}
\usepackage{graphicx}
\graphicspath{F:/(some path here)/pdfs/}
\begin{figure}[!htb]
\centering
\includegraphics[width=0.5\textwidth]{fig1c.pdf}
\caption{Body filled with fluid}
\label{fig:digraph}
\end{figure}
\begin{tikzpicture}

%\draw (0,0)--(5,-4);
node[pos=0,above] {$X_3$} 
\end{tikzpicture}
\end{document}

那么,有什么想法吗?

答案1

好吧,这是我指的完整代码。但我认为@cmhughes 是对的,如果你在 TikZ 中完成所有操作就好了。

\documentclass[a4paper,10pt, reqno]{amsbook}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,trees}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering  
\begin{tikzpicture}
    \node[anchor = south west, inner sep = 0] (image) at (0,0) {\includegraphics[width = 0.5\textwidth]{fig1c.pdf}};
    \begin{scope}[x = {(image.south east)}, y = {(image.north west)}]
        \draw (0,1) node [left] {$X_3$}; 
        \draw (0,0) node [below left] {${X_1}$};
        \draw (1,0) node [below] {$X_1$};
    \end{scope}
\end{tikzpicture}
\caption{Body filled with fluid} \label{fig:digraph}
\end{figure}
\end{document}

图像

答案2

如何重新绘制整个事物tikz

截屏

\documentclass[a4paper,10pt, reqno]{amsbook}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}

\begin{document}

\begin{figure}[!htb]
\centering
\begin{tikzpicture}[every node/.style={node distance=3cm},>=stealth]
% set up the nodes
\node[label=left:$X_1$,circle,fill=black] (X1) at (0,0){};
\node[right=of  X1,label=below:$X_2$](X2){};
\node[above=of X1,label=left:$X_3$](X3){};
% draw the arrows
\draw[->] (X1)--(X2);
\draw[->] (X1)--(X3);
% draw the rectangle
\draw (0,0) -- (0,2.5)--node[pos=0.5](topline){}(2.5,2.5)--(2.5,0);
% draw the horizontal lines
\draw ($(topline.south west)-(0.5,0)$)--($(topline.south east)+(0.5,0)$);
\draw ($(topline.south west)-(0.25,0.1)$)--($(topline.south east)+(0.25,-0.1)$);
% additional circle at X1
\draw (0,0) circle (7pt);
\end{tikzpicture}
\caption{Body filled with fluid}
\label{fig:digraph}
\end{figure}


\end{document}

相关内容