0

I want to center a table caption between the 5th and 6th columns, like this:

target table

where I've made the following

current table attempt

in this way:

% for table captions on top
\usepackage[tableposition=top]{caption}
% space out columns
\setlength{\tabcolsep}{14pt}
% remove default caption numbering
\usepackage{caption}

    \begin{table}[th!]
        \centering
        \caption*{$x_{2}$}
        \begin{tabular}{l c | c c c c c}
                    &   & 0   & 1    & 2    & 3    \\
            \hline
                    & 0 & .08 & .07 & .04 & .00 \\
                    & 1 & .06 & .15 & .05 & .04 \\
            $x_{1}$ & 2 & .05 & .04 & .10 & .06 \\
                    & 3 & .00 & .03 & .04 & .07 \\
                    & 4 & .00 & .01 & .05 & .06 
        \end{tabular}
    \end{table}

where the h! is just for forcing the table's position in the document.

I've looked into threeparttable, but I didn't see anything in the (fairly brief) documentation that seemed like it would help.

Is there an easy way to do this?

1
  • 1
    You shouldn't be using the caption for labelling your columns. I would suggest you add an extra row with this code \ & \ & \ & \multicolumn{2}{c}{$x_2$} & \ & \\ above your data. It worked when I tried it in your code. \multicolumn{}{}{} merges columns in your table, 2 in this case. I hope this helps.
    – gnikit
    Commented Apr 10, 2017 at 23:46

1 Answer 1

3

Per @nikjohn's comment:

You shouldn't be using the caption for labelling your columns. I would suggest you add an extra row with this code \ & \ & \ & \multicolumn{2}{c}{$x_2$} & \ & \\ above your data. It worked when I tried it in your code. \multicolumn{}{}{} merges columns in your table, 2 in this case.

The code using this:

\begin{table}[th!]
    \centering
    \begin{tabular}{l c | c c c c }
        \ & \ & \ & \multicolumn{2}{c}{$x_2$} & \ \\
                &   & 0   & 1    & 2    & 3    \\
        \hline
                & 0 & .08 & .07 & .04 & .00 \\
                & 1 & .06 & .15 & .05 & .04 \\
        $x_{1}$ & 2 & .05 & .04 & .10 & .06 \\
                & 3 & .00 & .03 & .04 & .07 \\
                & 4 & .00 & .01 & .05 & .06 
    \end{tabular}
\end{table}

and resultant image:

result image

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .