
테이블이 있고 일부 행을 강조표시하고 싶습니다.
나는 다음을 사용하고 있습니다 :
\usepackage[table]{xcolor}
그리고:
\rowcolor{gray!50}
이는 다음을 생성합니다.
단색 블록으로 전체 행을 강조하고 싶습니다.
like this!
어떤 조언이라도 주시면 감사하겠습니다!
MWE:
\begin{table*}[ht]
\centering
\setlength{\tabcolsep}{1mm}
\begin{tabular}{cccccc}
\hline\hline
\thead{Name} & \thead{Observing\\Frequency\\(MHz)} & \thead{Mean Standard Deviation of\\On-Pulse Phase Bins} & \thead{Peak Systematic\\Variability} & \thead{Average Systematic\\Variability} & \thead{Noisy\\Variability} \\
\hline
\rowcolor{gray!50}
B1747 & 1400 & 8.83 & 281.00 & 0.95 & 8.68 \\
B1747 & 2030 & 3.61 & 6.15 & 0.09 & 3.66 \\
B1747 & 1500 & 2.37 & 5.47 & 0.19 & 2.35 \\
B1347 & 820 & 1.44 & 4.59 & 0.09 & 1.43 \\
\rowcolor{gray!50}
B1921 & 820 & 5.46 & 34.23 & 2.56 & 3.87 \\
C1921 & 1500 & 5.16 & 12.00 & 1.12 & 4.86 \\
D1921 & 1400 & 4.93 & 22.66 & 1.84 & 3.96 \\
B1921 & 2030 & 2.82 & 14.01 & 1.29 & 2.25 \\
\hline
\end{tabular}
\caption{caption}
\label{var_table}
\end{table*}
답변1
를 사용하여 테이블의 열 사이에 공간을 추가하려면 균일한 공간 변경을 위해 \rowcolor
사용해야 합니다 . \setlength{\tabcolsep}{5mm}
변경 사항이 균일하지 않아야 하는 경우 공백만 삽입하는 추가 열을 삽입할 수 있습니다( 사용 <{\hspace{5mm}}
). 후자의 경우 추가 &
를 사용하여 빈 열을 추가해야 합니다.
\documentclass[]{scrartcl}
\usepackage[table]{xcolor}
\begin{document}
Wrong:
\begin{tabular}[]{@{\hspace{5mm}}c@{\hspace{10mm}}c@{\hspace{5mm}}}
\hline
\rowcolor{gray!50}a&b\\
\hline
\end{tabular}
\\good:
{
\setlength{\tabcolsep}{5mm}
\begin{tabular}[]{cc}
\hline
\rowcolor{gray!50}a&b\\
\hline
\end{tabular}
}
\\not uniform:
{
\setlength{\tabcolsep}{0mm}
\begin{tabular}[]{c<{\hspace{7mm}}c<{\hspace{12mm}}c<{\hspace{5mm}}}
\hline
\rowcolor{gray!50}&a&b\\
\hline
\end{tabular}
}
\end{document}
첫 번째 테이블에서는 작동하지 않지만 두 번째 및 세 번째 테이블에서는 원하는 결과를 제공합니다.
답변2
패키지는 tabularray
간단합니다.
\documentclass[twocolumn]{article}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\begin{document}
\begin{table*}[ht]
\centering
\begin{talltblr}[
note{a} = {Mean Standard Deviation}
]{
hline{1,Z}=1pt, hline{2}=0.6pt,
colspec = {X[l,m] X[c,m, si={table-format=4}]
X[c,m, si={table-format=1.2}]
X[c,m, si={table-format=3.2}]
X[c,m, si={table-format=1.2}]
X[c,m, si={table-format=1.2}]
},
row{1} = {font=\small\bfseries},
}
Name & {{{Observing Frequency (MHz)}}}
& {{{MSD\TblrNote{a} of On-Pulse Phase Bins}}}
& {{{Peak Systematic Variability}}}
& {{{Average Systematic Variability}}}
& {{{ Noisy Variability }}} \\
\SetRow{bg=gray8}
B1747 & 1400 & 8.83 & 281.00 & 0.95 & 8.68 \\
B1747 & 2030 & 3.61 & 6.15 & 0.09 & 3.66 \\
B1747 & 1500 & 2.37 & 5.47 & 0.19 & 2.35 \\
B1347 & 820 & 1.44 & 4.59 & 0.09 & 1.43 \\
\SetRow{gray8}
B1921 & 820 & 5.46 & 34.23 & 2.56 & 3.87 \\
C1921 & 1500 & 5.16 & 12.00 & 1.12 & 4.86 \\
D1921 & 1400 & 4.93 & 22.66 & 1.84 & 3.96 \\
B1921 & 2030 & 2.82 & 14.01 & 1.29 & 2.25 \\
\end{talltblr}
\end{table*}
\end{document}
답변3
{NiceTabular}
패키지 환경은 행, 열 및 셀 색상을 지정하는 클래식 명령과 유사한 명령을 nicematrix
제공합니다(키가 강제로 실행되는 경우 ).colortbl-like
colortbl
@{\hspace{...}
두 열 사이의 공간을 늘리는 데 사용하더라도 예상한 출력을 얻을 수 있습니다 .
또한 어떤 PDF 뷰어를 사용하든 얇은 흰색 선이 표시되지 않습니다.
\documentclass{article}
\usepackage{nicematrix}
\usepackage{makecell}
\begin{document}
\begin{table*}[ht]
\centering
\setlength{\tabcolsep}{1mm}
\begin{NiceTabular}{c@{\hspace{2cm}}ccccc}[colortbl-like]
\hline\hline
\RowStyle{\bfseries}
\thead{Name} & \thead{Observing\\Frequency\\(MHz)} & \thead{Mean Standard Deviation of\\On-Pulse Phase Bins} & \thead{Peak Systematic\\Variability} & \thead{Average Systematic\\Variability} & \thead{Noisy\\Variability} \\
\hline
\rowcolor{gray!50}
B1747 & 1400 & 8.83 & 281.00 & 0.95 & 8.68 \\
B1747 & 2030 & 3.61 & 6.15 & 0.09 & 3.66 \\
B1747 & 1500 & 2.37 & 5.47 & 0.19 & 2.35 \\
B1347 & 820 & 1.44 & 4.59 & 0.09 & 1.43 \\
\rowcolor{gray!50}
B1921 & 820 & 5.46 & 34.23 & 2.56 & 3.87 \\
C1921 & 1500 & 5.16 & 12.00 & 1.12 & 4.86 \\
D1921 & 1400 & 4.93 & 22.66 & 1.84 & 3.96 \\
B1921 & 2030 & 2.82 & 14.01 & 1.29 & 2.25 \\
\hline
\end{NiceTabular}
\caption{caption}
\label{var_table}
\end{table*}
\end{document}
여러 컴파일이 필요합니다( nicematrix
내부적으로 PGF/Tikz 노드를 사용하기 때문에).