vertikale Linie zwischen den Zellen

vertikale Linie zwischen den Zellen

könnte mir jemand freundlicherweise helfen, dieses Problem zu lösen, indem er die vertikale Linie zwischen den Zellen vervollständigt.

Grüße

Bildbeschreibung hier eingeben

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

Antwort1

Hier ist ein Versuch nach den Richtlinien vonbooktabsfür professionelle Tische undsiunitxzur Ausrichtung der Zahlendaten.

Beachten Sie, dass Klammern ( {...}) verwendet werden, um den Inhalt von Zellen zu maskieren, die keine auszurichtenden Zahlen enthalten. \multicolumndient für diese Zellen auch diesem Zweck.

Ob bei der Ausrichtung Platz für das Minuszeichen gelassen wird, ist Geschmackssache. Ich habe keinen Platz dafür gelassen ( table-format=1.2bedeutet eine Zahl mit einer Ziffer vor und zwei Ziffern nach dem Dezimaltrennzeichen), aber mit könnte man Platz dafür lassen table-format=-1.1.

Ich habe es auch gewohnt, *{<num-repeat>}{<col-spec>}Wiederholungen zu vermeiden, indem ich <col-spec> <num-repeat>die Zeiten in der tabularPräambel von wiederholt habe.

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

Bildbeschreibung hier eingeben

Die Tabelle ist zu breit für die Standardklasse article, aber ich habe keine Ahnung, welche Klassen- oder Randeinstellungen Sie verwenden. Ich kann Ihnen dabei besser helfen, wenn Sie mir diese Informationen geben.

Antwort2

Wenn Sie tatsächlich vertikale Regeln verwenden möchten, die mit Ihren horizontalen Regeln kompatibel sind, sollten Sie es mit „of“ versuchen {NiceTabular}( nicematrixin dieser Umgebung sind die vertikalen Regeln auch mit den Regeln von kompatibel booktabs– obwohl die booktabsVerwendung vertikaler Regeln überhaupt nicht im Sinne von „of“ ist).

 \documentclass{article}
 \usepackage{xcolor}
 \usepackage{nicematrix}
 \usepackage{geometry}

 \makeatletter
 \def\hlinewd#1{%
 \noalign{\ifnum0=`}\fi\hrule \@height #1 %
 \futurelet\reserved@a\@xhline} 
 \makeatother

 \begin{document}

 \begin{table}[htbp]
 \renewcommand{\arraystretch}{1.2}
 \centering
 \caption{\textsc{Discrete Probability Distribution of Wind and Solar Resources, and Load}}
 \begin{NiceTabular}{cc | cc | cc}[colortbl-like]
 \hlinewd{1.5pt}
 \RowStyle{\bfseries}
 \rowcolor[gray]{.9} \Block{1-2}{Solar} && \Block{1-2}{Wind} && \Block{1-2}{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{NiceTabular}
 \label{tab4.1}
 \end{table}
     
 \end{document}

Sie benötigen mehrere Kompilierungen (da nicematrixim Hintergrund PGF/Tikz-Knoten verwendet werden).

Ausgabe des obigen Codes

Antwort3

Erwägen Sie das Hinzufügen einer Blindzeile vor Ihrer ersten Zeile:

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

wo man das [-10pt]nach eigenem Geschmack anpassen kann. Sag mir Bescheid, ob es klappt.

verwandte Informationen