2

Hi again (I´m sorry by English mistakes).

I've learned a lot here. This week I learned several ways to create a table joining cells, and also how to put colors in it. However for some reason, two different models of producing the same table do not present a satisfactory result in cell colors, disappearing words or lines. Is there any way to get around this using these same templates? At what point is the error? How to color the background´s cell first?

enter image description here

Thanks for everyone.

Here is my MWE

\documentclass[a4paper,brazil, 12pt]{report}
\usepackage[top=1.5cm,left=1.5cm,bottom=1.5cm,right=1.5cm ]{geometry}
\usepackage{mathpazo, amsmath,amsfonts,amscd,bezier, amssymb}
\usepackage{multirow}
\usepackage[table, x11names]{xcolor}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{hhline}
\usepackage{siunitx}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{tikz, tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{quotes,angles}
\usepackage[american]{circuitikz}
\usetikzlibrary{arrows}
\usepackage{babel}
\usepackage{color}
\usepackage{hyperref}
\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\usepackage{tasks}
\usepackage{float}
\usepackage{makecell}

\pgfdeclarelayer{background}
\pgfdeclarelayer{main}

\pgfsetlayers{background,main}

\newcolumntype{C}{>{\Centering}X}

\colorlet{slightgray}{LightSteelBlue3!25}%https://tex.stackexchange.com/questions/290912/horizontal-line-hline-inconsistent-behaviour
\begin{document}

\begin{table}[H]
    {\renewcommand\arraystretch{1.5}
        \setlength\arrayrulewidth{1.1pt}
        {\centering{
                \begin{tabular}{|c|c|c|c|c|c|c|}
                    \Xhline{1.2pt}%\hline
                    \multirow{ 2.1}{*} { \parbox[c][0.7cm]{2.0cm} {\centering \textbf{Question}}} & \multirow{ 2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering $a)$}} & \multirow{2.1}{*} { \parbox[c][0.7cm]{1.95cm} {\centering  $b)$}}  & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $c)$}} & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $d)$}} & \multicolumn{2}{c|} {\parbox[c][0.7cm]{4.55cm}  {\centering \textbf{Score}}} \\ \cline{6-7}
                     & &  &  &  &  {\parbox[c][0.7cm]{2.3cm}  {\centering \textbf{Individual}}} & {\parbox[c][0.7cm]{2.25cm} {\centering \textbf{Team}}} \\ \hline
                 1. & & & & & &  \\ \hline
                     2. & & & & & &  \\ \hline
                    \multicolumn{5}{|c|}{\textbf{TOTAL}} & & \\ \hline
                \end{tabular}
    }}}
\end{table}

\begin{table}[H]
    {\renewcommand\arraystretch{1.5}
        \setlength\arrayrulewidth{1.1pt}
        {\centering{
                \begin{tabular}{|>{\columncolor{slightgray}}c|c|c|c|c|c|c|}
                    \Xhline{1.2pt}%\hline
                    \multirow{ 2.1}{*} { \parbox[c][0.7cm]{2.0cm} {\centering \textbf{Question}}} & \multirow{ 2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering $a)$}} & \multirow{2.1}{*} { \parbox[c][0.7cm]{1.95cm} {\centering  $b)$}}  & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $c)$}} & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $d)$}} & \multicolumn{2}{c|} {\parbox[c][0.7cm]{4.55cm}  {\centering \textbf{Score}}} \\ \cline{6-7}
                    & &  &  &  &  {\parbox[c][0.7cm]{2.3cm}  {\centering \textbf{Individual}}} & {\parbox[c][0.7cm]{2.25cm} {\centering \textbf{Team}}} \\ \hline
                    1. & & & & & &  \\ \hline
                    2. & & & & & &  \\ \hline
                    \multicolumn{5}{|c|}{\textbf{TOTAL}} & & \\ \hline
                \end{tabular}
    }}}
\end{table}

\begin{table}[H]
    {\renewcommand\arraystretch{1.5}
        \setlength\arrayrulewidth{1.1pt}
        {\centering{
                \begin{tabular}{|>{\columncolor{slightgray}}c|c|c|c|c|c|c|}
                    \Xhline{1.2pt}%\hline
                    \rowcolor{slightgray}
                    \multirow{ 2.1}{*} { \parbox[c][0.7cm]{2.0cm} {\centering \textbf{Question}}} & \multirow{ 2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering $a)$}} & \multirow{2.1}{*} { \parbox[c][0.7cm]{1.95cm} {\centering  $b)$}}  & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $c)$}} & \multirow{2.1}{*} {\parbox[c][0.7cm]{1.95cm} {\centering  $d)$}} & \multicolumn{2}{c|} {\parbox[c][0.7cm]{4.55cm}  {\centering \textbf{Score}}} \\ \cline{6-7}
                    \rowcolor{slightgray} & &  &  &  &  {\parbox[c][0.7cm]{2.3cm}  {\centering \textbf{Individual}}} & {\parbox[c][0.7cm]{2.25cm} {\centering \textbf{Team}}} \\ \hline
                    1. & & & & & &  \\ \hline
                    2. & & & & & &  \\ \hline
                    \multicolumn{5}{|c|}{\cellcolor{slightgray} \textbf{TOTAL}} & & \\ \hline
                \end{tabular}
    }}}
