A few more suggestions in addition to Zarko’s fine answer.
- The setting of
output-decimal-marker
should be at a document level.
- A period should never be used for separating groups of digits, because it is ambiguous. Better leave the job to
siunitx
which will use a thin space.
- In the table we have a mixture of three to five digit numbers, so we add
group-four-digits
for uniformity.
- You can fit the table in
\footnotesize
, provided you squeeze it a bit.
The computation is easy, though it requires a bit of handwork. When the table is typeset with no adjustment to \tabcolsep
, an overfull of 30.65004pt was reported. We have 16 intercolumn spaces to act on, because the left and right padding have been removed with @{}
. Dividing the amount by 16 gives slightly less than 2pt, which can be safely subtracted to \tabcolsep
.
In the first run, the argument to \addtolenght
was set to 0pt
; then I made the computation and fixed the length.
The setting is confined to the particular table
environment, so it will not propagate to other tables.
\documentclass[12pt, a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{siunitx,booktabs}
\usepackage{eurosym}
\usepackage[labelfont=bf,labelsep=period]{caption}
\captionsetup[table]{skip = 1pt}
\sisetup{output-decimal-marker={,}}
\begin{document}
\begin{table}[!htp]
\caption{Comércio entre UE e Mercosul.}\label{tab2}
\centering
\footnotesize
\addtolength{\tabcolsep}{-1.91563pt}
% Overfull was 30.65004; divided by 16 gives 1.9156275
\begin{tabular}{
@{}
l
S[table-format=5.0,group-four-digits]
S[table-format=3.2]
S[table-format=5.0,group-four-digits]
S[table-format=3.2]
S[table-format=5.0,group-four-digits]
S[table-format=3.2]
S[table-format=5.0,group-four-digits]
S[table-format=3.2]
@{}
}
\toprule
\textbf{Itens} &
\multicolumn{4}{c}{\bfseries Importação} &
\multicolumn{4}{c}{\bfseries Exportação} \\
\cmidrule(lr){2-5} \cmidrule(l){6-9}
& \multicolumn{2}{c}{\bfseries 2013} & \multicolumn{2}{c}{\bfseries 2016}
& \multicolumn{2}{c}{\bfseries 2013} & \multicolumn{2}{c}{\bfseries 2016} \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}\cmidrule(l){8-9}
& {\euro/1000} & \%
& {\euro/1000} & \%
& {\euro/1000} & \%
& {\euro/1000} & \% \\
\midrule
Total & 47352 & 100,00 & 41895 & 100,00 & 56823 & 100,00 & 43111 & 100,00 \\
Produtos primários & 34379 & 72,60 & 29809 & 71,17 & 6647 & 11,70 & 4739 & 10,99 \\
Manufaturados & 9762 & 20,62 & 10066 & 24,03 & 47971 & 84,42 & 36852 & 85,48 \\
Outros produtos & 876 & 1,85 & 1332 & 3,18 & 825 & 1,45 & 626 & 1,45 \\
Outros & 2336 & 4,93 & 687 & 1,64 & 1379 & 2,43 & 894 & 2,07 \\
\midrule[\heavyrulewidth]
\multicolumn{9}{@{}l@{}}{\scriptsize \textit{Nota}: Mercosul 5 e União Europeia 28.} \\
\multicolumn{9}{@{}l@{}}{\scriptsize \textit{Fonte}: Eurostat comext (2017).} \\
\end{tabular}
\end{table}
\end{document}
An alternative approach is to use tabular*
:
\documentclass[12pt, a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{siunitx,booktabs}
\usepackage{eurosym}
\usepackage[labelfont=bf,labelsep=period]{caption}
\captionsetup[table]{skip = 1pt}
\sisetup{output-decimal-marker={,}}
\begin{document}
\begin{table}[!htp]
\caption{Comércio entre UE e Mercosul.}\label{tab2}
\centering
\footnotesize
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
l
S[table-format=5.0,group-four-digits]
S[table-format=3.2]
S[table-format=5.0,group-four-digits]
S[table-format=3.2]
S[table-format=5.0,group-four-digits]
S[table-format=3.2]
S[table-format=5.0,group-four-digits]
S[table-format=3.2]
@{}
}
\toprule
\textbf{Itens} &
\multicolumn{4}{c}{\bfseries Importação} &
\multicolumn{4}{c}{\bfseries Exportação} \\
\cmidrule(r{1pt}){2-5} \cmidrule(l{1pt}){6-9}
& \multicolumn{2}{c}{\bfseries 2013} & \multicolumn{2}{c}{\bfseries 2016}
& \multicolumn{2}{c}{\bfseries 2013} & \multicolumn{2}{c}{\bfseries 2016} \\
\cmidrule(r{1pt}){2-3}\cmidrule(l{1pt}r{1pt}){4-5}
\cmidrule(l{1pt}r{1pt}){6-7}\cmidrule(l{1pt}){8-9}
& {\euro/1000} & \%
& {\euro/1000} & \%
& {\euro/1000} & \%
& {\euro/1000} & \% \\
\midrule
Total & 47352 & 100,00 & 41895 & 100,00 & 56823 & 100,00 & 43111 & 100,00 \\
Produtos primários & 34379 & 72,60 & 29809 & 71,17 & 6647 & 11,70 & 4739 & 10,99 \\
Manufaturados & 9762 & 20,62 & 10066 & 24,03 & 47971 & 84,42 & 36852 & 85,48 \\
Outros produtos & 876 & 1,85 & 1332 & 3,18 & 825 & 1,45 & 626 & 1,45 \\
Outros & 2336 & 4,93 & 687 & 1,64 & 1379 & 2,43 & 894 & 2,07 \\
\midrule[\heavyrulewidth]
\multicolumn{9}{@{}l@{}}{\scriptsize \textit{Nota}: Mercosul 5 e União Europeia 28.} \\
\multicolumn{9}{@{}l@{}}{\scriptsize \textit{Fonte}: Eurostat comext (2017).} \\
\end{tabular*}
\end{table}
\end{document}
The output is essentially the same for both approaches.

\documentclass{...}
and ending with\end{document}
. we should know your page layout (is really needed so small fonts in table as can be observed in your code).