Tikz 计算距离修改器在矩阵中的旋转线上出错

Tikz 计算距离修改器在矩阵中的旋转线上出错

我想说明如何在无限表中将某些术语组合在一起。到目前为止,我已经做到了这一点:

在此处输入图片描述

我还想将 a₂b₃ 与 a₃b₂ 分组,并为 a₃b₃ 再创建一个组。到目前为止,我已经根据其他 Tex stack exchange 答案制作了带点端的线条这里这里。上面的例子是使用下面的代码完成的:

\documentclass{article}

\usepackage{etoolbox}
\usepackage{tikz} 
\usetikzlibrary{positioning, fit, matrix, decorations.pathreplacing, calc}

\tikzset{%
  rect/.style n args={4}{
        draw=none,
        rectangle,
        append after command={
            \pgfextra{%
                \pgfkeysgetvalue{/pgf/outer xsep}{\oxsep}
                \pgfkeysgetvalue{/pgf/outer ysep}{\oysep}
                \def\arg@one{#1}
                \def\arg@two{#2}
                \def\arg@three{#3}
                \def\arg@four{#4}
                \begin{pgfinterruptpath}
                    \ifx\\#1\\\else
                        \draw[draw,#1] ([xshift=-\oxsep,yshift=+\pgflinewidth]\tikzlastnode.south east) edge[decorate] ([xshift=-\oxsep,yshift=0\ifx\arg@two\@empty-\pgflinewidth\fi]\tikzlastnode.north east);
                    \fi\ifx\\#2\\\else
                        \draw[draw,#2] ([xshift=-\pgflinewidth,yshift=-\oysep]\tikzlastnode.north east) edge[decorate] ([xshift=0\ifx\arg@three\@empty+\pgflinewidth\fi,yshift=-\oysep]\tikzlastnode.north west);
                    \fi\ifx\\#3\\\else
                        \draw[draw,#3] ([xshift=\oxsep,yshift=0-\pgflinewidth]\tikzlastnode.north west) edge[decorate] ([xshift=\oxsep,yshift=0\ifx\arg@four\@empty+\pgflinewidth\fi]\tikzlastnode.south west);
                    \fi\ifx\\#4\\\else
                        \draw[draw,#4] ([xshift=0+\pgflinewidth,yshift=\oysep]\tikzlastnode.south west) edge[decorate] ([xshift=0\ifx\arg@one\@empty-\pgflinewidth\fi,yshift=\oysep]\tikzlastnode.south east);
                    \fi
                \end{pgfinterruptpath}
            }
        }
    },
    dotted ends/.style={
        decoration={
            show path construction,
            lineto code={
                \draw[dashed,#1] (\tikzinputsegmentfirst) --($(\tikzinputsegmentfirst)!-.2!(\tikzinputsegmentlast)$);,
                \draw (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);,
                \draw[dashed,#1] (\tikzinputsegmentlast) -- ($(\tikzinputsegmentlast)!-.2!(\tikzinputsegmentfirst)$);,
            }
        },
        decorate
    },
}



\begin{document}

\begin{center}    
    \begin{tikzpicture}
        \matrix[
            matrix of nodes,
            inner sep=20pt,
            row sep=2mm,
            column sep=2mm,
            every node/.style={
                circle,
                inner sep=0pt,
                align=center,
                text width=3em,
                text height=0.8em,
                text depth=0.2em,
            }] (m) {
                $a_0b_0$ & $a_0b_1$ & $a_0b_2$ & $a_0b_3$ & $\cdots$ \\
                $a_1b_0$ & $a_1b_1$ & $a_1b_2$ & $a_1b_3$ & $\cdots$ \\
                $a_2b_0$ & $a_2b_1$ & $a_2b_2$ & $a_2b_3$ & $\cdots$ \\
                $a_3b_0$ & $a_3b_1$ & $a_3b_2$ & $a_3b_3$ & $\cdots$ \\
                $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ \\
            };
            \node[
                inner sep=0pt,
                draw=blue,
                thick,
                rounded corners=1.2em,
                rotate fit=-45,
                fit={(m-1-1) (m-1-1)}
            ] {};
            \node[
                inner sep=0pt,
                draw=blue,
                thick,
                rounded corners=1.2em,
                rotate fit=-45,
                fit={(m-1-2) (m-2-1)}
            ] {};
            \node[
                inner sep=0pt,
                draw=blue,
                thick,
                rounded corners=1.2em,
                rotate fit=-45,
                fit={(m-1-3) (m-3-1)}
            ] {};
            \node[
                inner sep=0pt,
                draw=blue,
                thick,
                rounded corners=1.2em,
                rotate fit=-45,
                fit={(m-1-4) (m-4-1)}
            ] {};
            \node[
                inner sep=0pt,
                rotate fit=-45,
                fit={(m-2-4) (m-4-2)},
                rect={thick, blue, dotted ends={thick}}{}{thick, blue, dotted ends={thick}}{}
            ] {};
    \end{tikzpicture}
\end{center}

\end{document}

但是,当将该dotted-ends样式应用于最后两组时,最终会得到更短的虚线:

在此处输入图片描述

我尝试通过替换($(\tikzinputsegmentfirst)!-.2!(\tikzinputsegmentlast)$)来修复此问题($(\tikzinputsegmentfirst)!-1cm!(\tikzinputsegmentlast)$)。然而,这导致了一些错误,现在这些行如下所示:

在此处输入图片描述

我该如何解决?

相关内容