[Edit: improved syntax and illustrating how to to cope with different shapes, answering the OP's query in the comments..]
I agree with AboAmmar that tikz is a good approach. Here is a slightly shorter solution where the main difference is that it uses tikz to draw the tableau, resulting in a number of shortcuts. Here is the result of, first, drawing a tableau normally and, secondly, inserting this same code into a another tikzpicture
environment so that the blue lines can be drawn:

I have rewritten my original code so that it looks nicer and is easier to use. I have also added the third example above to show how to do a three-rowed tableau -- arbitrary shapes are fine.
The example code below defines a Tableau
environment for drawing a tableau and that then allows arbitrary tikz
code to appear after the tableau. There is also a "shortcut" macro \tableau
that draws an ordinary tableau without any additional decorations.
With both the Tableau
environment and \tableau
macro the entries of the tableau are specified as "comma separated lists" like `{{1,3,5,7,9},{2,4,8,10,11}}. This defines a two-rowed tableau with 1 3 5 7 9 in the first row and 2,4,8,10,11 in the second row. You can specify an arbitrary number of rows and columns with any reasonable entries this way.
Here is the full latex code:
\documentclass{article}
\usepackage{tikz}
\usepackage{xparse}
\newcount\tableauRow
\newcount\tableauCol
\def\tableauDim{0.4}
\newenvironment{Tableau}[1]{%
\tikzpicture[scale=0.4,draw/.append style={thick,black},
baseline=(current bounding box.center)]
% now draw the tableau
\tableauRow=-1.5
\foreach \Row in {#1} {
\tableauCol=0.5
\foreach\k in \Row {
\draw[thin](\the\tableauCol,\the\tableauRow)rectangle++(1,1);
\draw[thin](\the\tableauCol,\the\tableauRow)+(0.5,0.5)node{$\k$};
\global\advance\tableauCol by 1
}
\global\advance\tableauRow by -1
}
}{\endtikzpicture}
\newcommand\tableau[1]{\begin{Tableau}{#1}\end{Tableau}}
\begin{document}
\begin{tabular}{l@{\qquad}l@{\qquad}l}
\tableau{{1,3,5,7,9},{2,4,8,10,11}}
&
\begin{Tableau}{{1,3,5,7,9},{2,4,8,10,11}}
\draw[very thick,blue] (0,-2)--(2,-2)--(2,-1)--(3,-1)--(3,0)--(5,0);
\end{Tableau}
&
\begin{Tableau}{{1,5,7,9},{2,4,10,11},{3,8,14}}
\draw[very thick,blue](0,-3)--(2,-3)--(2,-2)--(3,-2)--(3,-1)--(4,-1)--(4,0);
\end{Tableau}
\end{tabular}
\end{document}
Btw, I have changed the code so that the boxes not sit on the "obvious" integer lattice points.
It's also easy to colour the boxes in this way and do many other things. I use these macros in my own papers -- although the trick of using an environment for decorating the tableaux is something that I only just thought of when editing this, so thanks:)
\documentclass{}
and ending with\end{document}
which includes the packages necessary for the code you posted. This is much more useful than a mere fragment.