0

I am trying to use the new line command within the multicolumn command in tabular. When I use it messes up the table in the following way. How can I fix this?

\begin{tabular}{l|*{8}{c}r}
&\multicolumn{2}{c}{Aug. D-F Z(t)-stat} & \multicolumn{2{c}{P-P Z(t)-stat.}\\
    \hline
    Team & Un-Differenced & Differenced & Un-Differenced & Differenced   \\
    \hline
    K-12 Education                  & 2 & 4 & 2 & 4    \\
    Medicaid and Welfare            & 6 & 3 & 2 & 4   \\
    Public Health and Hospitals     & 6 & 2 & 2 & 4   \\
    Natural Resources               & 6 & 2 & 2 & 4   \\
    Higher Education                & 6 & 4 & 2 & 4   \\
    Highways                        & 6 & 4 & 2 & 4   \\
    Police and Prisons              & 6 & 4 & 2 & 4   \\
    Other Spending                  & 6 & 4 & 2 & 4   \\
    \hline
        \multicolumn{8}{c}{Note: Augmented Dickey Fuller Z(t) test statistics word word wword wword word word word \\word  word.}
    \end{tabular}
2
  • Welcome to TSE. Please post a Minimal Working Example, instead of a code snippet. Commented Jun 24, 2022 at 22:16
  • You can only use \newline in a p column (or variant). You can also put a tabular inside a tabular column. Commented Jun 25, 2022 at 3:20

1 Answer 1

2

Like this?

enter image description here

With talltblr defined by the tabularray package:

\documentclass{article}
\usepackage{tabularray}

\begin{document}
\begin{talltblr}[
caption = {Overview of statistic. Diff.: Differened},
remark{Note} = {Augmented Dickey Fuller Z(t) test statistics word word word word word word word word  word.}
                ]{colspec = {l| *{4}{c}}}
    &   \SetCell[c=2]{c}    Aug. D-F Z(t)-stat  
        &   &   \SetCell[c=2]{c}    P-P Z(t)-stat.      
                &                                       \\
    \hline
Team & Un-Diff. & Diff. & Un-Diff. & Diff.   \\
    \hline
    K-12 Education                  & 2 & 4 & 2 & 4     \\
    Medicaid and Welfare            & 6 & 3 & 2 & 4     \\
    Public Health and Hospitals     & 6 & 2 & 2 & 4     \\
    Natural Resources               & 6 & 2 & 2 & 4     \\
    Higher Education                & 6 & 4 & 2 & 4     \\
    Highways                        & 6 & 4 & 2 & 4     \\
    Police and Prisons              & 6 & 4 & 2 & 4     \\
    Other Spending                  & 6 & 4 & 2 & 4     \\
    \hline
    \end{talltblr}
\end{document}
  • In columns type c (or l, t) you a text in cells can be only in one line, multiline text is possible to write only in p{width} (or b or m) column types. This means that in your case you should know table width.
  • With use of threeparttable or its equivalent talltblr defined in the tabullarray package this can be simple solved by use of table notes or remarks ia is used in above MWE,
  • It is not clear, why you specify 10 columns when you use only five.

You must log in to answer this question.

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