4

When using tikz to draw lines with the remember picture argument, is there a way to set the coordinates based on the height or width of the picture? For example, in the code below

\draw [-stealth, ultra thick,] ($(image1.south)+(0,0)$)--($(bar1.west)+(1,0)$);

how can I set the +(1,0) to something like (0.2*bar1.width,0) if I want the line to end at 20% of bar1's width?

MWE

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{float}
\usepackage{subfig}
\usetikzlibrary{calc}
\usepackage{graphicx}
\begin{document}



\begin{figure*}
\centering
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}

\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image1) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-b}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}\hspace{-0.2em}
\subfloat{
\begin{tikzpicture}[remember picture]
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.15\textwidth,trim={0 0 0 0},clip]{example-image-a}};
\end{tikzpicture}}

\noindent\begin{tabular}{@{}rl}     
    True Left & 
    \begin{tikzpicture}[remember picture] 
        \node[anchor=south west,inner sep=0] (bar1) at (0,0) {\includegraphics[width=0.85\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}};
    \end{tikzpicture}\\
    Pred Left &\includegraphics[width=0.85\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}\\
    True Right &\includegraphics[width=0.85\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}\\
    Pred Right &\includegraphics[width=0.85\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}\\
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\begin{scope}
    \draw [-stealth, ultra thick,] ($(image1.south)+(0,0)$)--($(bar1.west)+(1,0)$);
    \end{scope}
\end{tikzpicture}
\caption{}
\label{fig:qualitative-mocap}
\end{figure*}

\end{document}

enter image description here

1

1 Answer 1

5

You could use the let syntax like this:

\draw
  let \p1=(bar1.west), \p2=(bar1.east), \n1={0.2*(\x2-\x1)} in
 [-stealth, ultra thick,] ($(image1.south)+(0,0)$)--($(bar1.west)+(\n1,0)$);

Or you could do this:

\draw  [-stealth, ultra thick,] ($(image1.south)+(0,0)$)--($(bar1.west)!0.2!(bar1.east)$);
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .