Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplest MWE to have an alternating row color #18

Open
DAbidou opened this issue May 2, 2019 · 2 comments
Open

Simplest MWE to have an alternating row color #18

DAbidou opened this issue May 2, 2019 · 2 comments

Comments

@DAbidou
Copy link

DAbidou commented May 2, 2019

I tried in this question to make the simplest document having a table with an alternating row color but it didn't work as expected. I thought loading some packages might be needed (e.g. xcolor, colortbl) but nothing changed.

So, I have two questions: 1. why didn't my code work? 2. what are the required packages to get the job done in the easiest way?

\documentclass{article}
\usepackage{tabularx,booktabs,tabu,amsmath,colortbl}
\usepackage[table]{xcolor}

\begin{document}
\begin{tabu} to \linewidth {@{}*3{X[c]}@{}}
    \taburowcolors [1] 2{gray!10 .. white}
    \toprule
    5 & 6 & 7\\
    5 & 6 & 7\\
    \bottomrule
\end{tabu}
\end{document}

Untitled

@muzimuzhi
Copy link

A simpler mwe:

  • loads packages tabu, xcolor, and colortbl only, and
  • uses \rowcolor inside tabu environment
\documentclass{article}
\usepackage{tabu}
\usepackage[table]{xcolor}

\begin{document}
\begin{tabu}{l}
  \rowcolor{blue} in tabu \\ wrong
\end{tabu}

\begin{tabular}{l}
  \rowcolor{blue} in tabular \\ all right
\end{tabular}
\end{document}

Further more, I found the problem is concerned with modifications done by tabu-fix about "defining classz to use vcenter, reverting a change in array package". \rowcolor will recover from canceling the function of \tabu@classz as following lines, (and this change of course may cause other problems)

\def\tabu@classz{%
%  \ifx\tabu@prepnext@tok\prepnext@tok% in tabu
%    \expandafter\tabu@classz@oldarray
%  \else
    \tabu@classzORI
%  \fi
}%

I hardly know any thing about the kernel of tabular things in LaTeX, hence this comment is just an amateur attempt. The TeX Live used on overleaf.com is still at version 2017, and is free-of-bug on this problem, which may help compare and debug.

Some of my version info:

texlive 2019
    tabu.sty    2019/01/11 v2.9
   array.sty    2018/12/30 v2.4k
colortbl.sty    2018/12/12 v1.0d

meneldal added a commit to meneldal/tabu that referenced this issue May 13, 2019
Follow proposed resolution of background color bug tabu-issues-for-future-maintainer#18 (comment)
@c-alpha
Copy link

c-alpha commented Oct 4, 2019

According to my experiments, TeX Live 2017 is the last version where \rowcolor{} works as expected. If you still have that installed, open the TeX Live Utility and set the default TeX Live version to 2017 as a workaround. Versions 2018 and 2019 exhibit the error described in this issue.

In case it helps, the versions are:

Package Tex Live 2017 TeX Live 2018
tabu.sty 2011/02/26 v2.8 2019/01/11 v2.9
array.sty 2016/10/06 v2.4d 2018/12/30 v2.4k
colortbl.sty 2012/02/13 v1.0a 2018/12/12 v1.0d

I'm currently investigating the xltabular package, which seems a fairly recent addition, and does multi-page tables as well as X columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants