TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}

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 &* 


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

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

table with highlighted rows and cells

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...


%%% add following to LyX Preamble...

\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}
%%% ...until here


%%% 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
\multicolumn{1}{|l}{Variable Variable Variable 1 (Variable) Variable} &17.122 &* &3.481 &\multicolumn{1}{l|}{*}\\
Variable Variable Variable 2 (Variable) Variable & 76.48 &* &0.441 &* \\
\mystrut{12pt}{0pt}Variable Variable Variable 3 (Variable) Variable &\multicolumn{1}{|l}{117.132} &* &9.216 &\multicolumn{1}{l|}{*} \\


%%% as ERT in LyX: configure color and rulewidth of box
\begin{tabular}{@{\hskip\tabcolsep\hskip\arrayrulewidth}p{5cm} rlrl }
Table 2&\multicolumn{2}{c}{Model 1} &\multicolumn{2}{c@{}}{Model 2}\\
\midrule \midrule \addlinespace[0pt]
\multicolumn{1}{|p{5cm}}{\mystrut{10pt}{0pt}Variable Variable Variable 1 (Variable) Variable} &17.122 &* &3.481 &\multicolumn{1}{l|}{*}\\
\multicolumn{1}{|p{5cm}}{Variable Variable Variable 2 (Variable) Variable} & 76.48 &* &0.441 &\multicolumn{1}{l|}{*}\\
\textbf{Variable Variable Variable 3 (Variable) Variable} & 117.132 & * & 9.216 &* \\
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.