[Tex/LaTex] Horizontal line through table cell

rulestablesvertical alignment

I have a very long, thin table that I'm folding onto itself to make a wider, shorter version. The table has a couple horizontal rules to separate data categories. For example, the original table is like:

-----------------------
| Column A | Column B |
-----------------------
| Data A1  | Data B1  |
| Data A2  | Data B2  |
| ------------------- |
| Data A3  | Data B3  |
...

and I'm wanting it like:

---------------------------------------------------
| Column A | Column B |     | Column A | Column B |
---------------------------------------------------
| Data A1  | Data B1  |     | Data A51 | Data B51 |
| Data A2  | Data B2  |     | Data A52 | Data B52 |
| ------------------- |     | Data A53 | Data B53 |
| Data A3  | Data B3  |     | Data A54 | Data B54 |
...

The problem is I cannot get the desired behavior with the horizontal rules. If I use something like \cmidrule{1-2}, there is a blank row in the right two columns:

---------------------------------------------------
| Column A | Column B |     | Column A | Column B |
---------------------------------------------------
| Data A1  | Data B1  |     | Data A51 | Data B51 |
| Data A2  | Data B2  |     | Data A52 | Data B52 |
| -------------------                             |
| Data A3  | Data B3  |     | Data A53 | Data B53 |
...

I've tried playing with \vspace{-3mm} but I can't find values and a placement that gets the right results. I've also considered not using \cmidrule and fill the left two cells with a horizontal line. Something like

\multicolumn{2}{c}{--------} & Data A53 & Data B53 \\

However, I can't figure out how to make this horizontal line.

Best Answer

You could use \hrulefill in place of your ---- (but the vertical spacing may be rather strange, compared to \cmidrule) or you could use \cline{1-2} which will open up a gap in the other columns. Or (perhaps simplest) you could just use two separate tabular environments side by side.

If you want to control the vertical position of the rule you can use \leaders for example

\leaders\hbox{\rule[0.4em]{.1pt}{0.4pt}}\hfill\mbox{}

The \mbox{} is needed to protect the leaders from \unskip which the tabular code adds to remove white space from the end of the entry.