7

The following example works as expected:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{makecell, multirow}
    \renewcommand\theadfont{\normalsize\bfseries\color{white}}
    \renewcommand{\theadgape}{}
\usepackage{hhline}

\begin{document}
\centering
    \setlength\arrayrulewidth{2pt}
    \arrayrulecolor{yellow}
    \def\clinecolor{\hhline{>{\arrayrulecolor{yellow}}--%
                            >{\arrayrulecolor{gray}}-}}
    \setlength\extrarowheight{2pt}
\begin{tabular}{ c | c | c }%
    \rowcolor{gray}
\multicolumn{2}{c|}{\thead{AAA -- BBBB}}    &                                   \\
    \clinecolor
    \rowcolor{gray}
\color{white} AAA   &   \color{white} BBB   &   \multirow{-2}{*}{\thead{CCC}}   \\
    \hhline{>{\arrayrulecolor{yellow}}-|-|-}
    \rowcolor{gray!25}
aaa                 &   bbb                 &   ccc                             \\
    \hline
    \rowcolor{gray!25}
ddd             &   eee                 &   fff
    \end{tabular}
\end{document}

Enter image description here

But the following not:

\documentclass[xcolor=table]{beamer}
\usepackage{makecell, multirow}
    \renewcommand\theadfont{\normalsize\bfseries\color{white}}
    \renewcommand{\theadgape}{}
\usepackage{hhline}

\begin{document}
\begin{frame}
\frametitle{test}
\centering
    \setlength\arrayrulewidth{2pt}
    \arrayrulecolor{yellow}
    \def\clinecolor{\hhline{>{\arrayrulecolor{yellow}}--%
                            >{\arrayrulecolor{gray}}-}}
    \setlength\extrarowheight{2pt}
\begin{tabular}{ c | c | c }%
    \rowcolor{gray}
\multicolumn{2}{c|}{\thead{AAA -- BBBB}}    &                                   \\
    \clinecolor
    \rowcolor{gray}
\color{white} AAA   &   \color{white} BBB   &   \multirow{-2}{*}{\thead{CCC}}   \\
    \hhline{>{\arrayrulecolor{yellow}}-|-|-}
    \rowcolor{gray!25}
aaa                 &   bbb                 &   ccc                             \\
    \hline
    \rowcolor{gray!25}
ddd             &   eee                 &   fff                             \\
    \hhline{|-|-|-|}
    \end{tabular}
\end{frame}
\end{document}

Enter image description here

Why are the in beamer rules so strangely misplaced? Is there some workaround?

Zarko
  • 296,517
  • maybe related: https://chat.stackexchange.com/transcript/41?m=41452490#41452490 ??? – samcarter_is_at_topanswers.xyz Dec 06 '17 at 14:37
  • @samcarter, yes, it seems that my question is related to the same problem. means, that i (we) should wait on fix in beamer. hopefully this will happen soon :-). btw, my question is based on one one similar question where i try to help, but i was surprised that solution done for article doesn't work in beamer. – Zarko Dec 06 '17 at 15:35
  • related bug report: https://github.com/josephwright/beamer/issues/434 – samcarter_is_at_topanswers.xyz Dec 08 '17 at 09:23
  • @samcarter, please see my answer on similar question https://tex.stackexchange.com/questions/404661/fancy-table-multicol-and-multirow/405021#405021, in it i was faced with \hhline coloring problem (border of lines is still visible). so far i havent time to investigate, what is going on (is this only viewer artifact?). eventually i will ask new question about his. – Zarko Dec 08 '17 at 09:37
  • I put a comment there - my guess would be viewer artefact. – samcarter_is_at_topanswers.xyz Dec 08 '17 at 09:45

4 Answers4

9

enter image description here

as samcarter commented

\documentclass[xcolor=table]{beamer}
\usepackage{makecell, multirow}
    \renewcommand\theadfont{\normalsize\bfseries\color{white}}
    \renewcommand{\theadgape}{}
\usepackage{hhline}
\makeatletter
\let\zz\reset@color
\def\reset@color{\kern\z@\zz}
\makeatother

