LaTeX forum ⇒ Presentations and Posters\cline command in a colored table

Beamer, Powerdot and KOMA-Script presentations, Conference posters (a0poster, baposter, tikzposter)
NELLLY
Posts: 113
Joined: Thu Nov 26, 2009 2:21 am

\cline command in a colored table

Postby 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?


  1. \documentclass[xcolor={dvipsnames}]{beamer}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage{marvosym} %
  4. \usepackage{hyperref} %
  5. \usepackage{transparent} %
  6. \usepackage{ragged2e, siunitx, xcolor}
  7. \usepackage{adjustbox, amsmath,booktabs}
  8. \usepackage{tabularx,graphicx,rotating,subfigure,multirow,colortbl,hhline}
  9. % \usepackage{enumitem}
  10. \newcommand{\Min}{\operatornamewithlimits{Min}}
  11.  
  12. %\usepackage{etoolbox}
  13. % \apptocmd{\frame}{\justifying}{}{}
  14. \let\olditem\item
  15. \renewcommand\item{\olditem\justifying}
  16. \usepackage[english]{babel}
  17. \usetheme{Warsaw}
  18. \setbeamertemplate{caption}[numbered]
  19. \hyphenpenalty 10000
  20. \justifying
  21. %\setbeamertemplate{footline}{\insertframenumber/\inserttotalframenumber}
  22. \setbeamertemplate{footline}[frame number]
  23.  
  24. \begin{document}
  25. \begin{frame}
  26. \setlength{\tabcolsep}{1.5cm}
  27.  
  28. \begin{table}[bth]
  29. \begin{center}
  30. \caption{Level planning of the input parameters}
  31. {\setlength\arrayrulewidth{1pt}
  32. \arrayrulecolor{white}
  33.  
  34. \scalebox{0.8}{
  35. \begin{tabular}{c|c|c}
  36. \cellcolor{Blue} &\multicolumn{2}{c}{\cellcolor{Blue}{\color{white}Level}}\\ \cline{2-3}
  37. \cellcolor{Blue}{\color{white}Model parameter}&\cellcolor{Blue}{\color{white}Low}&\cellcolor{Blue}{\color{white}High}\\\hline
  38.  
  39. \rowcolor{cyan!20}$A$&0.03&0.08 \\\hline
  40. \rowcolor{cyan!20}$B$&0.5&1\\\hline
  41.  
  42. \end{tabular}}}
  43. \end{center}
  44. \end{table}
  45. \end{frame}
  46.  
  47. \end{document}

User avatar
Johannes_B
Site Moderator
Posts: 3803
Joined: Thu Nov 01, 2012 4:08 pm

Postby 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 :-(

  1. \documentclass[xcolor={dvipsnames},table]{beamer}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage{booktabs} %
  4. %\usepackage{marvosym} %
  5. %\usepackage{hyperref} %
  6. %\usepackage{transparent} %
  7. %\usepackage{ragged2e, siunitx,}
  8. %\usepackage{adjustbox, amsmath,booktabs}
  9. \usepackage{tabularx,graphicx,rotating,subfigure,multirow,hhline}
  10. % \usepackage{enumitem}
  11. \newcommand{\Min}{\operatornamewithlimits{Min}}
  12.  
  13. %\usepackage{etoolbox}
  14. % \apptocmd{\frame}{\justifying}{}{}
  15. % \let\olditem\item
  16. % \renewcommand\item{\olditem\justifying}
  17. % \usepackage[english]{babel}
  18. \usetheme{Warsaw}
  19. \setbeamertemplate{caption}[numbered]
  20. % \hyphenpenalty 10000
  21. % \justifying
  22. %\setbeamertemplate{footline}{\insertframenumber/\inserttotalframenumber}
  23. \setbeamertemplate{footline}[frame number]
  24.  
  25. \usepackage{etoolbox}
  26. \makeatletter
  27. \patchcmd\@cline
  28. {\arrayrulewidth\hfill}% search
  29. {\arrayrulewidth\hfill\kern\z@}% replace
  30. {}% success
  31. {\errmessage{Patching \string\@cline\space failed}}% failure
  32. \patchcmd{\@cmidrulea}{\hfill}{\hfill\kern\z@}{}{}
  33. \patchcmd{\@cmidruleb}{\hfill}{\hfill\kern\z@}{}{}
  34. \makeatother
  35. \begin{document}
  36. \begin{frame}
  37. \setlength{\tabcolsep}{1.5cm}
  38.  
  39. \begin{table}%[bth]
  40. \centering
  41. \caption{Level planning of the input parameters}
  42. \setlength\arrayrulewidth{1pt}
  43. \arrayrulecolor{white}
  44. \scalebox{0.8}{
  45. \begin{tabular}{c|c|c}
  46. \cellcolor{Blue}
  47. &\multicolumn{2}{c}{\cellcolor{Blue}{\color{white}Level}}\\
  48. \hhline{~--}
  49. \cellcolor{Blue}{\color{white}Model parameter}&\cellcolor{Blue}{\color{white}Low}&\cellcolor{Blue}{\color{white}High}\\\hline
  50.  
  51. \rowcolor{cyan!20}$A$&0.03&0.08 \\\hline
  52. \rowcolor{cyan!20}$B$&0.5&1\\\hline
  53.  
  54. \end{tabular}}
  55. \end{table}
  56. \end{frame}
  57.  
  58.  
  59.  
  60.  
  61. \begin{frame}
  62.  
  63. \arrayrulecolor{black}
  64. \begin{table}%[bth]
  65. \centering
  66. \caption{Level planning of the input parameters}
  67.  
  68. \begin{tabular}{c@{\qquad}c@{\quad}c}
  69. \toprule
  70. Model parameter & \multicolumn{2}{c}{Level} \\
  71. \cmidrule{2-3}
  72. & Low & High \\
  73. \midrule
  74. $A$ & 0.03 & 0.08 \\
  75. $B$ & 0.5 & 1\\
  76. \bottomrule
  77. \end{tabular}
  78. \end{table}
  79. \end{frame}
  80.  
  81. \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.


Return to “Presentations and Posters”

Who is online

Users browsing this forum: No registered users and 1 guest