2

I'm trying to make this table following figure. I can do the table, but I can not insert some circles to highlight some columns, at the end of each circle I want to put arrows down associating with the sum. My code is as follows:

\documentclass[12pt,a4paper]{article}
\usepackage[brazil]{babel}
\usepackage[latin1]{inputenc}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage[bottom=2.5cm,top=2.5cm,left=2.5cm,right=2.5cm]{geometry}
\usepackage{array}
\usepackage{mathtools}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{calc}
\usepackage{bm}
\usepackage{indentfirst}
\usepackage{enumitem}
\usepackage{makecell}
\usepackage{rotating}
\usepackage{dsfont}
\usepackage{comment}
\usepackage{placeins}
\usepackage{booktabs,siunitx}
\usepackage[alf]{abntex2cite}
\sisetup{%
output-decimal-marker={,},
}

\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,decorations.pathreplacing}

\pagestyle{empty}
\date{}

\begin{document}

\begin{center}
\centering
\begin{table}[]
\large
\begin{tabular}{lllll}
\multicolumn{1}{c}{NOV/96}           & \multicolumn{1}{c}{DEZ/96}           
& \multicolumn{1}{c}{JAN/97}           & \multicolumn{1}{c}{FEV/97}           
& \multicolumn{1}{c}{MAR/97}           \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
\multicolumn{1}{c}{1, 2, 3, ..., 30} & \multicolumn{1}{c}{1, 2, 3, 
..., 30} & \multicolumn{1}{c}{1, 2, 3, ..., 30} & \multicolumn{1}{c}
{1, 2, 3, ..., 30} & \multicolumn{1}{c}{1, 2, 3, ..., 30} \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     & 1, 2, 3, ..., 30                     
& 1, 2, 3, ..., 30                     \\
                                 &                                      
&                                      &                                      
&                                      \\
                                 &                                      
&                                      &                                      
&                                     
\end{tabular}
\end{table}
\end{center}

\end{document}

enter image description here

2

In this answer I restrict myself to November, the rest is repetition. I also would suggest to use \dots instead of ..., but this is of course up to you. I stripped off packages and libraries that are not used.

\documentclass[12pt,a4paper]{article}
\usepackage[brazil]{babel}
\usepackage[latin1]{inputenc}
\usepackage[bottom=2.5cm,top=2.5cm,left=2.5cm,right=2.5cm]{geometry}

\usepackage{tikz}
\usetikzlibrary{fit}
\newcommand{\tikznode}[2]{\relax
\ifmmode%
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};
\else
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
\fi}
\pagestyle{empty}
\date{}

\begin{document}

\begin{center}
\centering
\begin{table}[]
\large
\begin{tabular}{lllll}
\multicolumn{1}{c}{NOV/96}           & \multicolumn{1}{c}{DEZ/96}           
& \multicolumn{1}{c}{JAN/97}           & \multicolumn{1}{c}{FEV/97}           
& \multicolumn{1}{c}{MAR/97}           \\
\tikznode{NOV-1-T}{1}, 2, 3, \dots, \tikznode{NOV-30-T}{30}                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
\multicolumn{1}{c}{1, 2, 3, \dots, 30} & \multicolumn{1}{c}{1, 2, 3, 
\dots, 30} & \multicolumn{1}{c}{1, 2, 3, \dots, 30} & \multicolumn{1}{c}
{1, 2, 3, \dots, 30} & \multicolumn{1}{c}{1, 2, 3, \dots, 30} \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
\tikznode{NOV-1-B}{1}, 2, 3, \dots, \tikznode{NOV-30-B}{30}                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     & 1, 2, 3, \dots, 30                     
& 1, 2, 3, \dots, 30                     \\
                                 &                                      
&                                      &                                      
&                                      \\
                                 &                                      
&                                      &                                      
&                                     
\end{tabular}
\end{table}
\end{center}
\begin{tikzpicture}[overlay,remember picture]
 \node[rounded corners=2mm,draw,fit=(NOV-1-T)(NOV-1-B)] (NOV-L){};
 \node[rounded corners=2mm,draw,fit=(NOV-30-T)(NOV-30-B)] (NOV-R){};
 \draw[thick,-latex] (NOV-L.south) -- ++(0,-0.5) node[below]{$\displaystyle
 \frac{\sum d_1}{18}$};
 \draw[thick,-latex] (NOV-R.south) -- ++(0,-0.5) node[below]{$\displaystyle
 \frac{\sum d_1}{18}$};