\end{table}



\begin{table}[H]
    {\renewcommand\arraystretch{1.5}
        \setlength\arrayrulewidth{1.1pt}
        {\centering{
                \begin{tabular}{|c|c|c|c|c|c|c|}
                    \Xhline{1.2pt}%\hline
                    \multirow{ 2.1}{*} {\cellcolor{slightgray}} & \multirow{ 2.1}{*} {{\cellcolor{slightgray}}} & \multirow{2.1}{*} {{\cellcolor{slightgray}}} & \multirow{2.1}{*} {{\cellcolor{slightgray}}} & \multirow{2.1}{*} {{\cellcolor{slightgray}}} & \multicolumn{2}{c|} {\parbox[c][0.7cm]{4.55cm}  {\cellcolor{slightgray}\centering \textbf{Score}}} \\ \cline{6-7}
                    \multirow{ -1.9}{*} {\cellcolor{slightgray} \parbox[c][0.7cm]{2.0cm} {\centering \textbf{Question}}} &
                    \multirow{ -1.9}{*} {\cellcolor{slightgray}\parbox[c][0.7cm]{1.95cm} {\centering $a)$}} & \multirow{-1.9}{*} {{\cellcolor{slightgray}} \parbox[c][0.7cm]{1.95cm} {\centering  $b)$}} &\multirow{-1.9}{*} {{\cellcolor{slightgray}} \parbox[c][0.7cm]{1.95cm} {\centering  $c)$}} & \multirow{-1.9}{*} {{\cellcolor{slightgray}} \parbox[c][0.7cm]{1.95cm} {\centering  $d)$}} &  {\parbox[c][0.7cm]{2.3cm}  {\cellcolor{slightgray} \centering \textbf{Individual}}} & {\parbox[c][0.7cm]{2.25cm} {\cellcolor{slightgray} \centering \textbf{Team}}} \\ \hline
                    \cellcolor{slightgray} 1. & & & & & &  \\ \hline
                    \cellcolor{slightgray} 2. & & & & & &  \\ \hline
                    \multicolumn{5}{|c|}{\cellcolor{slightgray}\textbf{TOTAL}} & & \\ \hline
                \end{tabular}
    }}}
\end{table}

{\centering{
        {\renewcommand\arraystretch{1.5}
            \setlength\arrayrulewidth{1.1pt}
            \begin{tabularx}{\textwidth}{|>{\columncolor{slightgray}}c
                    |>{\hsize=1\hsize}C
                    |>{\hsize=1\hsize}C
                    |>{\hsize=1\hsize}C
                    |>{\hsize=1\hsize}C
                    |c|c|}
                \hline
                \rowcolor{slightgray}
                & & & & & \multicolumn{2}{c|}{Scores}\\ \hhline{*5{>{\arrayrulecolor{slightgray}}-}*{2}{>{\arrayrulecolor{black}}-}}
                \rowcolor{slightgray}
                \multirow{-2.2}{*}{\textbf{Question}} & \multirow{-2.2}{*}{$a)$} & \multirow{-2.2}{*}{$b)$} & \multirow{-2.2}{*}{$c)$} & \multirow{-2.2}{*}{$d)$} & \textbf{Individual} & \textbf{Team} \\
                \hline
                1. & & & & & & \\
                \hline
                2. & & & & & & \\
                \hline
                %\rowcolor{slightgray}
                \multicolumn{5}{|c|}{\cellcolor{slightgray} \textbf{TOTAL}} & & \\
                \hline
            \end{tabularx}
    }}%https://tex.stackexchange.com/questions/492140/help-to-tabular-how-to-set-different-sizes-of-cell-in-tabular-enviroment/492296#492296

\end{document}
1
  • About table design see wiert.me/2014/04/03/…. Coloring of tasble columns, rows, cells is problem, how used pdf viewer render table image. (lines in table).
    – Zarko
    Commented May 24, 2019 at 16:45

2 Answers 2

2

Here is a possibikity. Note that for commutative diagrams, you should preferably use tikz-cd in the place of amscd. Also, hyperref should be loaded as the last package, with very few exceptions, and you shouldn't load both enumerate and enumitem, to avoid any conflicts.

