![Latex 中是否有代码可以制作如上所示的工作包表?](https://linux22.com/image/436630/Latex%20%E4%B8%AD%E6%98%AF%E5%90%A6%E6%9C%89%E4%BB%A3%E7%A0%81%E5%8F%AF%E4%BB%A5%E5%88%B6%E4%BD%9C%E5%A6%82%E4%B8%8A%E6%89%80%E7%A4%BA%E7%9A%84%E5%B7%A5%E4%BD%9C%E5%8C%85%E8%A1%A8%EF%BC%9F.png)
是否有代码可以在乳胶中制作这样的表格?
我目前正在使用以下代码,我想将第一行设置为灰色
\usepackage{colortbl}
\documentclass[a4paper,11pt]{article}
\begin{table}[h]
\centering
\begin{tabular}{|>{\columncolor[gray]{0.8}}c|c|c|c|c|c|c|c|}
\hline
128&64&32&16&8&4&2&1\\\hline
1&0&1&1&0&1&0&1\\\hline
1&0&1&1&0&1&0&1\\\hline
\end{tabular}
\end{table}
\end{document}
答案1
作为起点:
在上表中使用了以下包:(booktabs
用于\addlinespace
第一和第二个表行之间),makecell˙(for columns' headers),
threeparttable (for notes in table) and
siunitx` 用于格式化最后四个表的列中的数字。
\documentclass[a4paper,11pt]{article}
\usepackage[table]{xcolor}
\usepackage{siunitx}
\usepackage{booktabs, makecell, threeparttable}
\begin{document}
\begin{table}[ht]
\begin{threeparttable}
\begin{tabular}{|w{l}{4em}|l|
S[table-format=2.0]|
S[table-format=3.2, table-column-width=4em]|
*{2}{S[table-format=2.0, table-column-width=4em]|}
}
\rowcolor{black}
\multicolumn{6}{c}{\textcolor{white}{some text}} \\
\addlinespace
\hline
\rowcolor{gray!80}
\makecell[l]{WP\\ Number\tnote{53}}
& WP Title
& {\makecell{Lead\\ benefeciary\\ number\tnote{55}}}
& {\makecell{Person-\\ moths\tnote{56}}}
& {\makecell{Start\\ month\tnote{57}}}
& {\makecell{End\\ month\tnote{58}}} \\
\hline
WP 1& package 1 title
& 7 & 171.00 & 1 & 36 \\
\hline
WP 2& package 2 title
& 6 & 192.00 & 1 & 36 \\
\hline
WP 3& package 3 title
& 26 & 102.00 & 2 & 36 \\
\hline
WP 4& package 4 title
& 13 & 73.00 & 1 & 36 \\
\hline
WP 5& package 5 title
& 21 & 72.00 & 1 & 36 \\
\hline
WP 6& package 6 title
& 1 & 48.00 & 1 & 36 \\
\hline
\multicolumn{2}{r|}{}
& {\cellcolor{gray!80} Total}
& \cellcolor{gray!80} 658.00
& \multicolumn{2}{l}{} \\
\cline{3-4}
\end{tabular}
\begin{tablenotes}[flushleft]\footnotesize
\item[53] some explanation
\item[55] some explanation
\item[56] some explanation
\item[57] some explanation
\item[58] some explanation
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
第二栏的真实文字留给OP去写。
附录:
作为练习,可以使用tabularray
包编写此表。这个新的表包(这里使用的是 L 版本)的语法略有不同,可以将表格格式与内容分开。其详细信息在包的文档中描述(这是其安装的一部分,也可以通过 Google 的帮助找到):
\documentclass[a4paper,11pt]{article}
\usepackage[table]{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\begin{document}
\vspace*{21\baselineskip}
\begin{table}[ht]
\begin{tblr}{hline{1-9},
hline{2} = {white, 3pt},
vline{1,2,6,7} = {1-8}{solid},
vline{3-5} = {1-9}{solid},
colspec = {X[0.9,m] l
X[m,c,si]
X[m,c,si]
X[m,c,si]
X[m,c,si]},
row{1} = {bg=black,fg=white},
row{2} = {bg=gray!80, font=\small\linespread{0.84}\selectfont},
}
\multicolumn{6}{c}{\textcolor{white}{some text}} \\
{WP\\ Number\footnotemark[53]}
& WP Title
& {{{Lead\\ benefeciary\\ number\footnotemark[55]}}}
& {{{Person-\\ moths\footnotemark[56]}}}
& {{{Start\\ month\footnotemark[57]}}}
& {{{End\\ month\footnotemark[58]}}} \\
WP 1& package 1 title
& 7 & 171.00 & 1 & 36 \\
WP 2& package 2 title
& 6 & 192.00 & 1 & 36 \\
WP 3& package 3 title
& 26 & 102.00 & 2 & 36 \\
WP 4& package 4 title
& 13 & 73.00 & 1 & 36 \\
WP 5& package 5 title
& 21 & 72.00 & 1 & 36 \\
WP 6& package 6 title
& 1 & 48.00 & 1 & 36 \\
& & \SetCell{bg=gray!80} {{{Total:}}}
& \SetCell{bg=gray!80} 658.00
& & \\
\cline{3-4}
\end{tblr}
\end{table}
\footnotetext[53]{\ some explanation}
\footnotetext[55]{\ some explanation}
\footnotetext[56]{\ some explanation}
\footnotetext[57]{\ some explanation}
\footnotetext[58]{\ some explanation}
\end{document}
结果与以前类似: