5

I have the next code, but I want that the vertical line be complete (it's cut off near to horizontal line):

\begin{table} [H] \footnotesize 
\sisetup{output-decimal-marker = {,}}

\centering
\caption{Massas e percentuais das frações separadas.}

\label{peneiramento}
%\begin{threeparttable}[b]
\begin{tabular}{S[input-symbols = {>},table-format=>2.3]
                S[table-format=4]
                S[table-format=2.1]|
                S[table-format=2]
                S[table-format=2.2,separate-uncertainty=true,table-figures-uncertainty=1]
                S[table-format=1.3,separate-uncertainty=true,table-figures-uncertainty=1]}

\toprule 
\multicolumn{3}{c|}{\makecell[tc]{Peneiramento}} & \multicolumn{3}{c}{\makecell[tc]{Elutriação}} \\
\midrule
{\makecell[tc]{Abertura \\ da peneira \\($\mu m$)}} & {\makecell[tc]{Fração \\ mássica \\ ($g$)}} & {\makecell[tc]{\% \\ massa }} & {\makecell[tc]{Velocidade \\ separação  \\ ($m/s$)}} & {\makecell[tc]{Fração \\ mássica \\ ($g$)}} & {\makecell[tc]{$\%$ \\ massa }}  
\\ 
\midrule

4000 & 26,72 & 34 \\
2830 & 8,79 & 11 \\
1900 & 8,88 & 11 \\
595 & 18,19 & 23 \\
297 & 9,74 & 13 \\
149 & 3,96 & 5 \\
Pan & 1,24 & 2 \\

\bottomrule 
\end{tabular} 
\end{table}

enter image description here

3
  • 3
    The rules from the booktabs package (\toprule, \midrule, \bottomrule, etc.) cut the vertical line by design. The booktabs package explicitly says that you should never use vertical rules in tables. If you want them, though, then you need to use other rule commands, like \hline. Jul 30, 2018 at 18:53
  • 3
    ...then you're doing it wrong. Since you're using booktabs, you should also read the documentation. It suggests "Never, ever use vertical rules" (section 2 The layout of formal tables).
    – Werner
    Jul 30, 2018 at 18:54
  • 1
    Maybe the table can be split into two tables with horizontal space between them instead of a vertical line. Jul 30, 2018 at 19:09

3 Answers 3

6

The table does not require vertical line between columns 3 and 4. Just be more deliberate in the way you structure the header material, say, by providing two separate \cmidrule statements.

enter image description here

\documentclass{article}
\usepackage[portuguese]{babel}
\usepackage{makecell,booktabs,float,siunitx}
\usepackage[skip=0.333\baselineskip]{caption}
\sisetup{per-mode=symbol,output-decimal-marker = {,}}

\begin{document}
\begin{table}[H] 
%\footnotesize   % not needed, right?
\centering
\caption{Massas e percentuais das frações separadas.}
\label{peneiramento}

\begin{tabular}{@{}
                S[table-format=4.0]
                S[table-format=2.2]           
                S[table-format=2.0]
                c  % ?
                S[table-format=2.2,
                  separate-uncertainty=true,
                  table-figures-uncertainty=1]
                S[table-format=1.3,
                  separate-uncertainty=true,
                  table-figures-uncertainty=1]
                @{}}

\toprule 
\multicolumn{3}{c}{Peneiramento} & 
\multicolumn{3}{c}{Elutriação} \\
\cmidrule(r){1-3} \cmidrule(l){4-6}
{\makecell[tc]{Abertura \\ da peneira \\(\si{\micro\meter})}} & 
{\makecell[tc]{Fração \\ mássica \\ (\si{\gram})}} & 
{\makecell[tc]{\% \\ massa }} & 
{\makecell[tc]{Velocidade \\ separação  \\ 
    (\si{\meter\per\second})}} & 
{\makecell[tc]{Fração \\ mássica \\ (\si{\gram})}} & 
{\makecell[tc]{\% \\ massa }}  
\\ 
\midrule
4000 & 26,72 & 34 \\
2830 &  8,79 & 11 \\
1900 &  8,88 & 11 \\
 595 & 18,19 & 23 \\
 297 &  9,74 & 13 \\
 149 &  3,96 &  5 \\
{Pan}&  1,24 &  2 \\
\bottomrule 
\end{tabular} 
\end{table}
\end{document}
3
  • This is a good answer for this particular problem, but is it possible to have a continuous line in tables generally? What about the cases where it might be justified?
    – gnucchi
    Jul 30, 2018 at 19:51
  • (I’m thinking e.g. crosstabs)
    – gnucchi
    Jul 30, 2018 at 20:05
  • @svenper - See @Bernard's parallel answer for a solution that features a long vertical line of some sort or other; speaking for myself, I'm not convinced that this table absolutely, positively requires any vertical lines. I agree with the author of the booktabs package on the following: If a tableau can't live without vertical lines, one is doing something wrong. BTW, your crosstabs "counterexample" is no counterexample at all: A contingency table can be designed just fine without vertical lines -- and be made more readable in the process. :-)
    – Mico
    Jul 30, 2018 at 20:08
2

Vertical lines are not necessarily a bad idea, if used judiciously, but if you want them to intersect the horizontal lines, you have to neutralise the padding that booktabs adds around rules, and replace it with ‘cell gapes’ defined by makecell. This is done in the first code below.

However, I also propose another code, with a thick vertical grey rule between columns; which looks nicer from my point of view.

    \documentclass[a4paper, tableportuguese]{article}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[svgnames, table]{xcolor}

    \usepackage{array, cellspace, makecell, caption, booktabs}
    \setlength{\cellspacetoplimit}{6pt}
    \setlength{\cellspacebottomlimit}{6pt}
\usepackage{float}
\usepackage{siunitx}

     \begin{document}

\begin{table} [H] \footnotesize
\sisetup{output-decimal-marker={,}, table-number-alignment=center}
\captionsetup{skip=4pt}
\aboverulesep=0pt
\belowrulesep=0pt
\setcellgapes{0.5ex}\makegapedcells
\renewcommand{\cellalign}{tc}
\centering
\caption{Massas e percentuais das frações separadas.}
\label{peneiramento}
%\begin{threeparttable}[b]
\begin{tabular}{S[input-symbols = {>}, table-format=>2.3]
                S[table-format=4]
                S[table-format=2.1]!{\vrule width 0.08em}
                S[table-format=2]
                S[table-format=2.2,separate-uncertainty=true,table-figures-uncertainty=1]
                S[table-format=1.3,separate-uncertainty=true,table-figures-uncertainty=1]}

\toprule
\multicolumn{3}{c!{\vrule width 0.08em}}{\makecell {Peneiramento}} & \multicolumn{3}{c}{\makecell {Elutriação}} \\
\midrule
{\makecell{Abertura \\ da peneira \\(\si{\um})}}& {\makecell{Fração \\ mássica \\ (g)}} & {\makecell[tc]{\% \\ massa }} & {\makecell{Velocidade \\ separação \\ (\si{\m\per\s})}} & {\makecell {Fração \\ mássica \\ (g)}} & {\makecell { \% \\ massa }}
\\
\midrule
4000 & 26,72 & 34 \\
2830 & 8,79 & 11 \\
1900 & 8,88 & 11 \\
595 & 18,19 & 23 \\
297 & 9,74 & 13 \\
149 & 3,96 & 5 \\
{Pan} & 1,24 & 2 \\
\bottomrule
\end{tabular}
\end{table}
\vskip1cm
\begin{table} [H] \footnotesize
\sisetup{output-decimal-marker={,}, table-number-alignment=center}
\captionsetup{skip=4pt}
\aboverulesep=-1pt
\belowrulesep=0pt
\cmidrulewidth=0.05em
\setcellgapes{0.5ex}\makegapedcells
\renewcommand{\cellalign}{tc}
\centering
\caption{Massas e percentuais das frações separadas.}
\label{peneiramento}
%\begin{threeparttable}[b]
\begin{tabular}{S[input-symbols = {>}, table-format=>2.3]
                S[table-format=4]
                S[table-format=2.1]!{\color{Gainsboro}\vrule width 0.5em}
                S[table-format=2]
                S[table-format=2.2,separate-uncertainty=true,table-figures-uncertainty=1]
                S[table-format=1.3,separate-uncertainty=true,table-figures-uncertainty=1]}

\toprule
\addlinespace[0.5ex]
\multicolumn{3}{c!{\color{Gainsboro}\vrule width 0.5em}}{\makecell {Peneiramento}} & \multicolumn{3}{c}{\makecell {Elutriação}} \\
\cmidrule(lr{1em}){1-3}\cmidrule(l{0.5em}r){4-6}
{\makecell{Abertura \\ da peneira \\(\si{\um})}}& {\makecell{Fração \\ mássica \\ (g)}} & {\makecell[tc]{\% \\ massa }} & {\makecell{Velocidade \\ separação \\ (\si{\m\per\s})}} & {\makecell {Fração \\ mássica \\ (g)}} & {\makecell { \% \\ massa }}
\\
\cmidrule(lr{1em}){1-3}\cmidrule(l{0.5em}r){4-6}
4000 & 26,72 & 34 \\
2830 & 8,79 & 11 \\
1900 & 8,88 & 11 \\
595 & 18,19 & 23 \\
297 & 9,74 & 13 \\
149 & 3,96 & 5 \\
{Pan} & 1,24 & 2 \\
\addlinespace[0.8ex]
\bottomrule
\end{tabular}
\end{table}

\end{document} 

enter image description here

1

If you actually want to use vertical rules with the horizontal rules of booktabs you may use the environment {NiceTabular} of nicematrix which is compatible with the rules of booktabs.

\documentclass[a4paper, tableportuguese]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[svgnames]{xcolor}
\usepackage{caption, booktabs}
\usepackage{float}
\usepackage{siunitx}

\usepackage{nicematrix}
\begin{document}

\begin{table} [H] \footnotesize
\sisetup{output-decimal-marker={,}, table-number-alignment=center}
\captionsetup{skip=4pt}
\centering
\caption{Massas e percentuais das frações separadas.}
\label{peneiramento}
\begin{NiceTabular}{S[input-symbols = {>}, table-format=>2.3]
                S[table-format=4]
                S[table-format=2.1]|
                S[table-format=2]
                S[table-format=2.2,separate-uncertainty=true,table-figures-uncertainty=1]
                S[table-format=1.3,separate-uncertainty=true,table-figures-uncertainty=1]}

\toprule
\Block{1-3}{Peneiramento} &&& \Block{1-3}{Elutriação} \\
\midrule
{\Block{}{Abertura \\ da peneira \\(\si{\um})}}& {\Block{}{Fração \\ mássica \\ (g)}} & {\Block{}{\% \\ massa \\ \\}} &
{\Block{}{Velocidade \\ separação \\ (\si{\m\per\s})}} & {\Block{}{Fração \\ mássica \\ (g)}} & {\Block{}{\% \\
    massa\\ \\}}\\
\midrule
4000 & 26,72 & 34 & & & \\
2830 & 8,79 & 11 \\
1900 & 8,88 & 11 \\
595 & 18,19 & 23 \\
297 & 9,74 & 13 \\
149 & 3,96 & 5 \\
{Pan} & 1,24 & 2 \\
\bottomrule
\end{NiceTabular}
\end{table}

\end{document} 

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

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.