1

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
0

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}
    \renewcommand\theadfont{\bfseries}
    \settowidth\rotheadsize{\theadfont Line segment}
    \newcolumntype{L}{>{\raggedright\arraybackslash}X}

    \begin{document}
    \centering
\begin{tabularx}{\hsize}{|>{\bfseries}c|L|c|c|c|}
    \hline
\multirowcell{5}{\thead{No.}}
    &   \multirowcell{5}{\thead{Questions}}
        &   \multicolumn{3}{c|}{\thead{Type of line}}    \\
        \cline{3-5}
    &   &   \rothead{Line}
            &   \rothead{Line segment}
                &   \rothead{Ray}                       \\
    \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:

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.

1

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

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

\end{document}
  • 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.