Here's an idea.
The first column of the TikZ-matrix is the left side,
the second column is the right side of your diagram.
I'm using the width of a space which is accessible in PGFmath with width(" ") in multiple places:
- as the
column sep,
- as the
inner xsep and
- most importantly in the
s style.
This way, we can say s=2 and it will shift the node about two digits to the right. With the default value of 1, you can also simply say s, s to shift it about two digits.
Similarly to the second column, you could also insert fake \0 to pad the left side of a node.
The anchor=base west left-aligns all nodes.
In the second column, I'm using \hphantom{0} to pad the right side of the node so that line from the append after command is long enough.
You could also do node family={text width=\tikzmatrixname, text width align=left} with my ext.node-families library.
Or you draw these lines after the matrix has been constructed and use the right border of the matrix (which fits tightly against the right-most node of the second column, i.e.
(m-2-x.north west) |- (m-2-x.south-|m.east)
Depending on the dynamic of these diagrams, it could be interesting to employ tikz-cd and use \arrow[uuuu, <half arc>] instead.
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{
matrix,
calc,
}
\begin{document}
\begin{tikzpicture}[
s/.style={xshift=#1*width("0 ")},
s/.default=1, % shifts one digit to the right
m/.style={fill=orange!10, draw=orange!50},
]
\matrix[
matrix of nodes,
column sep=2*width(" "),
every outer matrix/.append style={inner sep=+0pt},
/utils/exec=\def\,{\rlap{,}}% % overwriting \, doesn't seem like a good idea
\def\0{\hphantom{0}},% but it is local to the \matrix
nodes={
anchor=base west, % left-aligned
inner xsep=.5*width(" ")
},
column 2/.append style={
nodes={
text depth=+0pt,% comma doesn't contribute to the node size,
% alternatively: \def\,{\smash{\rlap{,}}}
outer sep=+0pt, % anchors on the actual border, just to be safe
append after command={% draw west and south border of node
% overlay so that it doesn't contribute
% to the cell's size
(\tikzlastnode.north west) edge[
overlay, to path={|-(\tikzlastnode.south east)}]()}
}
},
] (m) {
|[m]| 1 0 & 1 1 \0 \\
1 0 0 & 0\, 9 0 \\
|[s, s ]| 1 \\
|[m,s=2]| 1 0 \\
};
\draw[m, fill=none]
let \p{angle}=($(m-4-1.south)-(m-1-1.west)$) in
(m-4-1.south) arc[% half arc between m-4-1.south and m-1-1.west
start angle={atan2(\y{angle},\x{angle})},
delta angle=-180,
radius=.5*veclen(\p{angle})];
\end{tikzpicture}
\end{document}
Output

xlopbut it looks like you needtikzmarkto draw a rectangle around two cells of atabular(possibly on thebackgroundor before thetabularis typeset) and then just an arc between those two nodes? You could also do it all in TikZ with a\matrixof nodes or just some well-placed nodes … – Qrrbrbirlbel Oct 23 '22 at 14:19TikZmatrix, it is ok for me. – projetmbc Oct 23 '22 at 14:23