# LyX - Highlight a result in table

In LyX I am using this table as an ERT addition:

\begin{tabular}{l rlrl }

& \multicolumn{2}{c}{Model 1}
& \multicolumn{2}{c@{}}{Model 2}
\midrule
\midrule

Variable Variable Variable 1 (Variable) Variable & 17.122 & * &   3.481 &*
Variable Variable Variable 2 (Variable) Variable & 76.48 & * &   0.441 &*
Variable Variable Variable 3 (Variable) Variable & 117.132 & * &   9.216 &*

\end{tabular}


How can I put a box around the entire Variable 1 row and a box just around the two results for Variable 1

-
You could perhaps adapt Caramdir's solution to Highlighting table cells – Torbjørn T. Mar 19 '13 at 16:01

This solution uses the colortbl package. The spacing in the first example is not perfect. In the second example this is corrected by using \mystrut. The second example shows also other ideas like \textbf and line breaking in a cell are shown.

The LaTeX code is shown below. For LyX, just copy the marked part to the LyX Preamble (you can set a default color and rule width!) and edit your table according to these examples...

\documentclass{article}
\usepackage{booktabs}

%%% add following to LyX Preamble...
\usepackage{xcolor}
\usepackage{array}
\usepackage{colortbl}

\newcommand{\highlightcolor}{red}  %set default color of the box
\setlength\arrayrulewidth{3pt}     %set default rule width of the box
\newcommand{\mystrut}[2]{\vrule height #1 depth #2 width 0pt}
\newcommand{\coloredhline}{\arrayrulecolor{\highlightcolor}\hline}
%%% ...until here

\begin{document}
\centering

%%% as ERT in LyX
\begin{tabular}{@{\hskip\tabcolsep\hskip\arrayrulewidth}l rlrl }
Table 1&\multicolumn{2}{c}{Model 1} &\multicolumn{2}{c@{}}{Model 2}\\
\midrule \midrule
\coloredhline
\multicolumn{1}{|l}{Variable Variable Variable 1 (Variable) Variable} &17.122 &* &3.481 &\multicolumn{1}{l|}{*}\\
\coloredhline
Variable Variable Variable 2 (Variable) Variable & 76.48 &* &0.441 &* \\
\cline{2-5}
\mystrut{12pt}{0pt}Variable Variable Variable 3 (Variable) Variable &\multicolumn{1}{|l}{117.132} &* &9.216 &\multicolumn{1}{l|}{*} \\
\cline{2-5}
\arrayrulecolor{black}\bottomrule
\end{tabular}

\bigskip

%%% as ERT in LyX: configure color and rulewidth of box
\renewcommand{\highlightcolor}{blue}
\setlength\arrayrulewidth{5pt}
\begin{tabular}{@{\hskip\tabcolsep\hskip\arrayrulewidth}p{5cm} rlrl }
Table 2&\multicolumn{2}{c}{Model 1} &\multicolumn{2}{c@{}}{Model 2}\\