如何绘制线条并在图形上方放置文字?

如何绘制线条并在图形上方放置文字?

我正在尝试画这样的东西

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{subfig}
\usepackage{graphicx}

\usepackage{tikz}
\begin{document}

\begin{figure}
    \begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.18\textwidth,trim={0 50 0 0},clip]{example-image-a}};
    \includegraphics[width=0.18\textwidth]{example-image-a};
    \includegraphics[width=0.18\textwidth]{example-image-a};
    \includegraphics[width=0.18\textwidth]{example-image-a};
    \includegraphics[width=0.18\textwidth]{example-image-a};
    \draw (0,0) -- (4,0);
    \end{tikzpicture}
    \caption{Given the historical human and object motion}
    \label{fig:intro}
\end{figure}

\end{document}

但这就是我得到的

在此处输入图片描述

另一个图形去哪了?我该如何参考左边的图形画线?例如

\node[] (image) at (a=0,b=0) {\includegraphics[width=0.18\textwidth]{example-image-a}};
\draw (a,b) -- (a+10,b);

另外,为什么第一张图像没有被裁剪?

答案1

问题是,你将图形放在 tikz 图片中,但你实际上想将它们包裹在节点中。你可以使用 将它们自动放在彼此旁边chain。你可以使用这些节点的锚点来绘制线条。方便的是,链具有预定义的节点-begin-end

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{float}

\usepackage{tikz}% loads graphicx
\usetikzlibrary{chains}
\begin{document}

\begin{figure}
    \begin{tikzpicture}[start chain=g going right,node distance=1mm, 
        nodes={inner sep=0,on chain}]
    \node[anchor=south west] (image) at (0,0) {\includegraphics[width=0.18\textwidth,trim={0 50 0 0},clip]{example-image-a}};
    \node {\includegraphics[width=0.18\textwidth]{example-image-a}};
    \node {\includegraphics[width=0.18\textwidth]{example-image-a}};
    \node {\includegraphics[width=0.18\textwidth]{example-image-a}};
    \node {\includegraphics[width=0.18\textwidth]{example-image-a}};
    \draw (g-begin.south west|-g-end.south)+(-1mm,-1mm) -- ([xshift=1mm,yshift=-1mm]g-end.south east);
    \end{tikzpicture}
    \caption{Given the historical human and object motion}
    \label{fig:intro}
\end{figure}
\end{document}

在此处输入图片描述

相关内容