Por que o separador vertical não está completo na tabela?

Por que o separador vertical não está completo na tabela?

Este é o meu código.

\documentclass{article}
\usepackage{pbox}
\usepackage{graphicx}
\begin{document}
\begin{table}[H]
    \centering
    \caption{Effect of Tilt on Module Output Power}
    \resizebox{\textwidth}{!}{
        \begin{tabular}{c|ccccccccc|c|c|c|c}
            Angle & \multicolumn{9}{c}{Incident Radiation ($W/m^2$)} & \pbox{20 cm}{Average Incident \\ Radiation ($W/m^2$)} & Voltage (V) & Current (A) & Power (W) \\
            25    & 383                                        & 616 & 530 & 350 & 830  & 550 & 75  & 164 & 69  & 396                                       & 4.99        & 0.14        & 0.6986    \\
            22    & 364                                        & 594 & 483 & 364 & 865  & 630 & 112 & 178 & 170 & 417                     & 7.13        & 0.199       & 1.41887   \\
            19    & 360                                        & 622 & 496 & 418 & 886  & 625 & 101 & 246 & 220 & 441                 & 8.2         & 0.228       & 1.8696    \\
            16    & 357                                        & 586 & 461 & 437 & 988  & 724 & 119 & 251 & 250 & 463          & 9           & 0.249       & 2.241     \\
            13    & 393                                        & 595 & 459 & 451 & 953  & 721 & 124 & 274 & 306 & 475                 & 9.6         & 0.265       & 2.544     \\
            10    & 374                                        & 602 & 460 & 506 & 1012 & 736 & 167 & 288 & 287 & 492                 & 10.16       & 0.28        & 2.8448    \\
            7     & 368                                        & 584 & 466 & 505 & 977  & 718 & 188 & 418 & 378 & 511                 & 11.07       & 0.306       & 3.38742   \\
            4     & 351                                        & 538 & 420 & 545 & 1024 & 769 & 267 & 472 & 433 & 535                 & 11.75       & 0.324       & 3.807     \\
            0     & 345                                        & 526 & 420 & 529 & 1059 & 789 & 280 & 481 & 465 & 543                 & 12.17       & 0.331       & 4.02827  
        \end{tabular}
    }
\end{table}
\end{document}

Por que a linha separadora vertical após a segunda linha está incompleta (não no topo da tabela)?

Responder1

Use \multicolumn{9}{c|}{Incident Radiation ($W/m^2$)}em vez disso, ou seja, adicione |explicitamente se deve haver uma linha vertical, pois \multicolumnusa uma |na coluna da esquerda automaticamente, se tiver sido especificada na tabulardescrição, mas não na da direita |. Omitir isto |é um “erro” frequente.

A propósito: c|ccccccccc|c|c|c|cpode ser substituído porc|*{9}c|*{3}{c|}c

  • Considere usar siunitxpara as unidades
  • Na minha opinião, as colunas que contêm números inteiros (ou seja, as primeiras 10 colunas devem estar alinhadas à direita, não centralizadas.

EditarAlgumas melhorias sugeridas (mais pode ser feito)

\documentclass{article}
\usepackage{pbox}
\usepackage{siunitx}
\usepackage{makecell}
\usepackage{graphicx}
\begin{document}
\begin{table}
  \centering
  \caption{Effect of Tilt on Module Output Power}
  \resizebox{\textwidth}{!}{%
     \begin{tabular}{c|*{9}r|*{3}{c|}c}
      Angle (\SIUnitSymbolDegree) & \multicolumn{9}{c|}{Incident Radiation (\si{W/m^2})} & \thead{Average Incident \\ Radiation (\si{W/m^2})} & Voltage (\si{V}) & Current (\si{A}) & Power (\si{W}) \\
      25    & 383                                        & 616 & 530 & 350 & 830  & 550 & 75  & 164 & 69  & 396                                       & 4.99        & 0.14        & 0.6986    \\
      22    & 364                                        & 594 & 483 & 364 & 865  & 630 & 112 & 178 & 170 & 417                     & 7.13        & 0.199       & 1.41887   \\
      19    & 360                                        & 622 & 496 & 418 & 886  & 625 & 101 & 246 & 220 & 441                 & 8.2         & 0.228       & 1.8696    \\
      16    & 357                                        & 586 & 461 & 437 & 988  & 724 & 119 & 251 & 250 & 463          & 9           & 0.249       & 2.241     \\
      13    & 393                                        & 595 & 459 & 451 & 953  & 721 & 124 & 274 & 306 & 475                 & 9.6         & 0.265       & 2.544     \\
      10    & 374                                        & 602 & 460 & 506 & 1012 & 736 & 167 & 288 & 287 & 492                 & 10.16       & 0.28        & 2.8448    \\
      7     & 368                                        & 584 & 466 & 505 & 977  & 718 & 188 & 418 & 378 & 511                 & 11.07       & 0.306       & 3.38742   \\
      4     & 351                                        & 538 & 420 & 545 & 1024 & 769 & 267 & 472 & 433 & 535                 & 11.75       & 0.324       & 3.807     \\
      0     & 345                                        & 526 & 420 & 529 & 1059 & 789 & 280 & 481 & 465 & 543                 & 12.17       & 0.331       & 4.02827  
    \end{tabular}%
  }
\end{table}
\end{document}

insira a descrição da imagem aqui

Responder2

Você deveria dizer \multicolumn{9}{c|}{...}: a barra de separação pertence à coluna que a precede (na lógica do LaTeX), exceto aquela antes da primeira coluna que também pertence à primeira coluna.

No entanto, usar \resizebox{\textwidth}{!}{...}geralmente não é a melhor escolha. Você deve primeiro tentar reduzir a largura das colunas, por exemplo, separando as unidades em uma linha diferente.

O uso siunitxfaz o alinhamento das figuras, ao mesmo tempo que booktabsdá um aspecto mais profissional à mesa.

Reduzi a fonte ao \footnotesizemáximo \tabcolseppara não ficar com uma linha muito cheia.

\documentclass{article}
\usepackage{graphicx,siunitx,booktabs}

\newcommand{\splitcell}[2][c]{%
  \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}%
}

