内容被覆盖的问题很好解决,对合并单元格的最底部使用multirowcell命令,比如`\multirowcell{-2}{...}`
cline,hline会被之后的填充命令覆盖,引用colortbl中的原文:
```text
Lines produced by \cline are coloured if you use \arrayrulecolor but you may
not notice as they are covered up by any colour pannels in the following row. This
is a ‘feature’ of \cline. If using this package you would probably better using the
- rule type in a \hhline argument, rather than \cline
```
解决这个办法是用`hhline`宏包,但是会有一些小问题,比如合并单元格之间出现空白,需要在`\hhline`再将空白的地方填上,我自己写了个[脚本](https://github.com/ZhiyuanLck/excel2tex "脚本")解决,因为需要兼容很多东西,所以对简单的例子生成的代码比较繁琐,,结果如下
![](https://wenda.latexstudio.net/data/attach/200528/pWZbeGuK.png)
由于网页显示问题,下面代码中对应的网页代码应该是&,>
```tex
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{dashrule}
\usepackage{ehhline}
%% nested tabular
\newcommand{\minitab}[2][l]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
%% vertical line
% vertical colored line #1 color #2 width
\newcommand{\vsl}[2]{\color{#1}\vrule width #2}
% doubled vline
% #1 first color #2 first width #3 sep #4 second color #5 second sep
\newcommand{\dvsl}[5]{%
\vsl{#1}{#2}\hspace{#3}\vsl{#4}{#5}%
}
%% horizontal line
% colored solid line pattern
% #1 color #2 width #3 height
\newcommand{\hsp}[3]{\hbox{\textcolor{#1}{\rule{#2}{#3}}}}
% colored dash line pattern
% #1 color #2 width #3 height #4 style
\newcommand{\hdp}[4]{\hbox{\textcolor{#1}{\hdashrule{#2}{#3}{#4}}}}
% fill line
% #1 top fill #2 bottom fill
\newcommand{\leaderfill}[1]{%
\xleaders\hbox{%
\vbox{\baselineskip=0pt\lineskip=0pt#1}%
}\hfill%
}
% top: solid, bottom: solid
% #1 top color #2 top height #3 bottom color#4 bottom height
\newcommand{\ssfill}[4]{%
\leaderfill{\hsp{#1}{0.1pt}{#2}\hsp{#3}{0.1pt}{#4}}%
}
% top: solid, bottom: dashed
% #1 top color, #2 top height, #3 common width to expand
% #4 bottom color #5 bottom height, #6 bottom dash line style
\newcommand{\sdfill}[6]{%
\leaderfill{\hsp{#1}{#3}{#2}\hdp{#4}{#3}{#5}{#6}}%
}
% single solid
% #1 color #2 height
\newcommand{\sfill}[2]{%
\leaderfill{\hsp{#1}{0.1pt}{#2}}%
}
% single dash
% #1 color #2 width #3 height #4 style
\newcommand{\dfill}[4]{%
\leaderfill{\hdp{#1}{#2}{#3}{#4}}%
}
\definecolor{FFFF00}{HTML}{FFFF00}
\begin{document}
\begin{tabular}{*{5}{c}}
\hhline{
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
}
% row 1
\multicolumn{1}{!{\vsl{black}{0.4pt}}c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
& \multicolumn{2}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
\\
\hhline{
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0.4pt}}
!{\sfill{FFFF00}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0.4pt}}
>{\vsl{black}{0.4pt}}
}
% row 2
\multicolumn{1}{!{\vsl{black}{0.4pt}}c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
& \multicolumn{2}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
\\
\hhline{
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0pt}}
!{\sfill{FFFF00}{0pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0pt}}
>{\vsl{black}{0.4pt}}
}
% row 3
\multicolumn{1}{!{\vsl{black}{0.4pt}}c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
& \multicolumn{2}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}
\multirow{-3}*{\minitab[c]{\minitab[c]{Is this person \\interested \\in the news?}}}}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}}
\\
\hhline{
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{FFFF00}{0.4pt}}
>{\vsl{black}{0.4pt}}
}
% row 4
\multicolumn{1}{!{\vsl{black}{0.4pt}}c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}
\multirow{-4}*{}}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}Yes}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}No}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}
\multirow{-4}*{\minitab[c]{\minitab[c]{Where does he/she get \\most of the news \\(online, TV, etc.)?}}}}
& \multicolumn{1}{c!{\vsl{black}{0.4pt}}}{\cellcolor{FFFF00}
\multirow{-4}*{\minitab[c]{\minitab[c]{What does he/she think? \\(Write the person’s name on all the responses.)}}}}
\\
\hhline{
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
!{\sfill{black}{0.4pt}}
>{\vsl{black}{0.4pt}}
}
\end{tabular}
\end{document}
```
一周热门 更多>