使用 `colortbl` 包的列颜色 - 手册中的示例 4

使用 `colortbl` 包的列颜色 - 手册中的示例 4

我正在尝试重新生成手册第 2-3 页上的彩色示例 colortbl包裹,请参见下面的屏幕截图。(请注意,该表格跨越两页)。

在此处输入图片描述

手册中写道:

这个例子看起来有点低俗,但颜色却很鲜艳!检查源文件,彩色表.dtx,查看示例的完整代码,但它使用了以下列类型。

在下面的代码中我提取了(来自彩色表.dtx) 我认为相关的代码部分。但是,代码无法编译。我留下了一长串错误。有人能确定(代码)错误在哪里吗?

\documentclass{article}

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

% Before starting give a little space: 
\setlength\minrowclearance{2pt}

% This example shows rather poor taste but is quite colourful! Inspect the source
% file, colortbl.dtx, to see the full code for the example, but it uses the following
% column types. 

\newcolumntype{A}{%
    >{\color{white}\columncolor{red}[.5\tabcolsep]%
        \raggedright}%
    p{2cm}}

\newcolumntype{B}{%
    >{\columncolor{blue}[.5\tabcolsep]%
        \color{yellow}\raggedright}
    p{3cm}}

\newcolumntype{C}{%
    >{\columncolor{yellow}[.5\tabcolsep]}%
    D{.}{\cdot}{3.3}}

\newcolumntype{E}{%
    >{\large\bfseries
        \columncolor{cyan}[.5\tabcolsep]}c}

\newcolumntype{F}{%
    >{\color{white}
        \columncolor{magenta}[.5\tabcolsep]}c}

\newcolumntype{G}{%
    >{\columncolor[gray]{0.8}[.5\tabcolsep][\tabcolsep]}l}

\newcolumntype{H}{>{\columncolor[gray]{0.8}}l}

\newcolumntype{I}{%
    >{\columncolor[gray]{0.8}[\tabcolsep][.5\tabcolsep]}%
    D{.}{\cdot}{3.3}}


\begin{document}

% The code below is directly extracted from colortbl.dtx
% http://tug.ctan.org/macros/latex2e/contrib/colortbl/colortbl.dtx

\begin{longtable}{ABC}
    \multicolumn{3}{E}{A long table example}\\
    \multicolumn{2}{F}{First two columns}&
    \multicolumn{1}{F}{Third column}\\
    \multicolumn{2}{F}{p-type}&
    \multicolumn{1}{F}{D-type (\textsf{dcolumn})}\endfirsthead
    \multicolumn{3}{E}{A long table example (continued)}\\
    \multicolumn{2}{F}{First two columns}&
    \multicolumn{1}{F}{Third column}\\
    \multicolumn{2}{F}{p-type}&
    \multicolumn{1}{F}{D-type (\textsf{dcolumn})}\endhead
    \multicolumn{3}{E}{Continued\ldots}\endfoot
    \multicolumn{3}{E}{The End}\endlastfoot
    P-column&and another one&12.34\\
    \multicolumn{1}{G}{Total}&
    \multicolumn{1}{H}{(wrong)}&
    \multicolumn{1}{I}{100.6}\\
    Some long text in the first column&bbb&1.2\\
    aaa&and some long text in the second column&1.345\\
    \multicolumn{1}{G}{Total}&
    \multicolumn{1}{H}{(wrong)}&
    \multicolumn{1}{I}{100.6}\\
    aaa&bbb&1.345\\
    Note that the coloured rules in all columns stretch to accomodate
    arge entries in one column. &bbb&1.345\\
    aaa&bbb&100\\
    aaa&Depending on your driver you may get unsightly gaps or lines
    where the  `screens' used to produce different shapes interact
    badly. You may want to cause adjacent panels of the same colour by
    specifying a larger overhang 
    or by adding some negative space (in a "\noalign" between rows.&12.4\\
    aaa&bbb&45.3\\
\end{longtable}


\end{document}

请注意,这是一个继续上一篇文章讨论了手册中的前三个表格。

答案1

您需要dcolumnD 列和\verb"\noalign"最后一行文本的逐字文本的包。

直接来自印刷品味的 Egreg 学校:

在此处输入图片描述

相关内容