4

This is my code.

\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}

Why is the vertical separator line after second line incomplete (not up to the top of the table)?

  • Your example isn't complete too, it misses the float package ;-). And it should be \multicolumn{9}{c|}{...}, You have to explicitly specify the right | always if there should be one, the left one is added automatically, if there has been one in the tabular description – user31729 Aug 2 '15 at 20:25
  • @ChristianHupfer It compiles properly without giving any error or warning. Also, Adding the float package doesn't change anything. – Yogesh Yadav Aug 2 '15 at 20:27
  • I couldn't compile with the [H] specifier. This normally needs the float package – user31729 Aug 2 '15 at 20:29
4

Use \multicolumn{9}{c|}{Incident Radiation ($W/m^2$)} instead, i.e. add the | explicitly if there must be a vertical line at all, since \multicolumn does use a | at the left column automatically, if it has been specified in the tabular description, but not the right | one. Omitting this | is a frequent 'error'.

By the way: c|ccccccccc|c|c|c|c can be replaced by c|*{9}c|*{3}{c|}c

  • Consider using siunitx for the units
  • In my opinion, the columns holding integer numbers (i.e. the first 10 columns should be right aligned, not centered.

Edit Some suggested improvements (more may be done)

\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}

enter image description here

| improve this answer | |
  • There are some other issues I've to figure out ;-) No comments please, I'll try to make some improvements – user31729 Aug 2 '15 at 20:33
  • @egreg: As I said, I am not finished ;-) – user31729 Aug 2 '15 at 20:36
  • @egreg What is the purpose of those % ? – Yogesh Yadav Aug 2 '15 at 21:05
  • @YogeshYadav: The % prevent spurius spaces. – user31729 Aug 2 '15 at 21:27
5

You should say \multicolumn{9}{c|}{...}: the separation bar belongs to the column preceding it (in LaTeX's logic), except the one before the first column that belongs also to the first column.

However, using \resizebox{\textwidth}{!}{...} is usually not the best choice. You should first try reducing the width of the columns, for instance separating the units in a different row.

Using siunitx makes for alignment of the figures, while booktabs gives a more professional look to the table.

I reduced the font to \footnotesize and \tabcolsep to the maximum in order not to get an overfull line.

\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}

enter image description here

If you reduce the header of the eleventh column just to “Average”, you can even use \small and a larger \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}

enter image description here

| improve this answer | |
1

Some suggestions:

  • Use a tabular* environment instead of a tabular environment, and let LaTeX calculate how wide the column separator should be while still making the table fit inside the text block

  • Use the capabilities of the siunitx package both to align the contents of the numerical data columns the units in question

  • Narrow the width of the 11th column by writing Avg. IR, where "IR" is defined as an acronym in the header to the left

  • No vertical rules, one single horizontal rule.

enter image description here

\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}
| improve this answer | |

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.