When I use TeXForm on a matrix I often want to replace some the output with some number of verticle and horizontal lines. Is there a way to get control over this, possibly using patterns?
As an example consider
TeXForm[TableForm[{{1, 2}, {3, 4}}, TableHeadings -> {{"a", "b"}, {"c", "d"}}]]
(*Output:
\begin{array}{ccc}
& \text{c} & \text{d} \\
\text{a} & 1 & 2 \\
\text{b} & 3 & 4 \\
\end{array}
*)
I would like the output,
\begin{array}{c|c|c}
& \text{c} & \text{d} \\ \hline
\text{a} & 1 & 2 \\
\text{b} & 3 & 4 \\
\end{array}
Is there a way this can be automatically accomplished?