将箭头安装到正确的位置

将箭头安装到正确的位置

我无法让箭头直接适合正确的位置。箭头移位了,没有处于正确的位置。

\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}

在此处输入图片描述

答案1

我不确定这是否是您想要的,但我建议使用 tikz 矩阵,而matrix of math nodes不是tikzmark使用tabular

在此处输入图片描述

\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}

答案2

Sandy G 的回答很好但不完整(例如元素 4/1 没有被箭头触及......)我无法添加这样的评论:

\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}

输出:

在此处输入图片描述

相关内容