Beamer, Powerdot and KOMA-Script presentations, Conference posters (a0poster, baposter, tikzposter)
NELLLY
Posts: 113 Joined: Thu Nov 26, 2009 2:21 am
Post
by NELLLY » Sun Jul 31, 2016 12:44 am
Hello
I need to insert a colored tab in my beamer presentation. When I use the command \cline{2-3} in the following code, the white line separating the second and third column of the table does'nt appear. I tried also to use instead the command \hhline{~|-||-|} but also it doesn't work. What shoud I do?
Code: Select all
\documentclass[xcolor={dvipsnames}]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{marvosym} %
\usepackage{hyperref} %
\usepackage{transparent} %
\usepackage{ragged2e, siunitx, xcolor}
\usepackage{adjustbox, amsmath,booktabs}
\usepackage{tabularx,graphicx,rotating,subfigure,multirow,colortbl,hhline}
% \usepackage{enumitem}
\newcommand{\Min}{\operatornamewithlimits{Min}}
%\usepackage{etoolbox}
% \apptocmd{\frame}{\justifying}{}{}
\let\olditem\item
\renewcommand\item{\olditem\justifying}
\usepackage[english]{babel}
\usetheme{Warsaw}
\setbeamertemplate{caption}[numbered]
\hyphenpenalty 10000
\justifying
%\setbeamertemplate{footline}{\insertframenumber/\inserttotalframenumber}
\setbeamertemplate{footline}[frame number]
\begin{document}
\begin{frame}
\setlength{\tabcolsep}{1.5cm}
\begin{table}[bth]
\begin{center}
\caption{Level planning of the input parameters}
{\setlength\arrayrulewidth{1pt}
\arrayrulecolor{white}
\scalebox{0.8}{
\begin{tabular}{c|c|c}
\cellcolor{Blue} &\multicolumn{2}{c}{\cellcolor{Blue}{\color{white}Level}}\\ \cline{2-3}
\cellcolor{Blue}{\color{white}Model parameter}&\cellcolor{Blue}{\color{white}Low}&\cellcolor{Blue}{\color{white}High}\\\hline
\rowcolor{cyan!20}$A$&0.03&0.08 \\\hline
\rowcolor{cyan!20}$B$&0.5&1\\\hline
\end{tabular}}}
\end{center}
\end{table}
\end{frame}
\end{document}
Johannes_B
Site Moderator
Posts: 4182 Joined: Thu Nov 01, 2012 4:08 pm
Post
by Johannes_B » Sun Jul 31, 2016 4:03 pm
Personally, i think that coloured tables are pretty awkward. Especially with beamer, there are things that make it even more complicated to get a suitable ouotput. Honestly, i didn't manage to find a way to achieve what you want in reasonable time. So, following just the very standard table, that still needs fixing with beamer
Code: Select all
\documentclass[xcolor={dvipsnames},table]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{booktabs} %
%\usepackage{marvosym} %
%\usepackage{hyperref} %
%\usepackage{transparent} %
%\usepackage{ragged2e, siunitx,}
%\usepackage{adjustbox, amsmath,booktabs}
\usepackage{tabularx,graphicx,rotating,subfigure,multirow,hhline}
% \usepackage{enumitem}
\newcommand{\Min}{\operatornamewithlimits{Min}}
%\usepackage{etoolbox}
% \apptocmd{\frame}{\justifying}{}{}
% \let\olditem\item
% \renewcommand\item{\olditem\justifying}
% \usepackage[english]{babel}
\usetheme{Warsaw}
\setbeamertemplate{caption}[numbered]
% \hyphenpenalty 10000
% \justifying
%\setbeamertemplate{footline}{\insertframenumber/\inserttotalframenumber}
\setbeamertemplate{footline}[frame number]
\usepackage{etoolbox}
\makeatletter
\patchcmd\@cline
{\arrayrulewidth\hfill}% search
{\arrayrulewidth\hfill\kern\z@}% replace
{}% success
{\errmessage{Patching \string\@cline\space failed}}% failure
\patchcmd{\@cmidrulea}{\hfill}{\hfill\kern\z@}{}{}
\patchcmd{\@cmidruleb}{\hfill}{\hfill\kern\z@}{}{}
\makeatother
\begin{document}
\begin{frame}
\setlength{\tabcolsep}{1.5cm}
\begin{table}%[bth]
\centering
\caption{Level planning of the input parameters}
\setlength\arrayrulewidth{1pt}
\arrayrulecolor{white}
\scalebox{0.8}{
\begin{tabular}{c|c|c}
\cellcolor{Blue}
&\multicolumn{2}{c}{\cellcolor{Blue}{\color{white}Level}}\\
\hhline{~--}
\cellcolor{Blue}{\color{white}Model parameter}&\cellcolor{Blue}{\color{white}Low}&\cellcolor{Blue}{\color{white}High}\\\hline
\rowcolor{cyan!20}$A$&0.03&0.08 \\\hline
\rowcolor{cyan!20}$B$&0.5&1\\\hline
\end{tabular}}
\end{table}
\end{frame}
\begin{frame}
\arrayrulecolor{black}
\begin{table}%[bth]
\centering
\caption{Level planning of the input parameters}
\begin{tabular}{c@{\qquad}c@{\quad}c}
\toprule
Model parameter & \multicolumn{2}{c}{Level} \\
\cmidrule{2-3}
& Low & High \\
\midrule
$A$ & 0.03 & 0.08 \\
$B$ & 0.5 & 1\\
\bottomrule
\end{tabular}
\end{table}
\end{frame}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.