
表があり、いくつかの行を強調表示したいと思います。
使っています:
\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 番目と 3 番目の表では目的の結果が得られています。
答え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{...}
2 つの列間のスペースを増やすためにを使用した場合でも、期待どおりの出力が得られます。
さらに、どの 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 ノードが使用されるため)。