I have a table which I want to transform it into Latex Code

But, I am beginner in Latex, thus, the header of this table is hard for me to write it in Latex.

## migrated from stackoverflow.comOct 22 '15 at 10:25

This question came from our site for professional and enthusiast programmers.

• This table header is not difficult reproduce, however, what you do so far? Do you have any code concern it? And how wide can table to be? – Zarko Oct 22 '15 at 11:01
• I relate sophisticated to simplicity and elegance, this is more like screaming for attention with a pimped out car. – Johannes_B Oct 22 '15 at 11:11

This questions look like "do this for me" ... For my exercise I reproduce part of above table:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{rotating}
\usepackage{array, makecell, multirow, tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

\begin{document}
\centering
\begin{tabularx}{\hsize}{|>{\bfseries}c|L|c|c|c|}
\hline
\cline{3-5}
\hline
Q1  &   Which of the following are straight?
&   Yes &   Yes &   Yes                         \\
\hline
\end{tabularx}
\end{document}


where I omit coloring of first two table rows. Above code gives:

Now you can answer yourself? Do I really need colored the first two table rows? Do be table nicer without vertical lines and column headers separated from other rows with rules provided by package booktabs?

Educative is to see "Wie Tabellen eigentlich aussehen sollten?"

Anyway, I try to give you a starting point, from where you can proceed further.

The following solution, hopefully, satisfies @Johannes_B's criteria for simplicity and elegance. :-)

Note that I use no vertical bars and only one horizontal rule (at the bottom of the table). I also don't gratuitously require readers of the table to crane their necks just so that they can read the subheader cells.

\documentclass{article}
\usepackage[a4paper,margin=1in]{geometry} % choose page and margin sizes
\usepackage{tabularx,booktabs}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage[table]{xcolor}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{>{\bfseries}l X C{1cm} C{1.75cm} C{1cm} }
\rowcolor{lightgray} No. & \textbf{Questions} & \multicolumn{3}{c}{\textbf{Type of line}} \\[1ex]
\rowcolor{lightgray} & & \bfseries Line & \bfseries Line Segment & \bfseries Ray \\