\end{tikzpicture}
\end{document}

enter image description here

ADDENDUM: Let TeX do the repetition. Had to decrease the font size, if you want to go to the original size you may want to switch to the landscape mode, which is commented out.

\documentclass[10pt,a4paper]{article}
\usepackage[brazil]{babel}
\usepackage[latin1]{inputenc}
\usepackage[bottom=2.5cm,top=2.5cm,left=2.5cm,right=2.5cm]{geometry}
%\usepackage{pdflscape}
\usepackage{tikz}
\usetikzlibrary{fit}
\newcommand{\tikznode}[2]{\relax
\ifmmode%
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};
\else
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
\fi}
\pagestyle{empty}
\date{}
\newcounter{it}
\setcounter{it}{0}

\begin{document}
\def\mylines{}% from https://tex.stackexchange.com/a/50299/121799
\loop\ifnum\theit<16
  \addtocounter{it}{1}
  \expandafter\def\expandafter\mylines\expandafter{%
    \mylines
     1,2,3,4,5,\dots,30 &  1,2,3,4,5,\dots,31 & 
      1,2,3,4,5,\dots,31 &  1,2,3,4,5,\dots,28 &  1,2,3,4,5,\dots,30\\
  }%
\repeat
%\begin{landscape}
\begin{center}
\centering
\begin{table}[]
\large
\begin{tabular}{lllll}
\multicolumn{1}{c}{NOV/96}           & \multicolumn{1}{c}{DEZ/96}           
& \multicolumn{1}{c}{JAN/97}           & \multicolumn{1}{c}{FEV/97}           
& \multicolumn{1}{c}{MAR/97}           \\
\tikznode{NOV-1-T}{1},2,3,4,5 \dots,\tikznode{NOV-30-T}{30}                  
& 1,\tikznode{DEZ-2-T}{2},3,4,5 \dots,\tikznode{DEZ-31-T}{31}                
& 1,2,\tikznode{JAN-3-T}{3},4,5 \dots,31               
& 1,2,3,\tikznode{FEB-4-T}{4},5 \dots,28               
& 1,2,3,4,\tikznode{MAR-5-T}{5} \dots,28 \\              
\mylines
\tikznode{NOV-1-B}{1},2,3,4,5 \dots,\tikznode{NOV-30-B}{30}                  
& 1,\tikznode{DEZ-2-B}{2},3,4,5 \dots,\tikznode{DEZ-31-B}{31}                
& 1,2,\tikznode{JAN-3-B}{3},4,5 \dots,31               
& 1,2,3,\tikznode{FEB-4-B}{4},5 \dots,28               
& 1,2,3,4,\tikznode{MAR-5-B}{5} \dots,28 \end{tabular}
\end{table}
\end{center}
\begin{tikzpicture}[overlay,remember picture]
 \foreach \X/\Y in {NOV/1,NOV/30,DEZ/2,DEZ/31,JAN/3,FEB/4,MAR/5}
 {\node[rounded corners=2mm,draw,fit=(\X-\Y-T)(\X-\Y-B)] (\X-L){};
 \draw[thick,-latex] (\X-L.south) -- ++(0,-0.5) node[below]{$\displaystyle
 \frac{\sum d_1}{18}$};
 }
\end{tikzpicture}
%\end{landscape}
\end{document}

enter image description here

  • @Werner Sorry, I had not realized this detail, I just got the code I was developing and published. – Wendell Fialho Sep 5 '18 at 17:46
  • @WendellFialho I am loading shapes.geometric. If you insist on ellipses, you could replace rounded corners=2mm by ellipse. The problem is that the result doesn't look nice IMHO. Of course, you could rectify this by using some negative value for inner ysep but this requires some manual adjustment which I generally try to avoid. – marmot Sep 5 '18 at 17:49
  • 1
    Off-topic: why November? Is it the best month for a marmot to hibernate? :P. +1 – manooooh Sep 5 '18 at 19:01
  • 1
    @manooooh Yes, precisely, these are the dates at which marmots briefly awake from hibernation. ;-) – marmot Sep 5 '18 at 19:08
  • @marmot, how do I do so that the subscript don't become fixed, e.g. the same value for all sums? I need to change them according to the days (d_1, d_30, d_4, d_5). Thanks a lot. – Wendell Fialho Sep 6 '18 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.