1

in tabular, multicolor is not working properly. and vertical line is generated in the first cell, Does anybody know, how to remove the vertical line AND distribute its content in the column and the row ?

\begin{table}
 \adjustbox{minipage=\mylength,center}
     \caption{long text.}   
     \resizebox{\columnwidth}{!} {
     
      \renewcommand{\arraystretch}{3}
      
       \newcolumntype{G}{>{\centering} m{1.4cm}}
       \newcolumntype{H}{>{\centering} m{1.2cm}}
          
        
        \begin{tabular}{|H|H|G|G|G|G|G|G|}
        \hline
    
    
    \rowcolor{blue}
    \multicolumn{2}{|c|}{\textbf{long texte}}
    &\multicolumn{2}{c|}{\textbf{long}} 
    &\multicolumn{2}{c|}{\textbf{long}} 
    &\multicolumn{2}{c|}{\textbf{long}}  \\ 
    \cline{2-8}

    \rowcolor{lilad!15}
    
    &
    &\textbf{\textcolor{blue}{\small long }} 
    &\textbf{\textcolor{orange}{\small long }}
    &\textbf{\textcolor{blue}{\small long }} 
    &\textbf{\textcolor{orange}{\small long }}
    &\textbf{\textcolor{blue}{\small long }}
    &\textbf{\textcolor{orange}{\small long}}\tabularnewline
    \hline

    \end{tabular}
    \end{table}

Edit:

\setlength{\overfullrule}{5pt}% 

 \usetheme{Hannover}
 
 \usepackage{amsfonts}%letra
 \usepackage{array}%tabular
 \usepackage[spanish,portuguese,english]{babel}%diccionarios
 \usepackage{caption,setspace}
 \usepackage{color}
 \usepackage{colortbl}
 \usepackage[detect-all]{siunitx}
 \usepackage{hhline}
 \usepackage[utf8]{inputenc}%tildes
 \usepackage{longtable}
 \usepackage{lscape}
 \usepackage{ragged2e}
 \usepackage{tabularx}
 \usepackage{tabulary}
 \usepackage{tablefootnote}
 \usepackage{threeparttable,threeparttablex}
 \usepackage[most]{tcolorbox}
 \usepackage{makecell} 
 \usepackage{mathtools}
 \usepackage{multicol}%varias columnas
 \usepackage{multirow}%varias filas
 \usepackage{xcolor}
 
 
 \begin{document}
 
 \begin{frame}
 \begin{table}
    
    {\caption{Mean change in monthly Precipitation (\%) in three time slices under two RCPs.}}
    
    \resizebox{\columnwidth}{!} {
        
        
        
        \renewcommand{\arraystretch}{3}
        
        
        \newcolumntype{G}{>{\centering} m{1.4cm}}
        \newcolumntype{H}{>{\centering} m{1.2cm}}
        
        
        
        \begin{tabular}{|H|H|G|G|G|G|G|G|}
            \hline
            %                       \rowcolor{lilad!15}
            
            
            \rowcolor{blue!15}
            %\cellcolor{lilad!15}
            
            %\multicolumn{2}{|c|}{\multirow{2}{*}{ Time Slice}}}
            \multicolumn{2}{|c|}{ \textbf{Time Slice}}
            &\multicolumn{2}{c|}{\textbf{Max. Temp (${^{\circ}}$C)}} 
            &\multicolumn{2}{c|}{\textbf{Min. Temp.(${^{\circ}}$C)}} 
            &\multicolumn{2}{c|}{\textbf{PCP(\%)}}  \\ %\tabularnewline 
            \cline{3-8}
            %\hhline{~~|------|}
            \rowcolor{blue!15}
            
            
            
            %\multicolumn{-2}{|c|}{ Time Slice}
            &
            &\textbf{\textcolor{blue}{{\small RCP4.5}}} 
            &\textbf{\textcolor{orange}{{\small RCP8.5}}}
            &\textbf{\textcolor{blue}{{\small RCP4.5}}} 
            &\textbf{\textcolor{orange}{{\small RCP8.5}}}
            &\textbf{\textcolor{blue}{{\small RCP4.5}}} 
            &\textbf{\textcolor{orange}{{\small RCP8.5}}}\tabularnewline
            \hline
            
    \end{tabular}
        }
    \end{table}
    
