longtable 和 rowcolors

longtable 和 rowcolors

我尝试使用带有行颜色的长表,并且我只是简单地让它工作。当我尝试这样做时:

\documentclass[10pt, landscape]{report}
    %Packages
        \usepackage[utf8]{inputenc} 
        \usepackage[english, ngerman]{babel}
        \usepackage{booktabs}
        \usepackage{array}
            \newcounter{rowno}
            \setcounter{rowno}{0}
        \usepackage{longtable}
        \usepackage[table]{xcolor}  
    \begin{document} 
    \rowcolors{1}{gray!40!white}{blue!10!white} 
            \begin{longtable}{>{\stepcounter{rowno}\therowno.}c c l c l l l l }
            \hiderowcolors
            \multicolumn{1}{c}{No.} & Article & Word & Type & 3. Person & Präteritum & Perfect & Translation \\
            \toprule
            \endfirsthead
            \showrowcolors
            \hiderowcolors
            \multicolumn{1}{c}{No.} & Article & Word & Type & 3. Person & Präteritum & Perfect & Translation \\
            \toprule 
            \endhead
            \showrowcolors
            & --- & abdecken & verb & deckt ab & deckte ab & abgedeckt & to cover, \\ \midrule
            & --- & abholen & verb & holt ab & holte ab & abgeholte & to collect or pick up \\ \midrule 
    \end{longtable}
    \end{document}

我让每一行都变成相同的颜色 - 灰色。我尝试用它做不同的事情,但无济于事。

在此处输入图片描述

有人处理过类似的事情并有解决方案吗?

答案1

这是你的设置问题\show/hiderowcolors。这有效:

\documentclass[10pt, landscape]{report}
    %Packages
        \usepackage[utf8]{inputenc} 
        \usepackage[english, ngerman]{babel}
        \usepackage{booktabs}
        \usepackage{array}
            \newcounter{rowno}
            \setcounter{rowno}{0}
        \usepackage{longtable}
        \usepackage[table]{xcolor}  
    \begin{document} 
    \rowcolors{3}{gray!40!white}{blue!40!white!80} 
            \begin{longtable}{>{\stepcounter{rowno}\therowno.}c c l c l l l l }
            \multicolumn{1}{c}{No.} & Article & Word & Type & 3. Person & Präteritum & Perfect & Translation \\\toprule
            \endfirsthead
            \multicolumn{1}{c}{No.} & Article & Word & Type & 3. Person & Präteritum & Perfect & Translation \\
            \toprule 
            \endhead
            & --- & abdecken & verb & deckt ab & deckte ab & abgedeckt & to cover, \\
            & --- & abholen & verb & holt ab & holte ab & abgeholte & to collect or pick up\\             & --- & abholen & verb & holt ab & holte ab & abgeholte & to collect or pick up\\             & --- & abholen & verb & holt ab & holte ab & abgeholte & to collect or pick up\\ \bottomrule 
    \end{longtable}
    \end{document}

在此处输入图片描述

答案2

事实上,这似乎\midrule就是问题所在。当我删除 \show/hidecolors 时,我什么也没做,但是删除后\midrule一切都正常了

相关内容