如何将文本“xyz”定位到 image1 的左上角?这是一个 MWE
\documentclass{article}
\usepackage{float}
\usepackage{subfig}
\usepackage{tikz}% loads graphicx
\usetikzlibrary{calc}
\begin{document}
\def\imagewidth{0.12\textwidth}
\begin{figure}[t!]
\centering
\subfloat{
\begin{tikzpicture}[remember picture]
\node[anchor=north west,inner sep=0] (image1) at (0,0) {\includegraphics[width=\imagewidth]{example-image-a}};
\end{tikzpicture}}
\subfloat{
\begin{tikzpicture}[remember picture]
\node[anchor=north west,inner sep=0] (image2) at (0,0) {\includegraphics[width=\imagewidth]{example-image-a}};
\end{tikzpicture}}
\subfloat{
\begin{tikzpicture}[remember picture]
\node[anchor=north west,inner sep=0] (image3) at (0,0) {\includegraphics[width=\imagewidth]{example-image-a}};
\end{tikzpicture}}
\subfloat{
\begin{tikzpicture}[remember picture]
\node[anchor=north west,inner sep=0] (image4) at (0,0) {\includegraphics[width=\imagewidth]{example-image-a}};
\end{tikzpicture}}
\subfloat{
\begin{tikzpicture}[remember picture]
\node[anchor=north west,inner sep=0] (image5) at (0,0) {\includegraphics[width=\imagewidth]{example-image-a}};
\end{tikzpicture}}
\subfloat{
\begin{tikzpicture}[remember picture]
\node[anchor=north west,inner sep=0] (image6) at (0,0) {\includegraphics[width=\imagewidth]{example-image-a}};
\end{tikzpicture}}
\subfloat{
\begin{tikzpicture}[remember picture]
\node[anchor=north west,inner sep=0] (image7) at (0,0) {\includegraphics[width=\imagewidth]{example-image-a}};
\end{tikzpicture}}
\subfloat{
\begin{tikzpicture}[remember picture]
\node[anchor=north west,inner sep=0] (image8) at (0,0) {\includegraphics[width=\imagewidth]{example-image-a}};
\end{tikzpicture}}
\begin{tikzpicture}[overlay,remember picture]
\begin{scope}
% max t = 246
% image1 t=0
\def\time1{0}
\draw let \p1=(image1.west), \p2=(image1.east), \n1={\time1*(\x2-\x1)} in [line width=0.5mm] ($(image1.north west)+(0,0.1)$)--($(image3.north east)+(\n1,0.1)$);
\begin{scope}[x={(image1.north west)},y={(image1.north west)}]
\node[anchor=south west,draw,fill=white] at (0,0) {xyz};
\end{scope}
\end{scope}
\end{tikzpicture}
\end{figure}
\end{document}
答案1
除非您想声明,否则subcaptions
我认为您不需要所有这些subfloat
。可以使用 来完成类似的事情matrix of nodes
。
\documentclass{article}
\usepackage{float}
\usepackage{subfig}
\usepackage{tikz}% loads graphicx
\usetikzlibrary{calc, matrix, positioning}
\begin{document}
\def\imagewidth{0.12\textwidth}
\begin{figure}
\begin{tikzpicture}
\matrix[matrix of nodes, column sep=3pt, nodes={anchor=center, inner sep=0pt}] (image){
\includegraphics[width=\imagewidth]{example-image-a} &
\includegraphics[width=\imagewidth]{example-image-a} &
\includegraphics[width=\imagewidth]{example-image-a} &
\includegraphics[width=\imagewidth]{example-image-a} &
\includegraphics[width=\imagewidth]{example-image-a} &
\includegraphics[width=\imagewidth]{example-image-a} &
\includegraphics[width=\imagewidth]{example-image-a} &
\includegraphics[width=\imagewidth]{example-image-a} \\};
\draw[line width=.5mm] ([yshift=1mm]image-1-1.north west) coordinate (aux)--([yshift=1mm]image-1-3.north east);
\node[above right=1mm and 0pt of aux, draw] {xyz};
\end{tikzpicture}
\end{figure}
\end{document}