\begin{document}

\begin{table}
\centering

\caption{Effect of Tilt on Module Output Power}

\footnotesize
\setlength{\tabcolsep}{2pt}\setlength{\cmidrulekern}{1pt}

\begin{tabular}{
  @{}
  S[table-format=2.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=4.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=2.2]
  S[table-format=1.3]
  S[table-format=1.5,group-digits=false]
  @{}
}
\toprule
{Angle} &
  \multicolumn{9}{c}{Incident Radiation} &
  {\splitcell{Average Incident \\ Radiation}} &
  {Voltage} &
  {Current} &
  {Power} \\
&
  \multicolumn{9}{c}{(\si{W/m^2})} &
  {(\si{W/m^2})} &
  {(\si{V})} &
  {(\si{A})} &
  {(\si{W})} \\
\cmidrule(r){1-1}
\cmidrule(lr){2-10}
\cmidrule(lr){11-11}
\cmidrule(lr){12-12}
\cmidrule(lr){13-13}
\cmidrule(l){14-14}
25 & 383 & 616 & 530 & 350 &  830 & 550 &  75 & 164 &  69 & 396 &  4.99 & 0.14  & 0.6986  \\
22 & 364 & 594 & 483 & 364 &  865 & 630 & 112 & 178 & 170 & 417 &  7.13 & 0.199 & 1.41887 \\
19 & 360 & 622 & 496 & 418 &  886 & 625 & 101 & 246 & 220 & 441 &  8.2  & 0.228 & 1.8696  \\
16 & 357 & 586 & 461 & 437 &  988 & 724 & 119 & 251 & 250 & 463 &  9    & 0.249 & 2.241   \\
13 & 393 & 595 & 459 & 451 &  953 & 721 & 124 & 274 & 306 & 475 &  9.6  & 0.265 & 2.544   \\
10 & 374 & 602 & 460 & 506 & 1012 & 736 & 167 & 288 & 287 & 492 & 10.16 & 0.28  & 2.8448  \\
 7 & 368 & 584 & 466 & 505 &  977 & 718 & 188 & 418 & 378 & 511 & 11.07 & 0.306 & 3.38742 \\
 4 & 351 & 538 & 420 & 545 & 1024 & 769 & 267 & 472 & 433 & 535 & 11.75 & 0.324 & 3.807   \\
 0 & 345 & 526 & 420 & 529 & 1059 & 789 & 280 & 481 & 465 & 543 & 12.17 & 0.331 & 4.02827 \\
\bottomrule
\end{tabular}

\end{table}
\end{document}

insira a descrição da imagem aqui

Se você reduzir o cabeçalho da décima primeira coluna apenas para “Média”, poderá até usar \smallum tamanho maior \tabcolsep:

\documentclass{article}
\usepackage{graphicx,siunitx,booktabs}

\begin{document}

\begin{table}
\centering

\caption{Effect of Tilt on Module Output Power}

\small
\setlength{\tabcolsep}{2.5pt}
\setlength{\cmidrulekern}{1.25pt} % half of \tabcolsep

\begin{tabular}{
  @{}
  S[table-format=2.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=4.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=3.0]
  S[table-format=2.2]
  S[table-format=1.3]
  S[table-format=1.5,group-digits=false]
  @{}
}
\toprule
{Angle} &
  \multicolumn{9}{c}{Incident Radiation} &
  {Average} &
  {Voltage} &
  {Current} &
  {Power} \\
&
  \multicolumn{9}{c}{(\si{W/m^2})} &
  {(\si{W/m^2})} &
  {(\si{V})} &
  {(\si{A})} &
  {(\si{W})} \\
