I'm using tikz matrix to put some data on a grid. However depending on the height of what's in each node the edge linking two nodes are slightly slanted making an ugly effect of wavy line. How can I have those line straight ?
Here is an example of code generating the effect
\documentclass[a4paper]{amsart}
\usepackage{amsmath, amsfonts, amssymb, amsthm, wasysym}
\usepackage{pgfkeys}
% tikz environnement
\usepackage{tikz}
\usetikzlibrary{trees, snakes, shapes, arrows, arrows.meta, matrix, calc, graphs,
plotmarks, backgrounds, decorations.markings}
\begin{document}
[
\begin{tikzpicture}[ultra thick,
column sep={1.5cm,between origins}, row sep={1.0cm,between origins}]
\matrix (M) [matrix of math nodes, nodes={inner sep=1pt}] {
U_1 & \cdots & U_{i-1} & U_{i-1} \cup {i} & U_{i-1}^\sharp &
U_{i}^\sharp & \cdots & U_{N} \
};
\foreach \n in {1,2,...,7} {
\draw[thin] (M-1-\n.east) -- (M-1-\the\numexpr \n + 1\relax.west);
}
\end{tikzpicture}
]
\end{document}
I tried to fix the height of the node but it doesn't work. I also tried a trick such as tikz matrix arrow from empty nodes is not horizontal should do the work, but if possible, I would like to avoid inserting by hand some phantom text in front of each node (moreover such a text add some horizontal spacing).


matrix of nodesfixes anchor nodes tobase, you have to hange them tocenter:nodes={inner sep=1pt, anchor=center}– Ignasi Aug 08 '23 at 15:47\mathstrutwould probably be enough. And you can useexecute at begin node=\mathstrutto let TikZ do it automatically for you. For more complex nodes you can use node families so that TikZ chooses the right maximum height and depth for all nodes. Though, the best solution would be to use theasymmetric rectangleshape from TikZ-CD. This is exactly why the shape exists. (It sets the west/center/east anchor a fixed but variable distance from the baseline.) – Qrrbrbirlbel Aug 08 '23 at 16:01([yshift=.5ex]M-1-\n.base east) -- ([yshift=.5ex]M-1-\the\numexpr \n + 1\relax.base west). – Qrrbrbirlbel Aug 09 '23 at 12:12