![如何将文本放置在图像周围的任意位置?](https://linux22.com/image/258802/%E5%A6%82%E4%BD%95%E5%B0%86%E6%96%87%E6%9C%AC%E6%94%BE%E7%BD%AE%E5%9C%A8%E5%9B%BE%E5%83%8F%E5%91%A8%E5%9B%B4%E7%9A%84%E4%BB%BB%E6%84%8F%E4%BD%8D%E7%BD%AE%EF%BC%9F.png)
我想要得到如下的东西:
我在 Adobe 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}