0

I cannot get the arrows to fit directly as in the correct positions. The arrows are displaced and are not in their correct locations.

\documentclass[a4paper]{article}\usepackage[dvipsnames]{xcolor}

\usepackage{tikz}
\usetikzlibrary{patterns, tikzmark}
\begin{document}
\renewcommand{\arraystretch}{1.5}% I've also increased this for esthetic reasons
    \setlength{\tabcolsep}{10pt}
\begin{tabular}{ccccc}
$1/1$ \tikzmark{a}& $2/1$ \tikzmark{b} & $3/1$ \tikzmark{c} & $4/1$ & \tikzmark{d} $\cdots$ \\
$1/2$ \tikzmark{e}& $2/2$ \tikzmark{f} & $3/2$ \tikzmark{g} & $4/2$ & \tikzmark{h} $\cdots$ \\
$1/3$ \tikzmark{i}& $2/3$ \tikzmark{j} & $3/3$ \tikzmark{k} & $4/3$ & \tikzmark{l} $\cdots$\\ 
$1/4$ \tikzmark{m}& $2/4$ \tikzmark{n} & $3/4$ \tikzmark{o} & $4/4$ & \tikzmark{p} $\cdots$
\end{tabular}
\begin{tikzpicture}[remember picture, overlay, >=stealth, shorten <=15pt, transform canvas={yshift=.25\baselineskip}]
\draw[->] ([yshift=.75pt]{pic cs:a}) -- ({pic cs:b});
\draw[->] ([yshift=.75pt]{pic cs:c}) -- ({pic cs:d});
\draw[->] ([yshift=.75pt]{pic cs:b}) -- ({pic cs:e});
\end{tikzpicture}
\end{document}

enter image description here

2 Answers 2

1

I'm not sure if this is what you want, but I would suggest using a tikz matrix with matrix of math nodes instead of using tikzmark in a tabular.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}[>=stealth]
\matrix(cantor)[matrix of math nodes, column sep=5mm, row sep=5mm]
{
    1/1 & 2/1 & 3/1 & 4/1 & \cdots \\
    1/2 & 2/2 & 3/2 & 4/2 & \cdots \\
    1/3 & 2/3 & 3/3 & 4/3 & \cdots \\
    1/4 & 2/4 & 3/4 & 4/4 & \cdots \\
};
\draw[->] (cantor-1-1)--(cantor-1-2);
\draw[->] (cantor-1-2)--(cantor-2-1);
\draw[->] (cantor-2-1)--(cantor-3-1);
\draw[->] (cantor-3-1)--(cantor-2-2);
\draw[->] (cantor-2-2)--(cantor-1-3);
\draw[->] (cantor-1-3)--(cantor-2-3);
\draw[->] (cantor-2-3)--(cantor-3-2);
\draw[->] (cantor-3-2)--(cantor-4-1);
\end{tikzpicture}
\end{document}
1
1

The answer of Sandy G is good but incomplete (for example the element 4/1 in not touched by arrows...) I cant add a comment like this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}[>=stealth]
\matrix(cantor)[matrix of math nodes, column sep=5mm, row sep=5mm]
{
    1/1 & 2/1 & 3/1 & 4/1 & 5/1 &\cdots \\
    1/2 & 2/2 & 3/2 & 4/2 & 5/2 &\cdots \\
    1/3 & 2/3 & 3/3 & 4/3 & 5/3 &\cdots \\
    1/4 & 2/4 & 3/4 & 4/4 & 5/4 &\cdots \\
    1/5 & 2/5 & 3/5 & 4/5 & 5/5 &\cdots \\
};
\draw[->] (cantor-1-1)--(cantor-2-1);
\draw[->] (cantor-2-1)--(cantor-1-2);
\draw[->] (cantor-1-2)--(cantor-1-3);
\draw[->] (cantor-1-3)--(cantor-2-2);
\draw[->] (cantor-2-2)--(cantor-3-1);
\draw[->] (cantor-3-1)--(cantor-4-1);
\draw[->] (cantor-4-1)--(cantor-3-2);
\draw[->] (cantor-3-2)--(cantor-2-3);
\draw[->] (cantor-2-3)--(cantor-1-4);
\draw[->] (cantor-1-4)--(cantor-1-5);
\draw[->] (cantor-1-5)--(cantor-2-4);
\draw[->] (cantor-2-4)--(cantor-3-3);
\draw[->] (cantor-3-3)--(cantor-4-2);
\draw[->] (cantor-4-2)--(cantor-5-1);
\end{tikzpicture}
\end{document}

Output:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.