The following code produces the expected output seen below. (I use Overleaf with the 2022 LuaLaTeX engine.)
\documentclass{article}
%\usepackage[bidi=basic,provide=*,english,hebrew,layout=graphics]{babel}
%\babelfont{rm}[Renderer=HarfBuzz]{FreeSerif}
\usepackage{adjustbox}
\usepackage{tabularray}
\usepackage{tikz}
\usetikzlibrary{calc}
\NewDocumentCommand{\points}{}{%
\draw (0,0) node [circle,fill=red,label={[label distance=.5cm]-90:$r$}] (r1) {}
(1,0) node [circle,fill=red,label={[label distance=.5cm]-90:$r'$}] (r2) {}
(2,0) node [circle,fill=blue,label={[label distance=.5cm]-90:$b'$}] (b1) {}
(3,0) node [circle,fill=blue,label={[label distance=.5cm]-90:$b$}] (b2) {};
}
\NewDocumentCommand{\colsinnersep}{}{2cm}
\begin{document}
\begin{adjustbox}{center}
\begin{tblr}{cells={halign=c,valign=m},row{1}={belowsep={.5cm}},column{1}={rightsep={\colsinnersep}},column{2}={leftsep={\colsinnersep}}}
Before
&
After
\\
\begin{tikzpicture}[baseline=0]
\points;
\draw[very thick] (r1) |- ($(b1)+(0,.5)$) -- (b1);
\draw[very thick] (r2) |- ($(b2)+(0,-.5)$) -- (b2);
\end{tikzpicture}
&
\begin{tikzpicture}[baseline=0]
\points;
\draw[very thick] (r1) |- ($(b2)+(0,.5)$) -- (b2);
\draw[very thick] (r2) |- ($(b1)+(0,-.5)$) -- (b1);
\end{tikzpicture}
\end{tblr}
\end{adjustbox}
\end{document}
However, when the two commented-out lines are uncommented thus making the document's main language Hebrew, the following incorrect output is produced.
Note that the problem is not that table's original left and right columns have switched places. This is correct behavior, since Hebrew is a right-to-left language. The problem is that the pictures are no longer centered in the columns, and the colored nodes are not aligned with their labels. Another problem is that the nodes' labels are written from right to left.
Why has this happened? How can it be fixed?



babel. just copy the relevant files to your project. I thinkbabel.sty,luababel.defandbabel-bidi-basic.luashould be enough for this example. – Udi Fogiel May 01 '23 at 08:55