5

The code below results in the image below.

\documentclass{beamer}
\usetheme{Montpellier}
\usecolortheme[named=gray]{structure}
\usepackage{colortbl}
\usepackage{array}
\newcommand{\gr}[1]{\textcolor{gray}{#1}}
\begin{document}
\definecolor{light-gray}{gray}{0.92}
\frame{
%\arrayrulecolor{light-gray}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|>{\raggedright}m{2.45cm}|>{\raggedright\arraybackslash}m{3.4cm}
|>{\raggedright\arraybackslash}m{3.63cm}|}\cline{2-3}
\multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\gr{short}} & \multicolumn{1}{c|}{\gr{short}}\\\hline
\gr{short text} & very, very long text here & very, very long text here\\\hline
\end{tabular}
}
\end{document}

black rules

When I try to change the arrayrulecolor to light-gray (by removing the percent symbol at the start of line 10), I get the image below. Note that the top rule has disappeared. light-gray

I tried using the hhline package and replacing \cline{2-3} with \hhline{~|-|-|} but I get the same results.

How do I get the table in the first image but with the rule color set to light gray? I am using pdfLaTeX.

2
5

There seems to be problems with coloured \clines in beamer. Here is a workaround, using \cmidrule from booktabs. I had to neutralise the vertical padding below the rule. I simplified a bit the code: instead of loading colortbl, I added the table option to beamer, which passses it to xcolor, which loads colortbl.

\documentclass[table]{beamer}
\usetheme{Montpellier}
\usecolortheme[named=gray]{structure}
\usepackage{array, booktabs}
\newcommand{\gr}[1]{\textcolor{gray}{#1}}

\begin{document}

\definecolor{light-gray}{gray}{0.92}
\frame{\arrayrulecolor{light-gray}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|>{\raggedright}m{2.45cm}|>{\raggedright\arraybackslash}m{3.4cm}
|>{\raggedright\arraybackslash}m{3.63cm}|}
 \cmidrule{2-3}\noalign{\vskip -\belowrulesep}
\multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\gr{short}} & \multicolumn{1}{c|}{\gr{short}}\\\hline
\gr{short text} & very, very long text here & very, very long text here\\\hline
\end{tabular}
}

\end{document} 

enter image description here

3
  • Erm, your code does not quite correspond to the description you give in the text...
    – campa
    Aug 14 '20 at 12:29
  • @campa: Oh! es. A copy-paste accident again! I should have checked. Fixed it. Thank you for pointing it!
    – Bernard
    Aug 14 '20 at 12:34
  • Thank you very much. It works perfectly. Aug 14 '20 at 13:38
4

You can obtain what you want directly with {NiceTabular} of nicematrix. A key hvlines draws all the expected rules excepted in the corners (specified by corners).

\documentclass{beamer}
\usetheme{Montpellier}
\usecolortheme[named=gray]{structure}

\usepackage{nicematrix}

\begin{document}

\begin{frame}
\renewcommand{\arraystretch}{1.2}
\begin{NiceTabular} [ rules/color=gray!20 , corners = NW , hvlines ]
  {wl{2.45cm}m[l]{3.4cm}m[l]{3.63cm}}
\RowStyle{\color{gray}\centering}
                & short & short \\
short text & very, very long text here & very, very long text here\\
\end{NiceTabular}
\end{frame}

\end{document}

Ouput of the above code

0
1

Following the informations given in this question, here is a patch of \cline (in fact \@cline which is used by \cline) which solves the problem.

The command \cline is defined in standard LaTeX. It's not overwritten by the package array but it is by the package colortbl.

In the following code, I have added kern \z@ in the redefinition done by colortbl.

\documentclass{beamer}
\usetheme{Montpellier}
\usecolortheme[named=gray]{structure}
\usepackage{colortbl}
\usepackage{array}
\newcommand{\gr}[1]{\textcolor{gray}{#1}}

\makeatletter
\def\@cline#1-#2\@nil{%
\omit
\@multicnt#1%
\advance\@multispan\m@ne
\ifnum\@multicnt=\@ne\@firstofone{&\omit}\fi
\@multicnt#2%
\advance\@multicnt-#1%
\advance\@multispan\@ne
{\CT@arc@ \leaders\hrule\@height\arrayrulewidth\hfill\kern\z@}%
\cr
\noalign{\vskip-\arrayrulewidth}}
\makeatother

\begin{document}
\definecolor{light-gray}{gray}{0.92}
\frame{
\arrayrulecolor{light-gray}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|>{\raggedright}m{2.45cm}|>{\raggedright\arraybackslash}m{3.4cm}
|>{\raggedright\arraybackslash}m{3.63cm}|}\cline{2-3}
\multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\gr{short}} & \multicolumn{1}{c|}{\gr{short}}\\\hline
\gr{short text} & very, very long text here & very, very long text here\\\hline
\end{tabular}
}
\end{document}

Ouput of the above code

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.