5

I am trying to reproduce a table like those in this picture

The table I want to reproduce

So far I have

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

How can I get the white text on black background top row of the tables in the picture (which seems to be a three column row where the others are four columns)?. Also, is it possible to get something like the fine double line you see round the outside of the table and in fact all round the white on black top row of the table in the following higher resolution snapshot (click to enlarge):

enter image description here

4
  • 1
    Just note that it is (virtually) impossible to reproduce something if we can't see it. The description doesn't provide enough information as is.
    – Werner
    Sep 27, 2011 at 14:12
  • Yes, sorry about that.
    – Simd
    Sep 27, 2011 at 14:32
  • Added a higher resolution picture that shows the lines.
    – Simd
    Sep 27, 2011 at 19:02
  • I've updated my answer to include some reference to you (now visible) line specification. This is doable using the hhline package. The colortbl package documentation has some examples of this.
    – Werner
    Sep 27, 2011 at 19:09

3 Answers 3

11

The idea is to use some of the commands provided by the table option of the xcolor package. The first option would be to use \rowcolor to specify the desired color for the whole row; however, since you need to use \multicolumn to override the default column specification (in order to have centered contents in some cells),the effect of \rowcolor will be lost, so it's better to use \cellcolor inside \multicolumn for the modified cells. The color for the text can be changed using the \textcolor (from the color package) command. These ideas can be better implemented through a new command. To get the fine double line, I used a \fbox (locally changing \fboxsep) to place a frame around the table, and a "fake" row; feel free to change the length according to your needs:

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

enter image description here

7
  • The use of \cellcolor seems to be better, since it (from the embedded image) maintains the column rules.
    – Werner
    Sep 27, 2011 at 17:33
  • @Raphael Clifford: Since you have some responses that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). Sep 27, 2011 at 19:26
  • @Gonzalo Medina, All the answers were great but I have accepted this one as it is the one I have used. I haven't managed to get quite the effect I was looking for with \hhline yet but I did add the high resolution second picture a little late.
    – Simd
    Sep 28, 2011 at 11:27
  • @Raphael Clifford: see my updated answer. Sep 28, 2011 at 15:18
  • Wow, that's great. One small thing, if I leave out the % after \end{tabularx} the tables stick out into the margin a few millimetres. Why is this? Actually, I think they all stick out very (very) slightly in any case now but not that it matters visually.
    – Simd
    Sep 28, 2011 at 16:17
2

Here is a mockup of what you might be after in terms of colouring the table row and text:

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

enter image description here

You should read the colortbl package documentation to see what can be done in general. The inclusion of xcolor allows for shades of colours (like the 80% black I used - black!80).

The hhline package provides the means to draw (double) horizontal lines that have very neat intersections. Read the colortbl package documentation for some illustrations on how to incorporate colour and \hhline in a tabular(x) environment (section 9 More fun with \hhline).

0
1

Please provide a full working example next time!

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

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .