# Aligning side-by-side tables with blank lines

I'm sure this is simple, but I can't figure it out. I'm trying to produce side-by-side tables that look like this:

except that the left-hand table should have completely blank lines instead of the two vertical lines in every other row. I tried this:

\begin{equation*}
\begin{array}{| c | c | c | c |}
\hline
\multicolumn{4}{|c|}{\Delta t = 0.1}\\\hline
k & t_k & u_k & f(t_k,u_k) \\\hline
0 & 0 & 2 & -2 \\\hline\\\hline
1 & 0.1 & 1.8 & -1.7 \\\hline \\\hline
2 & 0.2 & 1.63 & -1.43 \\\hline \\\hline
3 & 0.3 & 1.487 & -1.187 \\\hline \\\hline
\end{array}
\qquad
\begin{array}{| c | c | c | c |}
\hline
\multicolumn{4}{|c|}{\Delta t = 0.05}\\\hline
k & t_k & u_k & f(t_k,u_k) \\\hline
0 & 0 & 2 & -2 \\\hline
1 & 0.05 & 1.9 & -1.85 \\\hline
2 & 0.1 & 1.808 & -1.708 \\\hline
3 & 0.15 & 1.722 & -1.572 \\\hline
4 & 0.2 & 1.644 & -1.444 \\\hline
5 & 0.25 & 1.571 & -1.321 \\\hline
6 & 0.3 & 1.505 & -1.205 \\\hline
\end{array}
\end{equation*}


