LyX - 在表格中突出显示结果

LyX - 在表格中突出显示结果

在 LyX 中,我使用此表作为 ERT 补充:

\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}

我怎样才能用一个框围住整Variable 1行,再用一个框围住两个结果Variable 1

答案1

带有突出显示的行和单元格的表格

此解决方案使用colortbl包。第一个示例中的间距不完美。在第二个示例中,使用 可以纠正此问题\mystrut。第二个示例还展示了其他想法,例如\textbf单元格中的换行符。

LaTeX 代码如下所示。对于 LyX,只需将标记的部分复制到 LyX 序言中(您可以设置默认颜色和规则宽度!)并根据这些示例编辑表格...

\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}\\
\midrule \midrule \addlinespace[0pt]
\coloredhline
\multicolumn{1}{|p{5cm}}{\mystrut{10pt}{0pt}Variable Variable Variable 1 (Variable) Variable} &17.122 &* &3.481 &\multicolumn{1}{l|}{*}\\
\rowcolor{lightgray}
\multicolumn{1}{|p{5cm}}{Variable Variable Variable 2 (Variable) Variable} & 76.48 &* &0.441 &\multicolumn{1}{l|}{*}\\
\coloredhline
\arrayrulecolor{black}\addlinespace[0pt]\midrule
\textbf{Variable Variable Variable 3 (Variable) Variable} & 117.132 & * & 9.216 &* \\
\bottomrule
\end{tabular}
\end{document}

相关内容