使用 tabularray 时,hline 的颜色会覆盖 vline

使用 tabularray 时,hline 的颜色会覆盖 vline

使用 tabularray,我尝试达到以下结果: 预期结果

但是,当使用 tabularray 执行此操作时:

\documentclass[8pt]{report}

\usepackage[utf8]{inputenc} %Accept different input encodings
\usepackage[T1]{fontenc} %Standard package for selecting font encodings.
\usepackage[UKenglish]{babel}
\usepackage{xcolor, colortbl} %Driver-independent color extensions.

\usepackage{tabularray} %Typeset Tabulars and Arrays with LATEX3
\usepackage{booktabs} % Required for nicer horizontal rules in tables

% Solid colors used by custom
\definecolor{customPink}{RGB}{255,000,255}
\definecolor{customLightBlue}{RGB}{034,181,255}
\definecolor{customYellow}{RGB}{255,194,000}
\definecolor{customDarkBlue}{RGB}{000,113,188}

\definecolor{customShadePink1}{RGB}{233,099,253}
\definecolor{customShadePurple1}{RGB}{155,086,244}
\definecolor{customShadeBlue1}{RGB}{087,129,242}

\definecolor{customGrey}{RGB}{128,128,128}
\definecolor{customGreyLight}{RGB}{243,243,234}

\definecolor{customGreyHeaderTable}{RGB}{230,230,230}
\definecolor{customGreyRowTable}{RGB}{250,250,250}

\begin{document}
    \begin{tblr}{
                    hline{1,Z} = {1pt,solid},
                    hline{2} = {1pt,solid,customGrey},
                    hline{3,Y} = {customGreyLight},
                    vline{1,Z} = {1pt,solid},
                    vline{2-Y} = {customGreyLight},
                    columns  = {l},
                    row{1}  = {bg=customGreyHeaderTable, fg=customShadePink1},
                    row{2-Z}= {bg=customGreyRowTable, fg=customGrey}
                }
        \textbf{Version} & \textbf{Date} & \textbf{Comment} & \textbf{Author} & \textbf{Reviewer} \\
        0.1 & 16-04-2023 & Creation of the document & ... & ... \\
        &  &  &  &  \\
        &  &  &  &  \\
    \end{tblr}
\end{document}

它给出以下输出: 当前结果

水平线越过第一条和最后一条垂直线,而我希望相反的方向突出外部边界。

在表格中,它可以保持原样,即我希望 hline 颜色优先于内部 vline 颜色。

提前致谢。

答案1

在参照这个答案您可以将选项rightpos=0和添加leftpos=0到相关hlines 中,使水平线在第一条垂直线之后开始并在最后一条垂直线之前结束。但是,其他垂直线仍将打印在水平线上:

\documentclass{report}
\usepackage{xcolor} 
\usepackage{tabularray}

\definecolor{customPink}{RGB}{255,000,255}
\definecolor{customShadePink1}{RGB}{233,099,253}
\definecolor{customGrey}{RGB}{128,128,128}
\definecolor{customGreyLight}{RGB}{243,243,234}
\definecolor{customGreyHeaderTable}{RGB}{230,230,230}
\definecolor{customGreyRowTable}{RGB}{250,250,250}

\begin{document}
    \begin{tblr}{
        hline{1,Z} = {1pt, solid},
        hline{2} = {1pt, solid, customGrey, leftpos=0, rightpos=0},
        hline{3,Y} = {customGreyLight, leftpos=0, rightpos=0},
        vline{1,Z} = {1pt, solid},
        vline{2-Y} = {customGreyLight},
        columns = {l},
        row{1} = {bg=customGreyHeaderTable, fg=customShadePink1},
        row{2-Z}= {bg=customGreyRowTable, fg=customGrey}
    }
    \textbf{Version} & \textbf{Date} & \textbf{Comment} & \textbf{Author} & \textbf{Reviewer} \\
    0.1 & 16-04-2023 & Creation of the document & ... & ... \\
    &  &  &  &  \\
    &  &  &  &  \\
    \end{tblr}
\end{document}

在此处输入图片描述

放大:

在此处输入图片描述

为了使粗灰色水平线覆盖表格内的细垂直线,您需要将其分成三个部分,从而导致更复杂的设置:

\documentclass{report}
\usepackage{xcolor} 
\usepackage{tabularray}

\definecolor{customPink}{RGB}{255,000,255}
\definecolor{customShadePink1}{RGB}{233,099,253}
\definecolor{customGrey}{RGB}{128,128,128}
\definecolor{customGreyLight}{RGB}{243,243,234}
\definecolor{customGreyHeaderTable}{RGB}{230,230,230}
\definecolor{customGreyRowTable}{RGB}{250,250,250}

\begin{document}
    \begin{tblr}{
        hline{1,Z} = {1pt, solid},
        hline{2} = {1}{1pt, solid, customGrey, leftpos=0},
        hline{2} = {2-Y}{1pt, solid, customGrey},
        hline{2} = {Z}{1pt, solid, customGrey, rightpos=0},
        hline{3,Y} = {customGreyLight, leftpos=0, rightpos=0},
        vline{1,Z} = {1pt, solid},
        vline{2-Y} = {customGreyLight},
        columns = {l},
        row{1} = {bg=customGreyHeaderTable, fg=customShadePink1},
        row{2-Z}= {bg=customGreyRowTable, fg=customGrey}
    }
    \textbf{Version} & \textbf{Date} & \textbf{Comment} & \textbf{Author} & \textbf{Reviewer} \\
    0.1 & 16-04-2023 & Creation of the document & ... & ... \\
    &  &  &  &  \\
    &  &  &  &  \\
    \end{tblr}
\end{document}

在此处输入图片描述

放大:

在此处输入图片描述

答案2

{NiceTabualar}供参考,这里有一种使用和 TikZ创建该表的方法nicematrix

\documentclass[8pt]{report}
\usepackage[T1]{fontenc} %Standard package for selecting font encodings.
\usepackage[UKenglish]{babel}
\usepackage{nicematrix,tikz}

\definecolor{customShadePink1}{RGB}{233,099,253}

\definecolor{customGrey}{RGB}{128,128,128}
\definecolor{customGreyLight}{RGB}{243,243,234}

\definecolor{customGreyHeaderTable}{RGB}{230,230,230}
\definecolor{customGreyRowTable}{RGB}{250,250,250}


\begin{document}

\color{customGrey}
\begin{NiceTabular}{lllll}[hvlines,rules/color=customGreyLight,cell-space-limits=3pt]
\CodeBefore
  \rowcolor{customGreyHeaderTable}{1}
  \rowcolor{customGreyRowTable}{2-*}
\Body
  \RowStyle[color=customShadePink1]{\bfseries}
      Version & Date & Comment & Author & Reviewer \\
      0.1 & 16-04-2023 & Creation of the document & ... & ... \\
      &  &  &  &  \\
      &  &  &  &  \\
\CodeAfter
  \tikz \draw [line width=1pt, color=customGrey] (2-|1) -- (2-|last) ; 
  \tikz \draw [line width=1pt,color=black] (1-|1) rectangle (last-|last) ; 
\end{NiceTabular}

\end{document}

上述代码的输出

相关内容