\cmidrule(r){1-1}
\cmidrule(lr){2-10}
\cmidrule(lr){11-11}
\cmidrule(lr){12-12}
\cmidrule(lr){13-13}
\cmidrule(l){14-14}
25 & 383 & 616 & 530 & 350 &  830 & 550 &  75 & 164 &  69 & 396 &  4.99 & 0.14  & 0.6986  \\
22 & 364 & 594 & 483 & 364 &  865 & 630 & 112 & 178 & 170 & 417 &  7.13 & 0.199 & 1.41887 \\
19 & 360 & 622 & 496 & 418 &  886 & 625 & 101 & 246 & 220 & 441 &  8.2  & 0.228 & 1.8696  \\
16 & 357 & 586 & 461 & 437 &  988 & 724 & 119 & 251 & 250 & 463 &  9    & 0.249 & 2.241   \\
13 & 393 & 595 & 459 & 451 &  953 & 721 & 124 & 274 & 306 & 475 &  9.6  & 0.265 & 2.544   \\
10 & 374 & 602 & 460 & 506 & 1012 & 736 & 167 & 288 & 287 & 492 & 10.16 & 0.28  & 2.8448  \\
 7 & 368 & 584 & 466 & 505 &  977 & 718 & 188 & 418 & 378 & 511 & 11.07 & 0.306 & 3.38742 \\
 4 & 351 & 538 & 420 & 545 & 1024 & 769 & 267 & 472 & 433 & 535 & 11.75 & 0.324 & 3.807   \\
 0 & 345 & 526 & 420 & 529 & 1059 & 789 & 280 & 481 & 465 & 543 & 12.17 & 0.331 & 4.02827 \\
\bottomrule
\end{tabular}

\end{table}
\end{document}

insira a descrição da imagem aqui

Responder3

Algumas sugestões:

  • Use um tabular*ambiente em vez de um tabularambiente e deixe o LaTeX calcular a largura do separador de colunas enquanto ainda ajusta a tabela dentro do bloco de texto

  • Use os recursos do siunitxpacote para alinhar o conteúdo das colunas de dados numéricos com as unidades em questão

  • Reduza a largura da 11ª coluna escrevendo Avg. IR, onde "IR" é definido como uma sigla no cabeçalho à esquerda

  • Sem regras verticais, uma única regra horizontal.

insira a descrição da imagem aqui

\documentclass{article}
\usepackage{caption,siunitx,rotating,booktabs}
\sisetup{per-mode=symbol,group-digits=false}
\begin{document}
\begin{table}
\small
\setlength\tabcolsep{0.01pt}
\caption{Effect of Tilt on Module Output Power}
\begin{tabular*}{\textwidth}{S[table-format=2.0] 
     @{\extracolsep{\fill}}
     *{4}{S[table-format=3.0]}
          S[table-format=4.0] 
     *{5}{S[table-format=3.0]}
          S[table-format=2.2] 
          S[table-format=1.3] 
          S[table-format=1.5] }
{Angle} & \multicolumn{9}{c}{Incident Radiation (IR)}  & {Avg.~IR} & {Voltage} & {Current} & {Power}  \\
& \multicolumn{9}{c}{(\si{\watt\per\meter\squared})}
& {(\si{\watt\per\meter\squared})} & {(\si{\volt})} & {(\si{\ampere})} & {(\si{\watt})}\\
\cmidrule{2-10}
25 & 383 & 616 & 530 & 350 & 830  & 550 & 75  & 164 & 69  & 396   & 4.99 & 0.14 & 0.6986 \\
22 & 364 & 594 & 483 & 364 & 865  & 630 & 112 & 178 & 170 & 417 & 7.13 & 0.199 & 1.41887   \\
19 & 360 & 622 & 496 & 418 & 886  & 625 & 101 & 246 & 220 & 441 & 8.2 & 0.228 & 1.8696 \\
16 & 357 & 586 & 461 & 437 & 988  & 724 & 119 & 251 & 250 & 463 & 9 & 0.249 & 2.241  \\
13 & 393 & 595 & 459 & 451 & 953  & 721 & 124 & 274 & 306 & 475  & 9.6 & 0.265 & 2.544  \\
10 & 374 & 602 & 460 & 506 & 1012 & 736 & 167 & 288 & 287 & 492  & 10.16 & 0.28 & 2.8448 \\
7  & 368 & 584 & 466 & 505 & 977  & 718 & 188 & 418 & 378 & 511  & 11.07 & 0.306 & 3.38742   \\
4  & 351 & 538 & 420 & 545 & 1024 & 769 & 267 & 472 & 433 & 535  & 11.75 & 0.324 & 3.807  \\
0  & 345 & 526 & 420 & 529 & 1059 & 789 & 280 & 481 & 465 & 543  & 12.17 & 0.331 & 4.02827  
\end{tabular*}
\end{table}
\end{document}

informação relacionada