This is a follow up question to my earlier question here (Thanks to @Gonzalo for nice answer). I want to make the same table with boxes in article documentclass. My MWE
\documentclass{article}
\usepackage{booktabs}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usepackage[english]{babel}
\usepackage{blindtext}
\newcommand\FramedBox[3][]{%
\draw[red!80!black,rounded corners,#1]
([xshift=-1ex,yshift=3ex]pic cs:#2)
rectangle
([xshift=1ex,yshift=-1ex]pic cs:#3);
}
\begin{document}
\blindtext
\begin{table}[ph]
\protect\caption{Genotype-by-Environment Means}
\centering{}%
\begin{tabular}{l|cccccc|c}
\hline
& \multicolumn{6}{c|}{Environment} & \tabularnewline
\cline{2-7}
Genotype & $1$ & $2$ & $\ldots$ & $j$ & $\ldots$ & $e$ & Mean\tabularnewline
\hline
$1$ & $\overline{Y}_{11.}$ & $\overline{Y}_{12.}$ & $\ldots$ & $\overline{Y}_{1j.}$ & $\ldots$ & $\overline{Y}_{1e.}$ & $\overline{Y}_{1..}$\tabularnewline
$2$ & $\overline{Y}_{21.}$ & $\overline{Y}_{22.}$ & $\ldots$ & $\overline{Y}_{2j.}$ & $\ldots$ & $\overline{Y}_{2e.}$ & $\overline{Y}_{2..}$\tabularnewline
$\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\vdots$\tabularnewline
$i$ & $\overline{Y}_{i1.}$ & $\overline{Y}_{i2.}$ & $\ldots$ & $\overline{Y}_{ij.}$ & $\ldots$ & $\overline{Y}_{ie.}$ & $\overline{Y}_{i..}$\tabularnewline
$\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\vdots$\tabularnewline
$g$ & $\overline{Y}_{g1.}$ & $\overline{Y}_{g2.}$ & $\ldots$ & $\overline{Y}_{gj.}$ & $\ldots$ & $\overline{Y}_{ge.}$ & $\overline{Y}_{g..}$\tabularnewline
\hline
Mean & $\overline{Y}_{.1.}$ & $\overline{Y}_{.2.}$ & $\ldots$ & $\overline{Y}_{.j.}$ & $\ldots$ & $\overline{Y}_{.e.}$ & $\overline{Y}_{...}$\tabularnewline
\hline
\end{tabular}
\end{table}
\Blindtext
\begin{tikzpicture}[remember picture,overlay]
\FramedBox{starta}{enda}
\FramedBox{startc}{endc}
\FramedBox[draw=cyan]{startb}{endb}
\end{tikzpicture}
\begin{table}
\caption{Genotype-by-Environment Means}
\centering{}%
\begin{tabular}{lccccccc}
\toprule
& \multicolumn{6}{c}{Environment} &
\tabularnewline
\cmidrule{2-7}
Genotype & $1$ & $2$ & $\ldots$ & $j$ & $\ldots$ & $e$ & Mean
\tabularnewline
\midrule
$1$ & $\overline{Y}_{11.}$ & $\overline{Y}_{12.}$ & $\ldots$
& \tikzmark{startb}$\overline{Y}_{1j.}$ & $\ldots$ & $\overline{Y}_{1e.}$ & $\overline{Y}_{1..}$
\tabularnewline
$2$ & $\overline{Y}_{21.}$ & $\overline{Y}_{22.}$ & $\ldots$
& $\overline{Y}_{2j.}$ & $\ldots$ & $\overline{Y}_{2e.}$ & $\overline{Y}_{2..}$
\tabularnewline
$\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\ddots$
& $\vdots$ & $\vdots$
\tabularnewline
$i$ & \tikzmark{starta}$\overline{Y}_{i1.}$ & $\overline{Y}_{i2.}$
& $\ldots$ & $\overline{Y}_{ij.}$ & $\ldots$ & $\overline{Y}_{ie.}$
& $\overline{Y}_{i..}$ \tikzmark{enda}
\tabularnewline
$\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\ddots$
& $\vdots$ & $\vdots$
\tabularnewline
$g$ & $\overline{Y}_{g1.}$ & $\overline{Y}_{g2.}$ & $\ldots$
& $\overline{Y}_{gj.}$ & $\ldots$ & $\overline{Y}_{ge.}$ & $\overline{Y}_{g..}$
\tabularnewline
\midrule
Mean & $\overline{Y}_{.1.}$ & \tikzmark{startc}$\overline{Y}_{.2.}$\tikzmark{endc} & $\ldots$
& $\overline{Y}_{.j.}$\tikzmark{endb} & $\ldots$ & $\overline{Y}_{.e.}$ & $\overline{Y}_{...}$
\tabularnewline
\bottomrule
\end{tabular}
\end{table}
\blindtext
\Blindtext
\end{document}
It works fine. But if I export this to LyX then I have problems. In LyX Version 2.1.0beta2 even after multiple compilations, node positions are wrong. See attached figure. 
Any idea to do this in LyX. Thanks
Edited
Using @Gonzalo code, every thing works fine but after exporting to LyX I'm getting the following output with problems with node positions.

