请参阅下面的代码和显示代码输出的附加图片。我正在制作一个表格,它快完成了,但最后一件事困扰着我。标题为“上层”的列单元格中的文本未居中。
\newcommand{\rotatemultirow}[1]{\parbox[t]{3mm}{\multirow{6}{*}{\rotatebox[origin=l]{90}{#1}}}}
\begin{table}[t!]
\caption{Caption.}
{\setlength{\extrarowheight}{2pt}%
\begin{tabular}{|c|>{\centering}p{24mm}|>{\centering}p{20mm}|>{\centering}p{15mm}|>{\centering}p{22mm}|>{\centering}p{12mm}|>{\centering}p{12mm}|>{\centering}p{12mm}|}
\cline{2-8}
\multicolumn{1}{c|}{}
& $\begin{matrix} \textbf{Upper} \\\textbf{Level} \end{matrix}$
& $\begin{matrix} \textbf{Lower} \\\textbf{Level} \end{matrix}$
& $\begin{matrix} \textbf{$\mathbf{\lambda_{ij}}$} \\ \text{(nm)} \end{matrix}$
& $\begin{matrix} \textbf{$\mathbf{A_{ij}}$} \\ \text{(10$^{7}$ s$^{-1}$)} \end{matrix}$
& $\begin{matrix} \textbf{$\mathbf{\beta_{exp}}$} \\ \text{(\%)} \end{matrix}$
& $\begin{matrix} \textbf{$\mathbf{\beta_{th}}$} \\ \text{(\%)} \end{matrix}$
& $\begin{matrix} \textbf{$\mathbf{\beta_{rec}}$} \\ \text{(\%)} \end{matrix}$ \tabularnewline
\cline{1-8}
\hline
\textbf{He} &$\dagger$ & $^{3}$S$_{1}$ & 1083.3 & 1.02 & \textemdash & \textemdash & \textemdash \tabularnewline
\hline
\rotatemultirow{\textbf{Neon}\hspace{1cm}}
&\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$133.1\,nm)}}
& 1s$_{2}$ & 693.1 & 1.74-1.88 & 38 & 35 & 37 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 630.7 & 0.42-0.59 & 11 & 11 & 11 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 614.5 & 2.16-2.82 & 51 & 54 & 52 \bigstrut \tabularnewline
\cline{2-8}
& \multirow{3}[8]{20mm}{\makecell{2p$_{8}$\\(2$\times$133.5\,nm)}}
& 1s$_{2}$ & 717.6 & 0.26-0.37 & 7 & 3 & 6 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 650.8 & 2.03-3.00 & 58 & 63 & 60 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 633.6 & 1.26-1.77 & 35 & 34 & 34 \bigstrut \tabularnewline
\hline
\rotatemultirow{\textbf{Argon}\hspace{1cm}}
&\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$188.3\,nm)}}
& 1s$_{2}$ & 922.5 & 0.59-0.63 & 16 & 16 & 26 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 800.6 & 0.48-0.51 & 13 & 12 & 25 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 763.5 & 2.62-2.96 & 71 & 72 & 49 \bigstrut \tabularnewline
\cline{2-8}
& \multirow{3}[8]{20mm}{\makecell{2p$_{8}$\\(2$\times$189.4\,nm)}}
& 1s$_{2}$ & 978.5 & 0.11-0.17 & 3 & 5 & 7 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 842.5 & 2.11-2.52 & 66 & 67 & 51 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 801.5 & 1.00-1.04 & 31 & 28 & 43 \bigstrut \tabularnewline
\hline
\rotatemultirow{\textbf{Krypton}\hspace{1cm}}
&\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$214.8\,nm)}}
& 1s$_{2}$ & 1373.9 & 0.02-0.03 & 0 & 1 & 7 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 819.0 & 0.9-1.1 & 26 & 24 & 22 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 760.2 & 2.6-3.1 & 74 & 75 & 71 \bigstrut \tabularnewline
\cline{2-8}
&\multirow{3}[8]{20mm}{\makecell{2p$_{8}$\\(2$\times$216.7\,nm)}}
& 1s$_{2}$ & 1547.4 & 0.003-0.008 & 0 & 0 & 1 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 877.7 & 1.5-2.6 & 68 & 68 & 69 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 810.4 & 0.7-1.1 & 32 & 32 & 30 \bigstrut \tabularnewline
\hline
\rotatemultirow{\textbf{Xenon}\hspace{1cm}}
&\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$252.5\,nm)}}
& 1s$_{2}$ & 4932.4 & 0.002 & 0 & 0 & 0 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 895.5 & 1.06 & 21 & 30 & 9 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 823.4 & 2.49 & 79 & 70 & 91 \bigstrut \tabularnewline
\cline{2-8}
&\multirow{3}[8]{20mm}{\makecell{2p$_{9}$\\(2$\times$256.0\,nm)}}
& 1s$_{2}$ & 10698.1 & 0 & 0 & 0 & 0 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 992.6 & 1.96 & 49 & 65 & 71 \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 904.8 & 1.07 & 51 & 35 & 29 \bigstrut \tabularnewline
\hline
\rotatemultirow{\textbf{Radon}\hspace{-0.2cm}}
&\multirow{2}[8]{20mm}{\vspace{-3mm}\makecell{2p$_{6}$\\(2$\times$290.7\,nm)}}
& 1s$_{4}$ & 781.2 & NA & NA & NA & NA \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 705.7 & NA & NA & NA & NA \bigstrut \tabularnewline
\cline{2-8}
&\multirow{2}[8]{20mm}{\vspace{-3mm}\makecell{2p$_{9}$\\(2$\times$299.8\,nm)}}
& 1s$_{4}$ & 933.0 & NA & NA & NA & NA \bigstrut \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 827.3 & NA & NA & NA & NA \bigstrut \tabularnewline
\hline
\end{tabular}}
\label{tbl:choosingTransition}
\end{table}
答案1
这是一个更简单的代码,用于siunitx
在第 4 列的小数点上对齐数字,并使用以下内容垂直填充单元格makecell
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage[detect-weight]{siunitx}
\usepackage{array, caption, multirow, makecell, bigstrut, rotating}
\renewcommand\theadfont{\boldmath\bfseries\normalsize}
\newcommand{\rotatemultirow}[2][6]{\parbox[t]{3mm}{\multirow{#1 }{*}{\rotatebox[origin=c]{90}{#2}}}}
\begin{document}
\begin{table}[t!]
\captionsetup{skip=6pt}
\caption{Caption.}
\sisetup{table-number-alignment=center}
\setlength{\extrarowheight}{3pt}\centering%
\setcellgapes[b]{2pt}\makegapedcells
\begin{tabular}
{|c|>{\centering}p{24mm}|>{\centering}p{20mm}|S[table-format=5.1]|>{\centering}p{18mm}|*{3}{>{\centering}p{12mm}|}}%
% {|c|>{\centering}p{24mm}|>{\centering}p{20mm}|>{\centering}p{15mm}|>{\centering}p{22mm}|*{3}{>{\centering}p{12mm}|}}
\cline{2-8}
\multicolumn{1}{c|}{}
&\thead{Upper \\ Level}
&\thead{Lower \\ Level}
&{\thead{$\lambda_{ij}$ \\ (nm)}}
&\thead{$A_{ij}$ \\ (\SI{e7}{\per\s})}
&\thead{$\beta_{\exp}$ \\ (\%)}
&\thead{$\beta_\text{th}$ \\ (\%)}
&\thead{$\beta_\text{rec}$ \\ (\%)} \tabularnewline
\cline{1-8}
\hline
\textbf{He} &$\dagger$ & $^{3}$S$_{1}$ & 1083.3 & 1.02 & \textemdash & \textemdash & \textemdash \tabularnewline
\hline
\rotatemultirow[6.8]{\textbf{Neon}}
% &\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$133.1\,nm)}}
&\multirowcell{3}{2p$_{6}$\\(2$\times$133.1\,nm)}
& 1s$_{2}$ & 693.1 & 1.74--1.88 & 38 & 35 & 37 \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 630.7 & 0.42--0.59 & 11 & 11 & 11 \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 614.5 & 2.16--2.82 & 51 & 54 & 52 \tabularnewline
\cline{2-8}
&\multirowcell{3}{2p$_{8}$\\(2$\times$133.5\,nm)}
& 1s$_{2}$ & 717.6 & 0.26--0.37 & 7 & 3 & 6 \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 650.8 & 2.03--3.00 & 58 & 63 & 60 \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 633.6 & 1.26--1.77 & 35 & 34 & 34 \tabularnewline
\hline
\rotatemultirow[6.8]{\textbf{Argon}}
&\multirowcell{3}{2p$_{6}$\\(2$\times$188.3\,nm)}
& 1s$_{2}$ & 922.5 & 0.59--0.63 & 16 & 16 & 26 \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 800.6 & 0.48--0.51 & 13 & 12 & 25 \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 763.5 & 2.62--2.96 & 71 & 72 & 49 \tabularnewline
\cline{2-8}
&\multirowcell{3}{2p$_{8}$\\(2$\times$189.4\,nm)}
& 1s$_{2}$ & 978.5 & 0.11--0.17 & 3 & 5 & 7 \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 842.5 & 2.11--2.52 & 66 & 67 & 51 \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 801.5 & 1.00--1.04 & 31 & 28 & 43 \tabularnewline
\hline
\rotatemultirow[6.8]{\textbf{Krypton}}
&\multirowcell{3}{2p$_{6}$\\(2$\times$214.8\,nm)}
& 1s$_{2}$ & 1373.9 & 0.02--0.03 & 0 & 1 & 7 \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 819.0 & 0.9--1.1 & 26 & 24 & 22 \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 760.2 & 2.6--3.1 & 74 & 75 & 71 \tabularnewline
\cline{2-8}
&\multirowcell{3}{2p$_{8}$\\(2$\times$216.7\,nm)}
& 1s$_{2}$ & 1547.4 & 0.003--0.008 & 0 & 0 & 1 \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 877.7 & 1.5--2.6 & 68 & 68 & 69 \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 810.4 & 0.7--1.1 & 32 & 32 & 30 \tabularnewline
\hline
\rotatemultirow[6.9]{\textbf{Xenon}}
&\multirowcell{3}{2p$_{6}$\\(2$\times$252.5\,nm)}
& 1s$_{2}$ & 4932.4 & 0.002 & 0 & 0 & 0 \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 895.5 & 1.06 & 21 & 30 & 9 \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 823.4 & 2.49 & 79 & 70 & 91 \tabularnewline
\cline{2-8}
&\multirowcell{3}{2p$_{9}$\\(2$\times$256.0\,nm)}
& 1s$_{2}$ & 10698.1 & 0 & 0 & 0 & 0 \tabularnewline \cline{3-8}
& & 1s$_{4}$ & 992.6 & 1.96 & 49 & 65 & 71 \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 904.8 & 1.07 & 51 & 35 & 29 \tabularnewline
\hline
\rotatemultirow[4.5]{\textbf{Radon}}
&\multirowcell{2}{2p$_{6}$\\(2$\times$290.7\,nm)}
& 1s$_{4}$ & 781.2 & NA & NA & NA & NA \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 705.7 & NA & NA & NA & NA \tabularnewline
\cline{2-8}
&\multirowcell{2}{2p$_{9}$\\(2$\times$299.8\,nm)}
& 1s$_{4}$ & 933.0 & NA & NA & NA & NA \tabularnewline \cline{3-8}
& & 1s$_{5}$ & 827.3 & NA & NA & NA & NA \tabularnewline
\hline
\end{tabular}
\label{tbl:choosingTransition}
\end{table}
\end{document}
答案2
{NiceTabular}
供参考,这里有一种使用制作该表的方法nicematrix
。
在该环境中,您可以使用命令\Block
和键在水平和垂直方向上合并单元格hvlines
,除块和(左上)角之外的所有规则都将通过键绘制corners=NW
。
此外,块的内容始终放在合并单元格构建的矩形的数学中心(使用时multirow
,有时您必须手动调整)。
然而,您需要多次编译。
\documentclass{article}
\usepackage{geometry}
\usepackage[detect-weight]{siunitx}
\usepackage{caption}
\usepackage{nicematrix}
\begin{document}
\begin{table}[t!]
\captionsetup{skip=6pt}
\caption{Caption.}
\sisetup{table-number-alignment=center}
\setlength{\extrarowheight}{3pt}
\centering%
\NiceMatrixOptions{cell-space-bottom-limit=2pt}
\begin{NiceTabular} [hvlines,corners=NW]
{>{\bfseries}c
w{c}{24mm}
w{c}{20mm}
S[table-format=5.1]
w{c}{18mm}
*{3}{w{c}{12mm}}}
\RowStyle{\bfseries\boldmath}
&\Block{}{Upper \\ Level}
&\Block{}{Lower \\ Level}
&\Block{}{$\lambda_{ij}$ \\ (nm)}
&\Block{}{$A_{ij}$ \\ ($10^7$ $\text{s}^{-1}$)}
&\Block{}{$\beta_{\exp}$ \\ (\%)}
&\Block{}{$\beta_\text{th}$ \\ (\%)}
&\Block{}{$\beta_\text{rec}$ \\ (\%)} \\
He &$\dagger$ & $^{3}$S$_{1}$ & 1083.3 & 1.02 & \textemdash & \textemdash & \textemdash \\
\Block{6-1}<\rotate>{Neon}
&\Block{3-1}{2p$_{6}$\\(2$\times$133.1\,nm)}
& 1s$_{2}$ & 693.1 & 1.74--1.88 & 38 & 35 & 37 \\
& & 1s$_{4}$ & 630.7 & 0.42--0.59 & 11 & 11 & 11 \\
& & 1s$_{5}$ & 614.5 & 2.16--2.82 & 51 & 54 & 52 \\
&\Block{3-1}{2p$_{8}$\\(2$\times$133.5\,nm)}
& 1s$_{2}$ & 717.6 & 0.26--0.37 & 7 & 3 & 6 \\
& & 1s$_{4}$ & 650.8 & 2.03--3.00 & 58 & 63 & 60 \\
& & 1s$_{5}$ & 633.6 & 1.26--1.77 & 35 & 34 & 34 \\
\Block{6-1}<\rotate>{Argon}
&\Block{3-1}{2p$_{6}$\\(2$\times$188.3\,nm)}
& 1s$_{2}$ & 922.5 & 0.59--0.63 & 16 & 16 & 26 \\
& & 1s$_{4}$ & 800.6 & 0.48--0.51 & 13 & 12 & 25 \\
& & 1s$_{5}$ & 763.5 & 2.62--2.96 & 71 & 72 & 49 \\
&\Block{3-1}{2p$_{8}$\\(2$\times$189.4\,nm)}
& 1s$_{2}$ & 978.5 & 0.11--0.17 & 3 & 5 & 7 \\
& & 1s$_{4}$ & 842.5 & 2.11--2.52 & 66 & 67 & 51 \\
& & 1s$_{5}$ & 801.5 & 1.00--1.04 & 31 & 28 & 43 \\
\Block{6-1}<\rotate>{Krypton}
&\Block{3-1}{2p$_{6}$\\(2$\times$214.8\,nm)}
& 1s$_{2}$ & 1373.9 & 0.02--0.03 & 0 & 1 & 7 \\
& & 1s$_{4}$ & 819.0 & 0.9--1.1 & 26 & 24 & 22 \\
& & 1s$_{5}$ & 760.2 & 2.6--3.1 & 74 & 75 & 71 \\
&\Block{3-1}{2p$_{8}$\\(2$\times$216.7\,nm)}
& 1s$_{2}$ & 1547.4 & 0.003--0.008 & 0 & 0 & 1 \\
& & 1s$_{4}$ & 877.7 & 1.5--2.6 & 68 & 68 & 69 \\
& & 1s$_{5}$ & 810.4 & 0.7--1.1 & 32 & 32 & 30 \\
\Block{6-1}<\rotate>{Xenon}
&\Block{3-1}{2p$_{6}$\\(2$\times$252.5\,nm)}
& 1s$_{2}$ & 4932.4 & 0.002 & 0 & 0 & 0 \\
& & 1s$_{4}$ & 895.5 & 1.06 & 21 & 30 & 9 \\
& & 1s$_{5}$ & 823.4 & 2.49 & 79 & 70 & 91 \\
&\Block{3-1}{2p$_{9}$\\(2$\times$256.0\,nm)}
& 1s$_{2}$ & 10698.1 & 0 & 0 & 0 & 0 \\
& & 1s$_{4}$ & 992.6 & 1.96 & 49 & 65 & 71 \\
& & 1s$_{5}$ & 904.8 & 1.07 & 51 & 35 & 29 \\
\Block{4-1}<\rotate>{Radon}
&\Block{2-1}{2p$_{6}$\\(2$\times$290.7\,nm)}
& 1s$_{4}$ & 781.2 & NA & NA & NA & NA \\
& & 1s$_{5}$ & 705.7 & NA & NA & NA & NA \\
&\Block{2-1}{2p$_{9}$\\(2$\times$299.8\,nm)}
& 1s$_{4}$ & 933.0 & NA & NA & NA & NA \\
& & 1s$_{5}$ & 827.3 & NA & NA & NA & NA \\
\end{NiceTabular}
\label{tbl:choosingTransition}
\end{table}
\end{document}