\end{frame}

\end{document}

output

As seen in the pic, although the above code uses "multicolumn" it generates a vertical line in the first cell, which I would like to remove.

2
  • Welcome to TEX.SE. Please provide a compilable code (MWE) that reproduces the problematic output.
    – Imran
    Commented Oct 4, 2021 at 17:19
  • beamer doesn't define adjustbox or \mylength if I delete the adjustbox use I get ! File ended while scanning use of \Gscale@box@dd Commented Oct 4, 2021 at 17:26

2 Answers 2

1

You have a multicolumn with the Time Slice title but currently you have two empty cells in the next row so they get a | replace the first & on the following row by \multicolumn{2}{|c|}{}

1

First, some off-topic remarks/wonderings:

  • You should be aware that beamer load some package as are graphicx, amsmath, xcolor ... which it need for itself. Consequently you not need to load them again
  • Package caption doesn't work well in beamer. For captions beamer has own mechanism, which can be set/adjusted by \setbeamertemlate{caption}, \setbeamerfont{caption}{...} ...
  • Package multicol doesn't in presentations has much sense. Instead it beamer provide columns environment, when is needed to present something in parallel (for example text and image)
  • Package landscape in presentations hasn't any sence. All frames had to be "portrait" oriented
  • Do you really need so may table packages?
  • Why you need tablefootnote package if you load threeparttable (preasumble to write table notes?)
  • etc.

Considering aforementioned, your preamble can be:

\documentclass[xcolor=table]{beamer}
\usetheme{Hannover}

\usepackage[spanish,portuguese,english]{babel}%diccionarios
\usepackage[detect-all]{siunitx}
\usepackage{ragged2e}
\usepackage{hhline}
\usepackage{array}%tabular
\usepackage{longtable}
\usepackage{makecell}
\usepackage{multirow}%varias filas
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{tablefootnote}
\usepackage{threeparttable,threeparttablex}
\usepackage[most]{tcolorbox}

On-topic: The context, why you need two columns for "time Slice" data is unknow. From provided code fragments can be concluded, that one be sufficient (and by this your problem can not be happen).

Four your table I would use tabularray package. Using it MWE (Minimal Working Example) can be much shorter and clear:

\documentclass[xcolor=table]{beamer}
\usetheme{Hannover}

\usepackage[spanish,portuguese,english]{babel}%diccionarios
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\sisetup{detect-all}
\NewTableCommand\SCTC[1]{\SetCell{fg=#1}}

\usepackage[most]{tcolorbox} % not used in this MWE
 

\begin{document}
\begin{frame}
\frametitle{Example of table using the \texttt{tabularray} package}
    \begin{table}
\caption{Mean change in monthly Precipitation (\%) in three time slices under two RCPs.}
\begin{tblr}{hlines, vlines,
             colspec= {c *{6}{X[c]}},
             colsep = 3pt,
             rowsep = 5pt,
             rows   = {font=\footnotesize\bfseries, bg=blue!15},
             }
Time Slice
    &   \SetCell[c=2]{c}    Max. Temp (\si{\celsius})
        &   &   \SetCell[c=2]{c}    Min. Temp. (\si{\celsius})
                &   &   \SetCell[c=2]{c}    PCP (\%)        
                        &                               \\
month ?
    &   \SCTC{blue}    RCP4.5
        &   \SCTC{orange}    RCP8.5
            &   \SCTC{blue}    RCP4.5
                &   \SCTC{orange}    RCP8.5
                    &   \SCTC{blue}    RCP4.5
                        &   \SCTC{orange}    RCP8.5      \\
\end{tblr}
    \end{table}
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .