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

enter image description here

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

migrated from stackoverflow.com Oct 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
  • 2
    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:

\usepackage{array, makecell, multirow, tabularx}
    \settowidth\rotheadsize{\theadfont Line segment}

    &   \multirowcell{5}{\thead{Questions}}
        &   \multicolumn{3}{c|}{\thead{Type of line}}    \\
    &   &   \rothead{Line}
            &   \rothead{Line segment}
                &   \rothead{Ray}                       \\
Q1  &   Which of the following are straight?
        &   Yes &   Yes &   Yes                         \\

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

enter image description here 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.

enter image description here

\usepackage[a4paper,margin=1in]{geometry} % choose page and margin sizes


\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 \\
Q1 & Which of the following are straight? & Yes & Yes & Yes \\
Q2 & Which of the following are part of a line? & No & Yes & Yes \\

  • That looks a bit better :-) – Johannes_B Oct 22 '15 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.