![셀 사이의 수직선](https://rvso.com/image/309845/%EC%85%80%20%EC%82%AC%EC%9D%B4%EC%9D%98%20%EC%88%98%EC%A7%81%EC%84%A0.png)
누군가 셀 사이의 수직선을 완성하여 이 문제를 해결하는 방법을 친절하게 도와줄 수 있습니까?
문안 인사
\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
다음은 지침을 따르는 시도입니다.booktabs
전문적인 테이블과siunitx
수치 데이터의 정렬을 위해.
중괄호( {...}
)는 정렬할 숫자가 포함되지 않은 셀의 내용을 이스케이프하는 데 사용됩니다. \multicolumn
또한 해당 셀에 대해서도 이러한 목적을 수행합니다.
정렬에서 마이너스 기호를 위한 공간을 허용하는 것은 개인 취향의 문제입니다. 나는 그것을 위한 공간을 남겨 두지 않았지만( table-format=1.2
소수 구분 기호 앞의 한 자리와 뒤의 두 자리 숫자를 의미), 를 사용하여 공간을 남겨 둘 수 있습니다 table-format=-1.1
.
나는 또한 의 서문 에서 여러 번 *{<num-repeat>}{<col-spec>}
반복하여 반복을 피하곤 했습니다 .<col-spec>
<num-repeat>
tabular
\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}
표준 article
클래스에 비해 테이블이 너무 넓은데 어떤 클래스나 마진 설정을 사용하고 있는지 모르겠습니다. 해당 정보를 제공해 주시면 더 많은 도움을 드릴 수 있습니다.
답변2
실제로 수평 규칙과 호환되는 수직 규칙을 사용하려면 다음 {NiceTabular}
을 시도해야 합니다 nicematrix
(해당 환경에서 수직 규칙은 ---의 규칙과도 호환됩니다. 비록 이것이 수직 규칙을 사용하는 booktabs
정신에 전혀 부합하지는 않더라도) booktabs
규칙).
\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}
여러 컴파일이 필요합니다( nicematrix
내부적으로 PGF/Tikz 노드를 사용하기 때문에).
답변3
첫 번째 행 앞에 더미 행을 추가하는 것을 고려해보세요.
\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}
[-10pt]
취향에 맞게 조절할 수 있는 곳 . 작동하는지 알려주세요.