# Could someone turn this table into a latex table?

I have this table on Word and I would like to convert it to a latex table. The only thing is I don't know how to create rows that have 2 lines.

If someone could just give me the code to make this table a latex table, I'd really appreciate it!

\begin{center}
\begin{tabular}{ |c|c|c| }
\hline
$(x)_2 = n$; $n\%5$  & $(x0)_2 = 2n$; $2n\%5$ & $(x1)_2 = 2n + 1$; $(2n+1)\%5$ \\
\hline
0 & 0 & 1 \\
1 & 2 & 3 \\
2 & 4 & 0 \\
3 & 1 & 2 \\
4 & 3 & 4 \\
\hline
\end{tabular}
\end{center}

• If you really want to duplicate that layout, just leave off the \hline between rows. But I'd recommend getting rid of most of the rules entirely. See texdoc.net/pkg/booktabs – Paul Gessler Apr 27 '16 at 1:54
• OK, so please give us the code you've got for the table and somebody will be happy to adapt it to show you how to use multirow or p{} or similar. But @PaulGessler 's suggestion is better (either of them) in this case. – cfr Apr 27 '16 at 1:54
• @cfr Alrighty. I've added the code – 14wml Apr 27 '16 at 2:06

The easiest option is to split the heading into two rows with no line between them:

\documentclass{article}

\begin{document}
\begin{center}
\begin{tabular}{ |c|c|c| }
\hline
$(x)_2 = n$ & $(x0)_2 = 2n$ & $(x1)_2 = 2n + 1$ \\
$n\%5$  & $2n\%5$ & $(2n+1)\%5$ \\
\hline
0 & 0 & 1 \\
1 & 2 & 3 \\
2 & 4 & 0 \\
3 & 1 & 2 \\
4 & 3 & 4 \\
\hline
\end{tabular}
\end{center}
\end{document}


Many are likely to suggest that you should follow the advice from the booktabs package and dispense with the vertical rules and most of the horizontal rules, which aren´t doing much more than distracting the eyes in so simple a table. Note also how the spacing between rows tends to be better by default as well (especially around the \hlines).

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{center}
\begin{tabular}{ ccc }
\toprule
$(x)_2 = n$ & $(x0)_2 = 2n$ & $(x1)_2 = 2n + 1$ \\
$n\%5$  & $2n\%5$ & $(2n+1)\%5$ \\
\midrule
0 & 0 & 1 \\
1 & 2 & 3 \\
2 & 4 & 0 \\
3 & 1 & 2 \\
4 & 3 & 4 \\
\bottomrule
\end{tabular}
\end{center}
\end{document}