which produced the output above. Is there an easy way to do what I want? (I'm using the array and multirow packages).

-
In the particular multicolumns, use {|c} instead of {|c|}, instead of a double hline – Steven B. Segletes Mar 30 '13 at 19:47
D'Oh. Works perfectly, thanks. – rogerl Mar 30 '13 at 19:52
@StevenB.Segletes if you want to turn that into an answer, I'll accept that one since you were first; otherwise I'll accept Gonzalo's answer below. Either way, thank you. – rogerl Mar 30 '13 at 19:54
Gonzalo did the work, give it to him. Cheers! – Steven B. Segletes Mar 30 '13 at 20:30
Your code, when augmented to form a minimum working example (MWE), doesn't generate the image that's currently posted; it also features, in the first array environment, a row of | | followed by a horizontal black line. – Mico Mar 30 '13 at 20:47

## 2 Answers

You can use \multicolumn to override the declared format; I also used t for the optional argument of array to produce top alignment:

\documentclass{article}
\usepackage{array,multirow}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\begin{array}[t]{| c | c | c | c |}
\hline
\multicolumn{4}{|c|}{\Delta t = 0.1} \\
\hline
k & t_k & u_k & f(t_k,u_k) \\
\hline
0 & 0 & 2 & -2 \\
\hline
\multicolumn{4}{c}{} \\
\hline
1 & 0.1 & 1.8 & -1.7 \\
\hline
\multicolumn{4}{c}{} \\
\hline
2 & 0.2 & 1.63 & -1.43 \\
\hline
\multicolumn{4}{c}{} \\
\hline
3 & 0.3 & 1.487 & -1.187 \\
\hline
\end{array}
\qquad
\begin{array}[t]{| c | c | c | c |}
\hline
\multicolumn{4}{|c|}{\Delta t = 0.05} \\
\hline
k & t_k & u_k & f(t_k,u_k) \\
\hline
0 & 0 & 2 & -2 \\
\hline
1 & 0.05 & 1.9 & -1.85 \\
\hline
2 & 0.1 & 1.808 & -1.708 \\
\hline
3 & 0.15 & 1.722 & -1.572 \\
\hline
4 & 0.2 & 1.644 & -1.444 \\
\hline
5 & 0.25 & 1.571 & -1.321 \\
\hline
6 & 0.3 & 1.505 & -1.205 \\
\hline
\end{array}
\end{equation*}

\end{document}


-

I believe you have an unneeded \\\hline statement at the end of the first array. If you leave out this statement, the two arrays will be aligned correctly.

If you want to go a bit further, I'd recommend you use the siunitx package and its S column type to align the numbers on their decimal points. And, as already shown in Gonzalo Medina's answer, you may want to insert \multicolumn{1}{c}{ } directives in the first table to suppress (presumably unnecessary) | | in every other row.

\documentclass{article}
\usepackage{siunitx}
\sisetup{table-format=2.3}
\begin{document}
$\begin{array}{| l | S | S | S |} \hline \multicolumn{4}{|c|}{\Delta t = 0.1}\\ \hline k & {t_k} & {u_k} & {f(t_k,u_k)} \\ \hline 0 & 0 & 2 & -2 \\\hline \multicolumn{1}{c}{ }\\\hline % extra blank line 1 & 0.1 & 1.8 & -1.7 \\\hline \multicolumn{1}{c}{ }\\\hline % extra blank line 2 & 0.2 & 1.63 & -1.43 \\\hline \multicolumn{1}{c}{ }\\\hline % extra blank line 3 & 0.3 & 1.487 & -1.187\\\hline \end{array} \qquad \begin{array}{| l | S | S | S |} \hline \multicolumn{4}{|c|}{\Delta t = 0.05}\\ \hline k & {t_k} & {u_k} & {f(t_k,u_k)} \\ \hline 0 & 0 & 2 & -2 \\\hline 1 & 0.05 & 1.9 & -1.85 \\\hline 2 & 0.1 & 1.808 & -1.708 \\\hline 3 & 0.15 & 1.722 & -1.572 \\\hline 4 & 0.2 & 1.644 & -1.444 \\\hline 5 & 0.25 & 1.571 & -1.321 \\\hline 6 & 0.3 & 1.505 & -1.205 \\\hline \end{array}$
\end{document}


I'd also like to encourage you to consider getting rid of all vertical lines; they really don't add any useful information once the numeric columns are aligned on the decimal points. As a bonus, you needn't type something like \multicolumn{1}{c}{ } \\ to generate a blank line without vertical lines; \\ is enough. :-) Moreover, I'd argue that most horizontal lines in the two arrays aren't needed either.

Here, then, is a slight modification of your example; instead of \hline, it uses the booktabs package (and its commands \toprule, \midrule, and \bottomrule) to draw horizontal lines with better spacing.

\documentclass{article}
\usepackage{siunitx}
\sisetup{table-format=2.3}
\usepackage{booktabs}
\begin{document}
$\begin{array}{ @{} l S S S @{} } \multicolumn{4}{c}{\Delta t = 0.1}\\ \midrule[\heavyrulewidth] k & {t_k} & {u_k} & {f(t_k,u_k)} \\ \midrule 0 & 0 & 2 & -2 \\ \\ % extra blank line 1 & 0.1 & 1.8 & -1.7 \\ \\ % extra blank line 2 & 0.2 & 1.63 & -1.43 \\ \\ % extra blank line 3 & 0.3 & 1.487 & -1.187\\ \bottomrule \end{array} \qquad \begin{array}{ @{} l S S S @{} } \multicolumn{4}{c}{\Delta t = 0.05}\\ \midrule[\heavyrulewidth] k & {t_k} & {u_k} & {f(t_k,u_k)} \\ \midrule 0 & 0 & 2 & -2 \\ 1 & 0.05 & 1.9 & -1.85 \\ 2 & 0.1 & 1.808 & -1.708 \\ 3 & 0.15 & 1.722 & -1.572 \\ 4 & 0.2 & 1.644 & -1.444 \\ 5 & 0.25 & 1.571 & -1.321 \\ 6 & 0.3 & 1.505 & -1.205 \\ \bottomrule \end{array}$
\end{document}

-
The added @{} contradict somehow the introduced vertical padding introduces by booktabs’ rules. It looks like the k column is about to fall down the rule’s edge. – Qrrbrbirlbel Mar 30 '13 at 20:33
@Qrrbrbirlbel - The default extra whitespace to the left of the first column and to the right of the last column of an array is given by \arraycolsep (usually, 6pt). Omitting this extra whitespace via @{} directives is something that the author of the booktabs package seems to recommend doing. In the present example, it may be that because the first column is quite thin, some extra padding (i.e., extra whitespace) may indeed counteract the effect you describe. However, I wouldn't leave off @{} entirely; instead, I'd insert something like @{\hspace*{2pt}}. – Mico Mar 30 '13 at 21:21
Yes, this isn’t new to me. :) While I agree on most things in the booktabs manual, this is something that doesn’t look right to me, especially due to the added vertical space. It’s like protrusion pushing certain glyphs into the margin. Here the rules protrude. And, yes it helps that the first column is very thin. The effect isn’t that big on the other side because the header is wider than the rest and the ) glyph has more white space on the right than $k$ on the left. Anyway, to each its own. (Nonetheless, this does produce a better output as a |-\hline solution!) – Qrrbrbirlbel Mar 30 '13 at 21:37