黑色背景上带有白色文字的表格行

黑色背景上带有白色文字的表格行

我正在尝试复制一张类似这张图片中的表格

我想要复制的表格

到目前为止

\noindent
\begin{tabularx}{\textwidth}{| l | X | l | l | }
\hline
& Does the proposed research involve processing of genetic information or personal data (e.g. health, sexual lifestyle, ethnicity, political opinion, religious or philosophical conviction)? & &  \\
\hline
& Does the proposed research involve tracking the location or observation of people? & &  \\
\hline
& I CONFIRM THAT NONE OF THE ABOVE ISSUES APPLY TO MY PROPOSAL  & YES & \\
\hline
\end{tabularx}

我怎样才能让图片中的表格顶行出现黑底白字(该行似乎是三列,而其他行是四列)?此外,在以下高分辨率快照中,是否可以获得类似于表格外围的细双线,以及实际上表格顶行黑底白字周围的所有细双线(单击放大):

在此处输入图片描述

答案1

这个想法是使用table选项提供的一些命令彩色包。第一个选项是使用\rowcolor来指定整行所需的颜色;但是,由于您需要使用\multicolumn来覆盖默认的列规范(以便在某些单元格中居中显示内容), 的效果\rowcolor将丢失,因此最好在修改后的单元格中使用\cellcolorinside 。可以使用(来自包)命令更改文本的颜色。这些想法可以通过新命令更好地实现。为了获得细双线,我使用了(局部更改)在表格周围放置一个框架和一个“假”行;请根据需要随意更改长度:\multicolumn\textcolorcolor\fbox\fboxsep

\documentclass{article}
\usepackage{tabularx}
\usepackage[table]{xcolor}

\newcommand\BlackCell[1]{%
  \multicolumn{1}{c|}{\cellcolor{black}\textcolor{white}{#1}}
}

\begin{document}

\begingroup
\noindent
\setlength\fboxsep{0.6pt}\fbox{%
\begin{tabularx}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}{| l | X | l | l | }
\hline
\BlackCell{} & \BlackCell{Research on Human Embryo/Foetus} & \BlackCell{YES} & \BlackCell{Page} \\\hline\multicolumn{4}{c}{}\\[-11.5pt]\hline
& Does the proposed research involve processing of genetic information or personal data (e.g. health, sexual lifestyle, ethnicity, political opinion, religious or philosophical conviction)? & &  \\
\hline
& Does the proposed research involve tracking the location or observation of people? & &  \\
\hline
& I CONFIRM THAT NONE OF THE ABOVE ISSUES APPLY TO MY PROPOSAL  & YES & \\
\hline
\end{tabularx}%
}
\endgroup

\end{document}

在此处输入图片描述

答案2

下面是您在为表格行和文本着色时可能需要的模型:

\documentclass{article}
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage{colortbl}% http://ctan.org/pkg/colortbl
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{| l | X | l | l | }
\hline
\rowcolor{black!80} & \textcolor{white}{RESEARCH ON HUMANS} & \textcolor{white}{YES} & \textcolor{white}{Page} \\ \hline
& Does the proposed research involve processing of genetic information or personal data (e.g. health, sexual lifestyle, ethnicity, political opinion, religious or philosophical conviction)? & &  \\
\hline
& Does the proposed research involve tracking the location or observation of people? & &  \\
\hline
& I CONFIRM THAT NONE OF THE ABOVE ISSUES APPLY TO MY PROPOSAL  & YES & \\
\hline
\end{tabularx}
\end{document}

在此处输入图片描述

你应该读一下colortbl包裹 文档看看一般可以做些什么。xcolor允许使用不同深浅的颜色(比如我使用的 80% 黑色 - black!80)。

hhline包裹提供了绘制具有非常整齐交叉点的(双)水平线的方法。阅读colortbl包装文档\hhline有关如何融入色彩的一些插图以及tabularx)环境9 更多乐趣\hhline)。

答案3

请提供满的下次再来演示工作示例!

\documentclass{article}
\usepackage{tabularx}
\usepackage[table]{xcolor}

\begin{document}

\noindent
\def\arraystretch{1.3}
\begin{tabularx}{\textwidth}{| l | X | l | l | }\hline
\multicolumn{4}{@{}p{\dimexpr \textwidth-\tabcolsep}@{}}{\colorbox{black}{\parbox{\linewidth}{\color{white}%
 Does the proposed research involve processing of genetic information or personal data (e.g. health, sexual lifestyle, ethnicity, political opinion, religious or philosophical conviction)? }}}\\\hline
 & Does the proposed research involve tracking the location or observation of people? & &  \\
\hline
& I CONFIRM THAT NONE OF THE ABOVE ISSUES APPLY TO MY PROPOSAL  & YES & \\
\hline
\end{tabularx}

\end{document}

在此处输入图片描述

相关内容