1

This is a followup question on horizontal rule / line inside a multicolumn field In the later the problem regarding the horizontal line was solved but whe using the

\usepackage[table]{xcolor}

the required line does not span the combined cells but just the first:

The MWE:

\documentclass[twoside]{book}

\usepackage{tabu}
\usepackage{longtable}
\usepackage[table]{xcolor}

\begin{document}

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

\end{document}

This results in the wrong output as the horizonatl line is only in the first part of the combined cells:

enter image description here

The expected output is:

enter image description here

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).

3
  • 1
    The issue can be reproduced with \begin{tabular}{*4c} instead of longtabu and loading only colortbl (which is loaded by the table option of xcolor). Aug 29, 2019 at 12:52
  • You should report this issue to the author of colortabl. It is either a feature or a bug.
    – Sveinung
    Aug 29, 2019 at 12:56
  • @PhelypeOleinik I removed my initial comment as I realized that colortbl would give the same problems. Thanks for the reply on loading the complete xcolor.
    – albert
    Aug 29, 2019 at 12:59

2 Answers 2

3

The problem is that colortbl uses fill glue where the LaTeX kernel only uses fil glue.

You need a “more infinite” \hrulefill:

\documentclass[twoside]{book}

\usepackage{tabu}
\usepackage{longtable}
\usepackage[table]{xcolor}

\makeatletter
\newcommand\hrulefilll{\leavevmode\leaders\hrule\hskip 0pt plus 1filll\kern\z@}
\makeatother

\begin{document}

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

\bigskip

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

\end{document}

Compile with an old TeX Live.

enter image description here

3
  • Nice explanation @egreg thanks for sharing ...
    – MadyYuvi
    Aug 29, 2019 at 13:23
  • Thanks for the answer, Do you think the problem is a feature or a bug? Should I make an issue at github.com/davidcarlisle/dpctex/issues ?
    – albert
    Aug 29, 2019 at 13:23
  • @albert A feature.
    – egreg
    Aug 29, 2019 at 13:36
0

When not using:

\usepackage[table]{xcolor}

but

\usepackage{xcolor}

the line looks lie to be complete again.

MWE:

\documentclass[twoside]{book}

\usepackage{tabu}
\usepackage{longtable}
\usepackage{xcolor}

\begin{document}

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

\end{document}
5
  • Strange…Just loading xcolor produces a ! Missing } inserted.error message for me.
    – Bernard
    Aug 29, 2019 at 12:57
  • Strange I don't get an error. I'm using (for my tests) MiKTeX-pdfTeX 2.9.6839 (1.40.19) (MiKTeX 2.9.6840 64-bit)
    – albert
    Aug 29, 2019 at 13:01
  • I have MiKTeX 2.9.7140 and tabu from 11-1-2019. For me, it looks like an incompatibility between xcolor and tabu. Furthermore, using something like \color{red} inside a cell with ordinary text, without loading xcolor, compiles just fine but… produces no text colouring.
    – Bernard
    Aug 29, 2019 at 13:08
  • The newer tabu versions have some problems that is why I wrote the last line in my question. The problem is widely discussed here and also indicated at github.com/tabu-issues-for-future-maintainer/tabu. Looks like you run in some of those problems as you use a newer version.
    – albert
    Aug 29, 2019 at 13:21
  • Thanks for the link. Happily enough, usually I do without tabu!
    – Bernard
    Aug 29, 2019 at 13:24

You must log in to answer this question.

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