I would like to reproduce a table in tikz with arrows from predefined cell to another predefined cell.
Something looks like this.
What I did was the following:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,matrix,positioning}
\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,text width=3em,align=center},
text depth=1.25ex,
text height=2.5ex,
nodes in empty cells
},
}
\begin{document}
\begin{tikzpicture}
% the matrix entries
\matrix (mat) [table]
{
& $x$ & $y$ & $z$ \\
$x$ & a & a & b \\
$y$ & b & a & c \\
$z$ & c & d & e \\
};
% the matrix rules
\foreach \x in {1,...,3}
{
\draw
([xshift=-.5\pgflinewidth]mat-\x-1.south west) --
([xshift=-.5\pgflinewidth]mat-\x-4.south east);
}
\foreach \x in {1,...,3}
{
\draw
([yshift=.5\pgflinewidth]mat-1-\x.north east) --
([yshift=.5\pgflinewidth]mat-4-\x.south east);
}
% the arrows
\begin{scope}[shorten >=7pt,shorten <= 7pt]
\draw[->] (mat-4-4.center) -- (mat-3-4.center);
\draw[->] ([shift={(2.5pt,3pt)}]mat-4-4.center) -- ([shift={(2.5pt,2.5pt)}]mat-2-4.center);
\draw[->] ([shift={(8pt,8pt)}]mat-2-4.center) -- ([shift={(8pt,8pt)}]mat-2-3.center);
\end{scope}
\end{tikzpicture}
\end{document}
But as you can see by reproducing the output of the above code, the arrows are note good in the sense that are not aligned.
Note: Some of the above code was found in this site but I can't remember exactly the link.
EDIT: Here is the output of my code:




\tikzmark. Perhaps Tabular integration by parts, How to draw arrows from cell to cell at the borders of a table, or Drawing vertical arrow to a table column can get you started. Summary: Label the specific locations with\tikzmarkand then draw the appropriate arrows on top. – Peter Grill Feb 22 '16 at 23:17