Quiero ilustrar cómo agrupar ciertos términos en una tabla infinita. Hasta ahora he hecho esto:
También quiero agrupar a₂b₃ con a₃b₂ y hacer otro grupo para a₃b₃. Hasta ahora he hecho las líneas con extremos punteados basándome en otras respuestas de Tex Stack Exchange.aquíyaquí. El ejemplo anterior se realizó utilizando el siguiente código:
\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}
Sin embargo, al aplicar el dotted-ends
estilo a los 2 últimos grupos, al final se obtienen líneas discontinuas más cortas:
Intenté solucionar este problema reemplazándolo ($(\tikzinputsegmentfirst)!-.2!(\tikzinputsegmentlast)$)
con ($(\tikzinputsegmentfirst)!-1cm!(\tikzinputsegmentlast)$)
. Sin embargo, esto ha dado lugar a algunos errores y las líneas ahora tienen este aspecto:
¿Cómo puedo solucionar esto?