2

I can make the following table:

enter image description here

\documentclass{article}

\usepackage{geometry} 

\usepackage{xcolor} 

\usepackage{amsmath}

\begin{document}

\begin{center}

\begin{tabular}{|c||c|c||c|c||c|c||c|c||c|c||c|c|}

\hline

Caixa & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ \\

\hline

10&10&1&10&1&10&1&10&1&10&0&0&1\\

\hline

9&8&1&8&1&8&1&8&1&8&1&9&1\\

\hline

8&6&1&6&1&6&1&6&1&6&1&7&1\\

\hline

7&4&1&4&1&4&1&4&1&4&1&5&1\\

\hline

6&2&1&2&1&2&1&2&1&2&1&3&1\\

\hline

5&0&1&5&2&5&2&5&2&5&2&1&1\\

\hline

4&2&2&1&2&1&2&1&2&1&2&3&2\\

\hline

3&1&3&0&3&0&3&3&3&3&4&2&3\\

\hline

2&1&6&0&6&2&7&1&7&1&7&2&0\\

\hline

1&1&17&1&19&1&2&1&2&1&21&1&17\\

\hline

\textbf{TOTAL}&35&&37&&39&&39&&41&&33&\\

\hline

\end{tabular}

\end{center}

\end{document}

But I would like to paint the columns as shown in the figure.

enter image description here

benedito
  • 4,600

1 Answers1

4

Her is a solution: it uses the colortbl package, loaded by xcolorwith option[table]. I also usedhhlinefor nicer-looking horizontal lines (in my opinion) and I added some vertical padding to the rows withextrarowheight`: \documentclass{article}

\usepackage{geometry}

\usepackage[table, x11names]{xcolor}

\usepackage{array, hhline, amsmath}

\begin{document}

\begin{center}
\setlength\extrarowheight{3pt}
\begin{tabular}{|c|*{6}{|>{\columncolor{OliveDrab3!60}}c|>{\columncolor{Yellow1!80}}c|}}

\hhline{|-|*{6}{|--|}}

Caixa & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ & $a_{i}$&$n_{i}$ \\

\hhline{|-|*{6}{|--|}}

10&10&1&10&1&10&1&10&1&10&0&0&1\\

\hhline{|-|*{6}{|--|}}

9&8&1&8&1&8&1&8&1&8&1&9&1\\

\hhline{|-|*{6}{|--|}}

8&6&1&6&1&6&1&6&1&6&1&7&1\\

\hhline{|-|*{6}{|--|}}

7&4&1&4&1&4&1&4&1&4&1&5&1\\

\hhline{|-|*{6}{|--|}}

6&2&1&2&1&2&1&2&1&2&1&3&1\\

\hhline{|-|*{6}{|--|}}

5&0&1&5&2&5&2&5&2&5&2&1&1\\

\hline

4&2&2&1&2&1&2&1&2&1&2&3&2\\

\hhline{|-|*{6}{|--|}}

3&1&3&0&3&0&3&3&3&3&4&2&3\\

\hhline{|-|*{6}{|--|}}

2&1&6&0&6&2&7&1&7&1&7&2&0\\

\hhline{|-|*{6}{|--|}}

1&1&17&1&19&1&2&1&2&1&21&1&17\\

\hhline{|-|*{6}{|--|}}

\textbf{TOTAL}&35&&37&&39&&39&&41&&33&\\

\hhline{|-|*{6}{|--|}}

\end{tabular}

\end{center}

\end{document} 

enter image description here

Bernard
  • 271,350