Suppose I have the following table which lists conversion rules, where rows denote the input and columns denote the output type (so, for example, the conversion int8_t -> int16_t
would use b
, while int16_t -> int8_t
would use g
):
This answer lists alternatives for using a \slashbox
(which is what I would have originally used), which seem much more professional. However, the second table in their example seems unintuitive/not clear to me, and with the third, the thing that bit me was that in their example, the domains of rows and columns are different and therefore it is not necessary to define whether rows map to rooms and columns to dates or vice versa.
With that in mind, the best I could come up with was the above, which does not look good (and uses a vertical line which I'd like to avoid, but without it the table's meaning wouldn't be clear at all). What would be a best practice to typeset such a table?
Code for the example above:
\begin{table}
\centering
\begin{tabular}{rr|rrrrrr}
\toprule
& & \multicolumn{6}{c}{Output} \\
\midrule
& & int8\_t & int16\_t & int32\_t & uint8\_t & uint16\_t & uint32\_t \\
\multirow{6}[0]{*}{\begin{sideways}Input\end{sideways}} & int8\_t & a & b & c & d & e & f \\
& int16\_t & g & h & i & j & k & l \\
& int32\_t & m & n & o & p & q & r \\
& uint8\_t & s & t & u & v & w & x \\
& uint16\_t & y & z & a & b & c & d \\
& uint32\_t & e & f & g & h & i & j \\
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
Best Answer
First of all, as I suggested in my comment, I would rather have the
\midrule
one row below:I think grouping 'Output' with the headers makes more sense, logically, just as you did with 'Input'.
As an alternative to the
slashbox
package there isdiagbox
. The description in the documentation states:I also like it better, is easier to customize and the diagonal line (now drawn with
pict2e
) is much nicer. Here's an example using it:Overall a good result, but I was a bit dissatisfied with the placement of 'Output', so I tweaked the table. (Fortunately,
diagbox
is rather flexible.) The final result I came up with is a heavily modified (but IMHO visually the most appealing) version:On a final note, I believe vertical lines are sometimes necessary and I don't think there is anything wrong with using one here. It is a guide for the eye to help separate logical groups from each other (e.g. headers from raw data) in the table. (For a discussion see here: Why not use vertical lines ('|') in a tabular?)