我怎样才能按照图片合并细胞?谢谢。
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[czech]{babel}
\usepackage{indentfirst}
\usepackage{amsmath}
\usepackage[left=2cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{tabularx}
\usepackage{caption}
\captionsetup[table]{skip=10pt}
\begin{document}
\begin{table}[h!]\footnotesize
\caption{Zářič $^{137}$Cs - přirozené pozadí}
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
$PEAK$ [keV] &$E_{tab}$ [keV] &Zdroj& $FWHM$ [keV]&$NET$&$GROSS$ \\
\hline
609,35& 609,31& $^{214}$Bi& 1,38& 539& 4675\\ \cline{1-2} \cline{4-6}
1120,29& 1120,29& & 1,95& 558& 1530\\
1764,57& 1764,49& & 2,08& 451& 574\\
2204,36& 2204,21& & 1,86& 141& 188\\
1460,81& 1460,75& $^{40}$K& 1,73& 422& 738\\
74,71& rtg& $^{214}$Pb& 1,15& 2321& 34035\\
84,54& & & 1,22& 891& 16412\\
\hline
\end{tabular}
\label{Csp}
\end{table}
\end{document}
答案1
为了实现单个单元格在多行上垂直居中的所需对齐,您可以使用\multirow{<number of rows>}{>width>}{>content>}
如下例所示的命令:
\documentclass[12pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{caption}
\captionsetup[table]{skip=10pt}
\usepackage{multirow}
\begin{document}
\begin{table}[h!]\footnotesize
\caption{Zářič $^{137}$Cs - přirozené pozadí}
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
$PEAK$ [keV] &$E_{tab}$ [keV] &Zdroj& $FWHM$ [keV]&$NET$&$GROSS$ \\
\hline
609,35& 609,31& \multirow{4}{*}{$^{214}$Bi} & 1,38& 539& 4675\\ \cline{1-2} \cline{4-6}
1120,29& 1120,29& & 1,95& 558& 1530\\
1764,57& 1764,49& & 2,08& 451& 574\\
2204,36& 2204,21& & 1,86& 141& 188\\
1460,81& 1460,75& $^{40}$K& 1,73& 422& 738\\
74,71& \multirow{2}{*}{rtg}& \multirow{2}{*}{$^{214}$Pb}& 1,15& 2321& 34035\\
84,54& & & 1,22& 891& 16412\\
\hline
\end{tabular}
\label{Cs}
\end{table}
\end{document}
在下面的例子中,我做了一些调整,以改善数字的对齐方式和表格的整体可读性。(没有垂直线,来自包的水平线booktabs
,S
来自包的类型列siunitx
,白色空间来引导眼睛......)
\documentclass[12pt,a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{caption}
\captionsetup[table]{skip=10pt}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{output-decimal-marker = {,}}
\begin{document}
\begin{table}[h!]\footnotesize
\caption{Zářič $^{137}$Cs - přirozené pozadí}
\centering
\begin{tabular}{S[table-format=4.2]
S[table-format=4.2]
c
S[table-format=1.2]
S[table-format=4]
S[table-format=5]}
\toprule
{PEAK [\si{\kilo\electronvolt}]} & {E\textsubscript{tab} [\si{\kilo\electronvolt}]]} &Zdroj& {FWHM [\si{\kilo\electronvolt}]]} & {NET} & {GROSS} \\
\midrule
609,35& 609,31& \multirow{4}{*}{$^{214}$Bi} & 1,38& 539& 4675\\
1120,29& 1120,29& & 1,95& 558& 1530\\
1764,57& 1764,49& & 2,08& 451& 574\\
2204,36& 2204,21& & 1,86& 141& 188\\ \addlinespace
1460,81& 1460,75& $^{40}$K& 1,73& 422& 738\\ \addlinespace
74,71& {\multirow{2}{*}{rtg}}& \multirow{2}{*}{$^{214}$Pb} & 1,15& 2321& 34035\\
84,54& & & 1,22& 891& 16412\\
\bottomrule
\end{tabular}
\label{Cs}
\end{table}
\end{document}