\begin{document}
\begin{frame}
\frametitle{test}
\centering
    \setlength\arrayrulewidth{2pt}
    \arrayrulecolor{yellow}
    \def\clinecolor{\hhline{>{\arrayrulecolor{yellow}}--%
                            >{\arrayrulecolor{gray}}-}}
    \setlength\extrarowheight{2pt}
\begin{tabular}{ c | c | c }%
    \rowcolor{gray}
\multicolumn{2}{c|}{\thead{AAA -- BBBB}}    &                                   \\
    \clinecolor
    \rowcolor{gray}
\color{white} AAA   &   \color{white} BBB   &   \multirow{-2}{*}{\thead{CCC}}   \\
    \hhline{>{\arrayrulecolor{yellow}}-|-|-}
    \rowcolor{gray!25}
aaa                 &   bbb                 &   ccc                             \\
    \hline
    \rowcolor{gray!25}
ddd             &   eee                 &   fff                             \\
    \hhline{|-|-|-|}
    \end{tabular}
\end{frame}
\end{document}
David Carlisle
  • 757,742
  • thank you very much! i'm curious, which package should have this patch? beamer? can we expect that it will be incorporate in it soon? – Zarko Dec 06 '17 at 17:48
  • 1
    that isn't actually the right patch (but it's Ok and easiest to do in the document) beamer will probably change not to mess with \reset@font but also i'll probably change hhline and colortbl to protect themselves from the \unskip that beamer is adding. but no promise on an update this side of christmas. @Zarko – David Carlisle Dec 06 '17 at 18:27
  • thank you for explanation. it is not rush for this solution ... i only wondering, why use of rules from booktabs hasn't this problem (see Bernard answer). – Zarko Dec 06 '17 at 18:59
  • 1
    @Zarko because they are rules (and rules don't get removed by \unskip) but colortbl and hhline make interesting (brilliantly ingenious:-) use of \leaders and leaders are removed by \unskip. – David Carlisle Dec 06 '17 at 19:22
  • @DavidCarlisle As far as I can see, the problem still exists. Am I right? (I realize you didn't say which christmas :)) – Martin J. Osborne Feb 16 '20 at 03:53
  • @DavidCarlisle I believe this problem still exists. If there is not an upcoming patch, it would perhaps be helpful to acknowledge this issue in the documentation to save people like me from struggling to figure out why it wasn't working for several hours... :-/ – Tyler May 22 '20 at 06:41
  • 1
    @MightyTyGuy I think the correct fix is should be in beamer over which I have no control but I could add a guard to colortbl's hhline I guess (but really hhline should have no reason to expect to need a guard there, I think) – David Carlisle May 22 '20 at 08:31
  • @DavidCarlisle I see. Has this issue already been reported to the maintainers of beamer? – Tyler May 22 '20 at 17:12
4

Use booktabs instead – more precisely set \above/belowrulesep to 0pt and use \midrule:

\documentclass[xcolor=table]{beamer}
\usepackage{makecell, multirow}
\usepackage{booktabs}
\renewcommand\theadfont{\normalsize\bfseries\color{white}}
\renewcommand{\theadgape}{}

\begin{document}

\begin{frame}
  \frametitle{test}
  \centering
  \setlength\arrayrulewidth{2pt}
  \setlength\extrarowheight{2pt}
  \setlength\belowrulesep{0pt}\setlength\aboverulesep{0pt}
  \setlength\lightrulewidth{2pt}
  \arrayrulecolor{yellow}
  \begin{tabular}{ c | c | c }%
    \rowcolor{gray}
    \multicolumn{2}{c|}{\thead{AAA -- BBBB}} & \\
    \midrule
    \rowcolor{gray}
    \color{white} AAA & \color{white} BBB & \multirow{-2}{*}{\thead{CCC}} \\
    \midrule
    \rowcolor{gray!25}
    aaa & bbb & ccc \\
    \midrule
    \rowcolor{gray!25}
    ddd & eee & fff \\
  \end{tabular}
\end{frame}

\end{document} 

enter image description here

Bernard
  • 271,350
  • good to know, that booktabs rule interact with colortbl ([table]{xcolor}) very diferently than standard \hline or \hhline. – Zarko Dec 06 '17 at 17:50
3

A variant with the tabularray package:

\documentclass{beamer}
\usepackage{tabularray}

\begin{document}

\begin{frame} \centering \begin{tblr}{ colspec={ccc}, row{1-2}={bg=gray,fg=white}, row{1}={font=\bfseries}, row{3-Z}={bg=lightgray}, hline{2-Y}={yellow,wd=2pt}, vline{2-Y}={yellow,wd=2pt}, } \SetCell[c=2]{} AAA - BBBB & & \SetCell[r=2]{} CCC \ AAA & BBB & \ aaa & bbb & ccc \ ddd & eee & fff \end{tblr}

\end{frame}

\end{document}

enter image description here

2

With {NiceTabular} of nicematrix, you have a key hvlines-except-borders to draw all the rules, excepted on the borders and in the blocks (created by \Block).

\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix}

\begin{document}

\begin{center}

\arrayrulecolor{yellow} \setlength{\arrayrulewidth}{2pt} \setlength{\extrarowheight}{2pt} \setlength{\tabcolsep}{10pt}

\begin{NiceTabular}{ccc}[hvlines-except-borders] \RowStyle[nb-rows=2,color=white,rowcolor=gray]{} \RowStyle[bold]{} \Block{1-2}{AAA - BBBB} & & \Block{2-1}{CCC} \ AAA & BBB \ \RowStyle[nb-rows=2,rowcolor=gray!25]{} aaa & bbb & ccc \ ddd & eee & fff \end{NiceTabular}

\arrayrulecolor{black} \end{center}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the first code

The result may seem disappointing. The vertical rules protrude below the array by a length equal to \arrayrulewidth by design... It's useful to have perfect joins with vertical rules in the most common situations...

However, with nicematrix (version ≥ 6.12), it's possible to draw a white rule at the end with \Hline[color=white].

\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix,tikz}

\begin{document}

\begin{center}

\arrayrulecolor{yellow} \setlength{\arrayrulewidth}{2pt} \setlength{\extrarowheight}{2pt} \setlength{\tabcolsep}{10pt}

\begin{NiceTabular}{ccc}[hvlines-except-borders] \RowStyle[nb-rows=2,color=white,rowcolor=gray]{} \RowStyle[bold]{} \Block{1-2}{AAA - BBBB} & & \Block{2-1}{CCC} \ AAA & BBB \ \RowStyle[nb-rows=2,rowcolor=gray!25]{} aaa & bbb & ccc \ ddd & eee & fff \Hline[color=white] \end{NiceTabular}

\arrayrulecolor{black} \end{center}

\end{document}

Output of the second code

But there is another way. It's possible to define a new type of rule with its letter (I) and its command \MyLine and use it in the preamble and between the rows.

\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix,tikz}

\NiceMatrixOptions { custom-line = { letter = I , command = MyLine , total-width = 2pt , tikz = { line width = 2pt , yellow } } }

\begin{document}

\begin{center} \setlength{\arrayrulewidth}{0pt} \begin{NiceTabular}{cIcIc}[columns-width=15mm,cell-space-limits=3pt] \RowStyle[nb-rows=2,color=white,rowcolor=gray]{} \RowStyle[bold]{} \Block{1-2}{AAA - BBBB} & & \Block{2-1}{CCC} \ \MyLine AAA & BBB \ \MyLine \RowStyle[nb-rows=2,rowcolor=gray!25]{} aaa & bbb & ccc \ \MyLine ddd & eee & fff \end{NiceTabular}

\arrayrulecolor{black} \end{center}

\end{document}

Output of the above code

Now, the vertical rules protrude below the array by a value of \arrayrulewidth but the value of \arrayrulewidth is zero. So, the output is perfect.

F. Pantigny
  • 40,250