2

I'm having an issue where LaTeX won't accept the main heading row of my table (the third row of code below). When I comment out that line, it works. Here's the beginning of my tabular-

\begin{tabular}{r| >{\raggedleft}p{0.8cm} ||r|r| >{\raggedleft}p{0.8cm} || r|r| >{\raggedleft}p{0.8cm} |}
 & & \multicolumn{3}{c||}{Speaker A} & \multicolumn{3}{c}{Speaker B} \\ \hline
\small{Session-Part} & \small{Total length} & \small{Time} & \small{Time \%} & \small{DM rate} & \small{Time} & \small{Time \%} & \small{DM rate} \\
1-\textsc{chat} & 10:15 & 4:17 & 41.8\% &  & 4:38 & 45.2\% &  \\

I think that it is somehow not registering the linebreak, and I'm getting a bunch of overfull hbox errors with it (is it too long? it seems to fit otherwise...). If I try to put a \hline there it also gives me a misplaced noalign error. Otherwise if I try to run it as it is here, it gives me an 'extra alignment tab' error for the first '&' in the next row, so it thinks I haven't ended the row. I have counted the columns a zillion times and I cannot fathom what could be going wrong. Could it be a problem with the multicolumn format? Again, it works fine when I comment out the second row of headings, so :/

4
  • 2
    regardless \small is a switch it is not a macro that takes arguments.
    – percusse
    Mar 19, 2016 at 4:29
  • I can't reproduce your problem. Bad boxes arise because you have to narrow p columns.
    – Zarko
    Mar 19, 2016 at 5:06
  • I've tried making them narrower, and again the table still runs without that row with these p widths, so that doesn't seem to be the problem
    – er23
    Mar 19, 2016 at 5:16
  • 3
    \raggedright redefines \\ so you either need \tabularnewline instead of \\ or use \arraybackslash to define it back again. Mar 19, 2016 at 8:10

1 Answer 1

3

I slightly modified your table: (i) added new column type with correct definition (as shortcuts for simpler its typing), (ii) added new command for \multicolumn and (iii) increase width of table (which cause in yiur MWE warning bad box: 2. I also remove remedy of wrong use \small macro. Horizontal lines I left as they are used in your MWE.

With this modification I can't reproduce your problem nor get any warnings of bad boxes:

\documentclass{article}
\usepackage{array}
\newcolumntype{P}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcommand\mcbf[2]{\multicolumn{#1}{c||}{\textbf{#2}}}

    \begin{document}
    \begin{center}\small
\begin{tabular}{r|P{1cm} ||r|r|P{0.8cm}||r|r|P{1cm}||}
\mcbf{2}{}
    & \mcbf{3}{Speaker A} & \mcbf{3}{Speaker B}    \\ 
    \hline
Session-Part 
    & Total length     & Time & Time \% & DM rate & Time & Time \% & DM rate \\
1-\textsc{chat} 
    & 10:15            & 4:17 & 41.8\%  &         & 4:38 & 45.2\%  &         \\ \hline   
\end{tabular}
    \end{center}
   \end{document}

The main difference in between my modification and your MWE is added arraybackslash to your definition of column p{...}. Without this (at list in the last column of table} cause unexpected problems -- its missing in your MWE is source of your problem). enter image description here

You must log in to answer this question.

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