2

I need to have a horizontal line inside a multicolumn cell. When the horizontal line is just in one cell this is without problems possible, when spanning, with multicolumn, over say 2 cells I get an error message:

! You can't use `\hrule' here except with leaders.
<argument> \hrule

l.22 \end{longtabu}

My MWE:

\documentclass[twoside]{book}

\usepackage{tabu}
\usepackage{longtable}

\begin{document}

\begin{longtabu}spread 0pt [c]{*{3}{|X[-1]}|}
\hline
Column 1&Column 2&Column 3 \\\cline{1-3}
Column 1&\hrule
&Column 3 \\\cline{1-3}
Column 1&Column 2&Column 3 \\\cline{1-3}
\end{longtabu}

\begin{longtabu}spread 0pt [c]{*{4}{|X[-1]}|}
\hline
Column 1&Column 2&Column 3 &Column4 \\\cline{1-4}
Column 1&\multicolumn{2}{l|}{\hrule
 }&Column4 \\\cline{1-4}
Column 1&Column 2&Column 3 &Column4 \\\cline{1-4}
\end{longtabu}

\end{document}

The resulting image (going in batchmode on error):

enter image description here

In the second row of the second table I would like a line in the combined columns 2 and 3 like shown in the first table in row 2 column2.

I use the tabu package, I know that there are some problems with this package but I use the older version of Tex Live and for the 2019 version I use the "saved" tabu package (and friends).

1 Answer 1

3

Please use \hrulefill instead of \hrule

\documentclass[twoside]{book}

\usepackage{tabu}
\usepackage{longtable}

\begin{document}

\begin{longtabu}spread 0pt [c]{*{3}{|X[-1]}|}
\hline
Column 1&Column 2&Column 3 \\\cline{1-3}
Column 1&\hrule
&Column 3 \\\cline{1-3}
Column 1&Column 2&Column 3 \\\cline{1-3}
\end{longtabu}

\begin{longtabu}spread 0pt [c]{*{4}{|X[-1]}|}
\hline
Column 1&Column 2&Column 3 &Column4 \\\cline{1-4}
Column 1&\multicolumn{2}{c|}{\hrulefill} &Column4 \\\cline{1-4}
Column 1&Column 2&Column 3 &Column4 \\\cline{1-4}
\end{longtabu}

\end{document}

enter image description here

6
  • 1
    My problem is nor getting ride of the message but that I cannot give a \hrule inside a \multicolumn and I need to have a horizontal line here. Just removing the \hrule leaves still the missing line problem. Note: inside the table \hline doesn't work at all
    – albert
    Aug 29, 2019 at 11:54
  • 1
    @albert Refer the updated answer...
    – MadyYuvi
    Aug 29, 2019 at 11:58
  • Small understatement, this is much better.
    – albert
    Aug 29, 2019 at 12:02
  • I had to post a follow up question: interaction between \usepackage[table]{xcolor} and \hrulefill (tex.stackexchange.com/questions/506221/…)
    – albert
    Aug 29, 2019 at 12:45
  • Fine, its fine to go with a new question, but accept this answer is helpful for this question...
    – MadyYuvi
    Aug 29, 2019 at 12:56

You must log in to answer this question.

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