1

could someone kindly help me out how to solve this problem by completing the vertical line between the cells.

Regards

enter image description here

\begin{table}[htbp]
%\setlength\extrarowheight{3pt}
\renewcommand{\arraystretch}{1.2}
  \centering
  \caption{\textsc{Discrete Probability Distribution of Wind and Solar Resources, and Load}}
    \begin{tabular}{cc | cc | cc}
 \hlinewd{1.5pt}
\rowcolor[gray]{.9} \multicolumn{2}{c | }{\textbf{Solar}} & \multicolumn{2}{| c | }{\textbf{Wind }} & \multicolumn{2}{c}{\textbf{Load}} \\
 \hlinewd{1.5pt}
    \% of deviation      & Probability  & \% of deviation          & Probability     & \% of deviation           & Probability \\
        $e_{PV}$ & $\rho_{PV}$  &  $e_{W}$ &   $\rho_{W}$    &  $e_{L}$     & $\rho_{L}$ \\
 \hlinewd{1.5pt}
    -2.5 & 0.2 & -5    & 0.05 & -5    & 0.05 \\
         0 & 0.6 & -2.5 & 0.1   & -2.5 & 0.15 \\
      2.5 & 0.2 & 0      & 0.7   & 0      & 0.6 \\
         - & -    & 2.5    & 0.1   & 2.5  & 0.15 \\
          - & -    & 5      & 0.05 & 5     & 0.05 \\
 \hlinewd{1.5pt}
    \end{tabular}%
  \label{tab4.1}%
\end{table}%
  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Apr 21 '15 at 20:43
  • 2
    No, please add the code to your table post above ;-) – user31729 Apr 21 '15 at 20:48
  • The booktabs package recommends the following: "Never, ever use vertical rules". Have you considered redesigning your table with just horizontal lines? – onewhaleid Apr 21 '15 at 23:19
  • 2
    Please post a complete example as the link posted above describes. Your current code cannot be compiled as is and uses non-standard commands which might come from anywhere (so it cannot even be completed without figuring out where those commands are from or how they should be defined). – cfr Apr 22 '15 at 0:25
  • Or just use booktabs if you want a professional-looking table, as suggested above. – cfr Apr 22 '15 at 0:25
2

Here's an attempt following the guidelines of booktabs for professional tables and siunitx for alignment of the numerical data.

Note that braces ({...}) are used to escape the contents of cells that do not contain numbers to be aligned. \multicolumn also serves this purpose for those cells.

Allowing space for the minus sign in the alignment is a matter of personal taste. I did not leave room for it (table-format=1.2 means a number with one digit before and two digits after the decimal separator), but you could leave room for it with table-format=-1.1.

I've also used *{<num-repeat>}{<col-spec>} to avoid repetition by repeating <col-spec> <num-repeat> times in the tabular's preamble.

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

\begin{document}
\begin{tabular}{
  *{2}{S[table-format=1.1]} 
  *{2}{S[table-format=1.1]S[table-format=1.2]}
}
  \toprule
  \multicolumn{2}{c}{Solar} & \multicolumn{2}{c}{Wind} & \multicolumn{2}{c}{Load} \\
  \cmidrule(lr){1-2}          \cmidrule(lr){3-4}         \cmidrule(lr){5-6}
  {\% of deviation} & {Probability} & 
    {\% of deviation} & {Probability} & 
    {\% of deviation} & {Probability} \\
  {$e_{PV}$} & {$\rho_{PV}$} & 
    {$e_{W}$} & {$\rho_{W}$} & 
    {$e_{L}$} & {$\rho_{L}$} \\
  \midrule
   -2.5 &   0.2 & -5.0 & 0.05 & -5.0 & 0.05 \\
    0.0 &   0.6 & -2.5 & 0.10 & -2.5 & 0.15 \\
    2.5 &   0.2 &  0.0 & 0.70 &  0.0 & 0.60 \\
  {---} & {---} &  2.5 & 0.10 &  2.5 & 0.15 \\
  {---} & {---} &  5.0 & 0.05 &  5.0 & 0.05 \\
  \bottomrule
\end{tabular}
\end{document}

enter image description here

The table is too wide for the standard article class, but I have no idea what class or margin settings you are using. I can help more with this if you provide that information.

0

Consider adding a dummy row before your first row:

\begin{tabular}{cc|cc|cc}
\hlinewd{1.5pt}
\rowcolor[gray]{.9} & & & & & \\[-10pt]
\rowcolor[gray]{.9}\multicolumn{2}{c|}{\textbf{Solar}} & \multicolumn{2}{|c|}
{\textbf{Wind}} & \multicolumn{2}{c}{\textbf{Load}} \\
\hlinewd{1.5pt}

where the [-10pt] can be adjusted to suit your taste. Tell me if it works.

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.