# How do I create this table?

I want to create this table:

I started with this, but it doesn't work:

\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{center}
\begin{tabular}{c|c}

hello & hello \\

\toprule
hello hello hello hello hello hello hello hello hello hello space infinity & hello hello hello hello  \\
hello hello hello hello hello & hello hello hello hello  \\

\end{tabular}
\end{center}
\end{document}}


How can I fix this?

• You cannot use vertical lines with booktabs horizontal rules. So you need to either replace \toprule with \hline or get rid of the vertical line. However \toprule is not the correct choice of rule, it should be \midrule but I expect what you're really going for is a thicker line, which demands a different solution tex.stackexchange.com/questions/256731/… – Au101 Aug 26 '18 at 16:46
• In terms of the too wide table cell, there are various solutions, the most basic of which would be to use something like p{2cm} (where 2cm is a fairly arbitrary length, you will have to select the width that you would like to use) instead of a c column. With c the column will be as wide as its contents, and if that means too wide for the page then unfortunately the table will run off the page, the line won't break, because you haven't told it when to break. With p{2cm} you tell it you want a 2cm wide cell and then the line will break to respect that – Au101 Aug 26 '18 at 16:48
• You can use \specialrule{\heavyrulewidth}{0pt}{0pt}: it will have the same thickness as \toprule but no vertical padding. An alternative: load boldline , from the shipunov bundle, which defines horizontal and vertical lines with custom thickness. – Bernard Aug 26 '18 at 16:53

## 3 Answers

like this:

beside tabularx are used options !{<option>} and \Xhline{<width>} from the package array (in this case loaded by the package tabularx) and macro \makecell from the package of the same name:

\documentclass[11pt,a4paper]{article}
\usepackage{makecell, tabularx}

\begin{document}
\begin{center}
\setcellgapes{5pt}\makegapedcells
\begin{tabularx}{\textwidth}{X!{\vline width 1pt} X}
\makecell{hello}   & \makecell{hello} \\
\Xhline{1pt}
hello hello hello hello hello hello hello hello hello hello space infinity
& hello hello hello hello  \\
hello hello hello hello hello hello hello hello hello hello space infinity
& hello hello hello hello  \\
\end{tabularx}
\end{center}
\end{document}

• perfect! thank you :) – Vidal Aug 27 '18 at 10:02

Don't use booktabs with vertical rules.

And don't load packages twice (you have two \usepackage{graphicx}).

I have used tabularx, and \\[4pt] and \rule{0pt}{16pt} to add some space before and after the horizontal rule.

\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{tabularx}
\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{X|X}
\multicolumn{1}{c|}{hello} &
\multicolumn{1}{c}{hello} \\[4pt]
\hline
\rule{0pt}{16pt}hello hello hello hello hello hello hello hello hello hello space infinity & hello hello hello hello  \\
hello hello hello hello hello & hello hello hello hello  \\
\end{tabularx}
\end{center}
\end{document}


The screenshot that accompanies your query creates the impression that each table column should be just wide enough (but no wider) to typeset three instances of the word "hello", separated by whitespace. If this impression is correct, you should use the p column type for both columns. The p column type takes an argument -- the usable width. In the preamble, be sure to set up a length parameter and measure the width of "hello hello hello" via a \settowidth directive.

Oh, and don't use the booktabs package (and \midrule directives) if you employ vertical lines. Instead, use \hline.

\documentclass[11pt,a4paper]{article}
\usepackage{array} % for "\extrarowheight" macro
\newlength\mylen
\settowidth\mylen{\sffamily hello hello hello} % measure width of "hello hello hello"
\begin{document}
\begin{center}
\sffamily % switch to sans-serif
\setlength\extrarowheight{2pt} % for a more open "look"
\begin{tabular}{p{\mylen}|p{\mylen}}
\multicolumn{1}{c|}{hello} &
\multicolumn{1}{c}{hello} \\[2pt]
\hline
hello hello hello hello hello hello hello hello hello hello space infinity & hello hello hello hello  \\
hello hello hello hello hello & hello hello hello hello \\
\end{tabular}
\end{center}
\end{document}