\documentclass[a4paper, brazil, 12pt]{report}
\usepackage[margin=1.5cm ]{geometry}
\usepackage{mathpazo, amsmath,amsfonts,amscd,bezier, amssymb}
\usepackage{multirow}
\usepackage[table, x11names]{xcolor}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{hhline}
\usepackage{siunitx}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{tikz, tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{quotes,angles}
\usepackage[american]{circuitikz}
\usetikzlibrary{arrows}
\usepackage{babel}
%\usepackage{color}
%\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\usepackage{tasks}
\usepackage{float}
\usepackage{makecell}
\usepackage{hyperref}

\pgfdeclarelayer{background}
\pgfdeclarelayer{main}

\pgfsetlayers{background,main}

\newcolumntype{C}{>{\Centering\arraybackslash}X}

\colorlet{slightgray}{LightSteelBlue3!25}%https://tex.stackexchange.com/questions/290912/horizontal-line-hline-inconsistent-behaviour

\begin{document}

{\centering
\renewcommand\arraystretch{1.5}
 \setlength\arrayrulewidth{1.1pt}
 \begin{tabularx}{\textwidth}{|>{\columncolor{slightgray}}c|*{6}{C|}}
 \hline
 \rowcolor{slightgray}
 & & & & & \multicolumn{2}{c|}{Scores}\\%
\hhline{*5{>{\arrayrulecolor{black}}|>{\arrayrulecolor{slightgray}}-}>{\arrayrulecolor{black}}|-|-|}
  \rowcolor{slightgray}
 \multirow{-2.2}{*}{\textbf{Question}} & \multirow{-2.2}{*}{$a)$} & \multirow{-2.2}{*}{$b)$} & \multirow{-2.2}{*}{$c)$} & \multirow{-2.2}{*}{$d)$} & \textbf{Individual} & \textbf{Team} \\
 \hline
 1. & & & & & & \\
 \hline
 2. & & & & & & \\
 \hline
 \multicolumn{5}{|c|}{\cellcolor{slightgray} \textbf{TOTAL}} & & \\
 \hline
 \end{tabularx}
 }

 \end{document}

enter image description here

1
  • thank you. I didn´t know about your tips. best regards
    – Moura
    Commented May 24, 2019 at 17:52
1

Such diagram/tabulars/coloured grids are unbelievable easy to build with cals:

\documentclass[a4paper, 12pt]{report}
\usepackage[margin=1.5cm ]{geometry}
\usepackage{mathpazo, cals}
\usepackage[table, x11names]{xcolor}

\colorlet{slightgray}{LightSteelBlue3!25}

\let\nc=\nullcell                                                  % Shortcuts
\let\sc=\spancontent

\begin{document}

\begin{calstable}[c]
% Defining column relativ to each other and relativ to the margins
\colwidths{{\dimexpr(\columnwidth)/7\relax}
            {\dimexpr(\columnwidth)/7\relax}
            {\dimexpr(\columnwidth)/7\relax}
            {\dimexpr(\columnwidth)/7\relax}
            {\dimexpr(\columnwidth)/7\relax}
            }
% The tabular fills the text area if sum of all columns is 7

% Set up the tabular
\makeatletter
\def\cals@framers@width{0.4pt}   % Outside frame rules, reduce if the rule is too heavy
\def\cals@framecs@width{0.4pt}
\def\cals@bodyrs@width{1pt}
\cals@setpadding{Ag}
\cals@setcellprevdepth{Al}
\def\cals@cs@width{0.4pt}             % Inside rules, reduce if the rule is too heavy
\def\cals@rs@width{0.4pt}
\def\cals@bgcolor{}

\def\sgray{\ifx\cals@bgcolor\empty
    \def\cals@bgcolor{slightgray}
\else \def\cals@bgcolor{} \fi}

% R1H1
\thead{%
\brow
    \sgray\nc{lrt}
    \nc{lrt}
    \nc{lrt}
    \nc{lrt}
    \nc{lrt}
    \nc{ltb}
    \nc{rtb}\alignC\sc{Scores}\sgray
\erow
%R2H2
\brow
    \sgray\nc{lrb}\sc{\bfseries\vfil Questions}
    \nc{lrb}\alignC\sc{\vfil\itshape a)}
    \nc{lrb}\alignC\sc{\vfil\itshape b)}
    \nc{lrb}\alignC\sc{\vfil\itshape c)}
    \nc{lrb}\alignC\sc{\vfil\itshape d)}
    \alignC\cell{\bfseries Individual}
    \alignC\cell{\bfseries Team}\sgray
\erow
\mdseries
}
\tfoot{\lastrule\strut}
%R3B1
\brow
    \sgray\cell{1.}\sgray
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
\erow
% R4B2
\brow
    \sgray\cell{2.}\sgray
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
\erow
%R5B3
\brow
    \sgray\nc{ltb}
    \nc{tb}
    \nc{tb}
    \nc{tb}
    \nc{tb}
    \nc{rtb}\sc{\bfseries TOTAL}\sgray
    \cell{}
\erow
\makeatletter
\end{calstable}\par
\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 .