![línea vertical entre las celdas](https://rvso.com/image/309845/l%C3%ADnea%20vertical%20entre%20las%20celdas.png)
¿Alguien podría ayudarme amablemente a resolver este problema completando la línea vertical entre las celdas?
Saludos
\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}%
Respuesta1
He aquí un intento siguiendo las pautas debooktabs
para mesas profesionales ysiunitx
para la alineación de los datos numéricos.
Tenga en cuenta que las llaves ( {...}
) se utilizan para escapar del contenido de las celdas que no contienen números para alinear. \multicolumn
También sirve para este propósito para esas células.
Dejar espacio para el signo menos en la alineación es una cuestión de gusto personal. No dejé espacio para ello ( table-format=1.2
es decir, un número con un dígito antes y dos dígitos después del separador decimal), pero puedes dejarle espacio con table-format=-1.1
.
También solía *{<num-repeat>}{<col-spec>}
evitar la repetición repitiendo <col-spec>
<num-repeat>
tiempos en el tabular
preámbulo.
\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}
La tabla es demasiado amplia para la article
clase estándar, pero no tengo idea de qué configuración de clase o margen está utilizando. Puedo ayudar más con esto si proporcionas esa información.
Respuesta2
Si realmente desea usar reglas verticales compatibles con sus reglas horizontales, debería intentarlo {NiceTabular}
( nicematrix
en ese entorno, las reglas verticales también son compatibles con las reglas de booktabs
--- aunque esto no está en absoluto en el espíritu de booktabs
usar reglas verticales). normas).
\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}
Necesita varias compilaciones (porque nicematrix
utiliza nodos PGF/Tikz bajo el capó).
Respuesta3
Considere agregar una fila ficticia antes de la primera fila:
\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}
donde [-10pt]
se puede ajustar a su gusto. Dime si funciona.