![linha vertical entre as células](https://rvso.com/image/309845/linha%20vertical%20entre%20as%20c%C3%A9lulas.png)
alguém poderia me ajudar a resolver esse problema completando a linha vertical entre as células.
Cumprimentos
\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}%
Responder1
Aqui está uma tentativa seguindo as diretrizes debooktabs
para mesas profissionais esiunitx
para alinhamento dos dados numéricos.
Observe que colchetes ( {...}
) são usados para escapar do conteúdo das células que não contêm números a serem alinhados. \multicolumn
também serve a esse propósito para essas células.
Permitir espaço para o sinal de menos no alinhamento é uma questão de gosto pessoal. Eu não deixei espaço para isso ( table-format=1.2
significa um número com um dígito antes e dois dígitos depois do separador decimal), mas você poderia deixar espaço para isso com table-format=-1.1
.
Eu também costumava *{<num-repeat>}{<col-spec>}
evitar repetições repetindo <col-spec>
<num-repeat>
os tempos no tabular
preâmbulo do '.
\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}
A tabela é muito larga para a article
classe padrão, mas não tenho ideia de quais classes ou configurações de margem você está usando. Posso ajudar mais com isso se você fornecer essas informações.
Responder2
Se você realmente deseja usar regras verticais compatíveis com suas regras horizontais, você deve tentar {NiceTabular}
( nicematrix
nesse ambiente, as regras verticais também são compatíveis com as regras de booktabs
--- mesmo que isso não esteja no espírito de booktabs
usar vertical regras).
\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}
Você precisa de várias compilações (porque nicematrix
usa nós PGF/Tikz nos bastidores).
Responder3
Considere adicionar uma linha fictícia antes da primeira linha:
\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}
onde o [-10pt]
pode ser ajustado para se adequar ao seu gosto. Diga-me se funciona.