Fancy Latex Tables

Do you like to create funny graphics like the following for your paper?

Masters of Illustrator can probably chop-chop-compose such a thing in a flash. I, however, abruptly failed as I tried to insert formulae. Why not directly script it in latex, I thought. So I unearthed the big old latex manuals and learned about \multicolumn and \cline. Eventually, I came up with the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
\begin{tabular}{|l|c|l|c|l|}
\multicolumn{1}{c}{}
&\multicolumn{2
}{c}{$e_i$}
&\multicolumn{2}{c}{$e_{i+1}$}\\

\multicolumn{1}{c}{$D$}
&\multicolumn{2}{c}{$\overbrace{\hspace{1cm}}^{}$}
&\multicolumn{2}{c}{$\overbrace{\hspace{1cm}}^{}$} \\\cline{1-1}

$P_1$
&\multicolumn{1}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{}   \\\cline{1-1}

$\vdots$
&\multicolumn{1}{c}{}
&\multicolumn{1
}{c}{$W$}
&\multicolumn{1}{c}{}
&\multicolumn{1
}{c}{}   \\\cline{1-1} \cline{3-3}

$P_{i}$
&$\longleftrightarrow$
&$V_0$
&\multicolumn{1}{c}{}
&\multicolumn{1
}{c}{$W$} \\\cline{3-3} \cline{1-1}\cline{5-5}

$P_{i+1}$
&$\longleftrightarrow$
&$V_1$
&$\longleftrightarrow$
&$V_0$ \\\cline{3-3} \cline{1-1} \cline{5-5}

$P_{i+2}$
&$\longleftrightarrow$
&$V_2$
&$\longleftrightarrow$
&$V_1$ \\\cline{3-3} \cline{1-1} \cline{5-5}

$\vdots$
&$\longleftrightarrow$
&$\vdots$
&$\longleftrightarrow$
&$V_2$ \\\cline{3-3} \cline{1-1}\cline{5-5}

$P_{i+k}$
&$\longleftrightarrow$
&$V_k$
&$\longleftrightarrow$
&$\vdots$ \\\cline{3-3} \cline{1-1} \cline{5-5}

$P_{i+k+1}$
& \multicolumn{1}{c}{}
&\multicolumn{1
}{c}{}&
$\longleftrightarrow$
&$V_k$ \\\cline{1-1
} \cline{5-5}

$\vdots$
&\multicolumn{1}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{}   \\\cline{1-1}

$P_m$
&\multicolumn{1}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{}   \\\cline{1-1}

\multicolumn{1}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{}   \\
\end{tabular
}

and

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline
$P_1$

&$\hdots$
&$P_{i}$
&$P_{i+1}$
&$P_{i+2}$
&$\hdots$
&$P_{i+k}$
&$\hdots$
&$P_m$ \\\hline

\multicolumn{1}{c}{}
&\multicolumn{1
}{c}{}
&\multicolumn{1
}{c}{$\updownarrow$}
& \multicolumn{1}{c}{$\updownarrow$}
& \multicolumn{1}{c}{$\updownarrow$}
& \multicolumn{1}{c}{$\hdots$}
& \multicolumn{1}{c}{$\updownarrow$}
& \multicolumn{2}{c}{} \\\cline{3-7}

\multicolumn{1}{c}{}
&
& $V_{0}$

& $V_{1}$
& $V_{2}$
& $\hdots$
& $V_{k}$
& \multicolumn{2}{c}{} \\\cline{3-7}
\end{tabular}

The trick is to create borderless cells using \multicolumn and then fill in horizontal lines with \cline. You’re welcome. Now back to work!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>