我尝试在下表的第 1、2 和 6 列(每个单元格的上、下、左、右边框)上放置红色边框,但仅从第 3 行(包括在内!)开始。
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{float}
\usepackage{graphicx}
\begin{document}
% Please add the following required packages to your document preamble:
\begin{table}[H]
\resizebox{\textwidth}{!}{\begin{tabular}{|c|c|c|c|c|c|c|c|cc|}
\hline
\rowcolor[HTML]{C0C0C0}
\textbf{\begin{tabular}[c]{@{}c@{}}Principal\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Period\\ notation\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Radial\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Azimuthal\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Orbital\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Orbital\\ notation\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Magnetic quantum\\ number\end{tabular}} & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}\textbf{Spin}} & \multicolumn{2}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Maximum\\ number of\\ electrons in\end{tabular}}} \\ \hline
\rowcolor[HTML]{EFEFEF}
\multicolumn{1}{|l|}{\cellcolor[HTML]{EFEFEF}$n=n_r+n_\theta$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}symbol} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}$n_r=n-1,\ldots,0$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}$n_\varphi=k=1,\ldots,n$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}$l=k-1$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}symbol} & $m_l$ & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}$m_s$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}shell} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}period} \\ \hline
1 & K & $0$ & $1$ & $0$ & 1s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & $2$ \\ \hline \hline
& & $1$ & $1$ & $0$ & 2s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
\multirow{-2}{*}{2} & \multirow{-2}{*}{L} & $0$ & $2$ & $1$ & 2p & $-1,0+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \multirow{-2}{*}{$8$} \\ \hline \hline
& & $2$ & $1$ & $0$ & 3s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
& & $1$ & $2$ & $0$ & 3p & $-1,0,+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \\ \cline{3-9}
\multirow{-3}{*}{3} & \multirow{-3}{*}{M} & $0$ & $3$ & $1$ & 3d & $-2,-1,0,+1,+2$ & $+,-$ & \multicolumn{1}{c|}{$10$} & \multirow{-3}{*}{$18$} \\ \hline \hline
& & $3$ & $1$ & $0$ & 4s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
& & $2$ & $2$ & $1$ & 4p & $-1,0,+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \\ \cline{3-9}
& & $1$ & $3$ & $2$ & 4d & $-2,-1,0,+1,+2$ & $+,-$ & \multicolumn{1}{c|}{$10$} & \\ \cline{3-9}
\multirow{-4}{*}{4} & \multirow{-4}{*}{N} & $0$ & $4$ & $3$ & 4f & $-3,-2,-1,0,+1,+2,+3$ & $+,-$ & \multicolumn{1}{c|}{$14$} & \multirow{-4}{*}{$32$} \\ \hline \hline
& & $4$ & $1$ & $0$ & 5s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
& & $3$ & $2$ & $1$ & 5p & $-1,0,+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \\ \cline{3-9}
& & $2$ & $3$ & $2$ & 5d & $-2,-1,0,+1,+2$ & $+,-$ & \multicolumn{1}{c|}{$10$} & \\ \cline{3-9}
& & $1$ & $4$ & $3$ & 5f & $-3,-2,-1,0,+1,+2,+3$ & $+,-$ & \multicolumn{1}{c|}{$14$} & \\ \cline{3-9}
\multirow{-5}{*}{5} & \multirow{-5}{*}{O} & $0$ & $5$ & $4$ & 5g & $-4,-3,-2,-1,0,+1,+2,+3,+4$ & $+,-$ & \multicolumn{1}{c|}{$18$} & \multirow{-5}{*}{$50$} \\ \hline \hline
\end{tabular}}
\end{table}
\end{document}
但是我失败了。任何帮助我都感激不尽。
答案1
这是我最好的版本。不知道其他边框该怎么做。
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{float}
\usepackage{graphicx}
\usepackage{showframe}
\begin{document}
% Please add the following required packages to your document preamble:
\begin{table}[p]
\centering\
\setlength{\tabcolsep}{5pt}%
\rotatebox{90}{\begin{tabular}{|c@{\textcolor{red}{\vline}}c@{\textcolor{red}{\vline}}c|c|c|c@{\textcolor{red}{\vline}}c|c|cc|}
\hline
\rowcolor[HTML]{C0C0C0}
\textbf{\begin{tabular}[c]{@{}c@{}}Principal\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Period\\ notation\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Radial\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Azimuthal\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Orbital\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Orbital\\ notation\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Magnetic quantum\\ number\end{tabular}} & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}\textbf{Spin}} & \multicolumn{2}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Maximum\\ number of\\ electrons in\end{tabular}}} \\ \hline
\rowcolor[HTML]{EFEFEF}
\multicolumn{1}{|l|}{\cellcolor[HTML]{EFEFEF}$n=n_r+n_\theta$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}symbol} & \multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}$n_r$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}$n_\varphi$} & {\cellcolor[HTML]{EFEFEF}$l=k-1$} & \multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}symbol} & $m_l$ & \multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}$m_s$} & \multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}shell} & \multicolumn{1}{c|}{\cellcolor[HTML]{EFEFEF}sum} \\ \hline
1 & K & $0$ & $1$ & $0$ & 1s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & $2$ \\ \hline \hline
& & $1$ & $1$ & $0$ & 2s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
\multirow{-2}{*}{2} & \multirow{-2}{*}{L} & $0$ & $2$ & $1$ & 2p & $-1,0+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \multirow{-2}{*}{$8$} \\ \hline \hline
& & $2$ & $1$ & $0$ & 3s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
& & $1$ & $2$ & $0$ & 3p & $-1,0,+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \\ \cline{3-9}
\multirow{-3}{*}{3} & \multirow{-3}{*}{M} & $0$ & $3$ & $1$ & 3d & $-2,-1,0,+1,+2$ & $+,-$ & \multicolumn{1}{c|}{$10$} & \multirow{-3}{*}{$18$} \\ \hline \hline
& & $3$ & $1$ & $0$ & 4s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
& & $2$ & $2$ & $1$ & 4p & $-1,0,+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \\ \cline{3-9}
& & $1$ & $3$ & $2$ & 4d & $-2,-1,0,+1,+2$ & $+,-$ & \multicolumn{1}{c|}{$10$} & \\ \cline{3-9}
\multirow{-4}{*}{4} & \multirow{-4}{*}{N} & $0$ & $4$ & $3$ & 4f & $-3,-2,-1,0,+1,+2,+3$ & $+,-$ & \multicolumn{1}{c|}{$14$} & \multirow{-4}{*}{$32$} \\ \hline \hline
& & $4$ & $1$ & $0$ & 5s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
& & $3$ & $2$ & $1$ & 5p & $-1,0,+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \\ \cline{3-9}
& & $2$ & $3$ & $2$ & 5d & $-2,-1,0,+1,+2$ & $+,-$ & \multicolumn{1}{c|}{$10$} & \\ \cline{3-9}
& & $1$ & $4$ & $3$ & 5f & $-3,-2,-1,0,+1,+2,+3$ & $+,-$ & \multicolumn{1}{c|}{$14$} & \\ \cline{3-9}
\multirow{-5}{*}{5} & \multirow{-5}{*}{O} & $0$ & $5$ & $4$ & 5g & $-4,-3,-2,-1,0,+1,+2,+3,+4$ & $+,-$ & \multicolumn{1}{c|}{$18$} & \multirow{-5}{*}{$50$} \\ \hline \hline
\end{tabular}}
\end{table}
\end{document}
答案2
我认为您的表格的一个严重问题是,如果不使用放大镜,它几乎无法辨认。
请帮您的读者一个大忙,要么将表格以横向格式呈现,要么应用缩写(例如q.n.
for quantum number
)并选择额外的换行符以缩小列宽。还请考虑通过省略所有垂直线和大多数水平线来提高表格的可读性,就像下面显示的 LaTeX 代码和相关屏幕截图一样。
观察表格现在是否适合文本块没有不得不诉诸\resizebox
大锤。哦,通过使整个表格更清晰易读,您可能还可以跳过突出显示某些列。
\documentclass[a4paper]{article}
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{float}
\usepackage{graphicx}
% new:
\usepackage{booktabs} % for well-spaced horizontal rules
\newcommand\mytab[1]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}
\begin{document}
%% before:
\begin{table}[H]
\resizebox{\textwidth}{!}{\begin{tabular}{|c|c|c|c|c|c|c|c|cc|}
\hline
\rowcolor[HTML]{C0C0C0}
\textbf{\begin{tabular}[c]{@{}c@{}}Principal\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Period\\ notation\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Radial\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Azimuthal\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Orbital\\ quantum\\ number\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Orbital\\ notation\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Magnetic quantum\\ number\end{tabular}} & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}\textbf{Spin}} & \multicolumn{2}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{\begin{tabular}[c]{@{}c@{}}Maximum\\ number of\\ electrons in\end{tabular}}} \\ \hline
\rowcolor[HTML]{EFEFEF}
\multicolumn{1}{|l|}{\cellcolor[HTML]{EFEFEF}$n=n_r+n_\theta$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}symbol} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}$n_r=n-1,\ldots,0$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}$n_\varphi=k=1,\ldots,n$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}$l=k-1$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}symbol} & $m_l$ & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}$m_s$} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}shell} & \multicolumn{1}{l|}{\cellcolor[HTML]{EFEFEF}period} \\ \hline
1 & K & $0$ & $1$ & $0$ & 1s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & $2$ \\ \hline \hline
& & $1$ & $1$ & $0$ & 2s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
\multirow{-2}{*}{2} & \multirow{-2}{*}{L} & $0$ & $2$ & $1$ & 2p & $-1,0+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \multirow{-2}{*}{$8$} \\ \hline \hline
& & $2$ & $1$ & $0$ & 3s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
& & $1$ & $2$ & $0$ & 3p & $-1,0,+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \\ \cline{3-9}
\multirow{-3}{*}{3} & \multirow{-3}{*}{M} & $0$ & $3$ & $1$ & 3d & $-2,-1,0,+1,+2$ & $+,-$ & \multicolumn{1}{c|}{$10$} & \multirow{-3}{*}{$18$} \\ \hline \hline
& & $3$ & $1$ & $0$ & 4s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
& & $2$ & $2$ & $1$ & 4p & $-1,0,+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \\ \cline{3-9}
& & $1$ & $3$ & $2$ & 4d & $-2,-1,0,+1,+2$ & $+,-$ & \multicolumn{1}{c|}{$10$} & \\ \cline{3-9}
\multirow{-4}{*}{4} & \multirow{-4}{*}{N} & $0$ & $4$ & $3$ & 4f & $-3,-2,-1,0,+1,+2,+3$ & $+,-$ & \multicolumn{1}{c|}{$14$} & \multirow{-4}{*}{$32$} \\ \hline \hline
& & $4$ & $1$ & $0$ & 5s & $0$ & $+,-$ & \multicolumn{1}{c|}{$2$} & \\ \cline{3-9}
& & $3$ & $2$ & $1$ & 5p & $-1,0,+1$ & $+,-$ & \multicolumn{1}{c|}{$6$} & \\ \cline{3-9}
& & $2$ & $3$ & $2$ & 5d & $-2,-1,0,+1,+2$ & $+,-$ & \multicolumn{1}{c|}{$10$} & \\ \cline{3-9}
& & $1$ & $4$ & $3$ & 5f & $-3,-2,-1,0,+1,+2,+3$ & $+,-$ & \multicolumn{1}{c|}{$14$} & \\ \cline{3-9}
\multirow{-5}{*}{5} & \multirow{-5}{*}{O} & $0$ & $5$ & $4$ & 5g & $-4,-3,-2,-1,0,+1,+2,+3,+4$ & $+,-$ & \multicolumn{1}{c|}{$18$} & \multirow{-5}{*}{$50$} \\ \hline \hline
\end{tabular}}
\end{table}
%% after:
\begin{table}[h]
\setlength\thickmuskip{0mu} % no space around relational operators
\setlength\medmuskip{0mu} % no space around binary operators
\scriptsize % for a 30% linear reduction in font size
\setlength\tabcolsep{0pt} % let LaTeX figure out intercol. whitespace amount
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{10}{c} }
\toprule
\mytab{Principal\\ q.n.} & \mytab{Period\\ notation} &
\mytab{Radial\\ q.n.} & \mytab{Azimuthal\\ q.n.} &
\mytab{Orbital\\ q.n.} & \mytab{Orbital\\ notation} &
\mytab{Magnetic\\q.n.} & Spin &
\multicolumn{2}{c}{\mytab{Max.\ \# of\\ electrons in}} \\
\addlinespace
$n=n_r+n_\theta$ & symbol &
\mytab{$n_r=n-1,$\\$\ldots,0$} &
\mytab{$n_\varphi=k=$\\$1,\ldots,n$} &
$l=k-1$ & symbol & $m_l$ & $m_s$ & shell & period \\
\midrule
$1$ & K & $0$ & $1$ & $0$ & 1s & $0$ & $+,-$ & $2$ & $2$ \\
\addlinespace % insert vertical whitespace
$2$ & L & $1$ & $1$ & $0$ & 2s & $0$ & $+,-$ & $2$ & $8$ \\
& & $0$ & $2$ & $1$ & 2p & $0,\pm1$ & $+,-$ & $6$ & \\
\addlinespace
$3$ & M & $2$ & $1$ & $0$ & 3s & $0$ & $+,-$ & $2$ & $18$ \\
& & $1$ & $2$ & $0$ & 3p & $0,\pm1$ & $+,-$ & $6$ & \\
& & $0$ & $3$ & $1$ & 3d & $0,\pm1,\pm2$ & $+,-$ & $10$ & \\
\addlinespace
$4$ & N & $3$ & $1$ & $0$ & 4s & $0$ & $+,-$ & $2$ & $32$ \\
& & $2$ & $2$ & $1$ & 4p & $0,\pm1$ & $+,-$ & $6$ & \\
& & $1$ & $3$ & $2$ & 4d & $0,\pm1,\pm2$ & $+,-$ & $10$ & \\
& & $0$ & $4$ & $3$ & 4f & $0,\pm1,\pm2,\pm3$ & $+,-$ & $14$ & \\
\addlinespace
$5$ & O & $4$ & $1$ & $0$ & 5s & $0$ & $+,-$ & $2$ & $50$ \\
& & $3$ & $2$ & $1$ & 5p & $0,\pm1$ & $+,-$ & $6$ & \\
& & $2$ & $3$ & $2$ & 5d & $0,\pm1,\pm2$ & $+,-$ & $10$ & \\
& & $1$ & $4$ & $3$ & 5f & $0,\pm1,\pm2,\pm3$ & $+,-$ & $14$ & \\
& & $0$ & $5$ & $4$ & 5g & $0,\pm1,\pm2,\pm3,\pm4$ & $+,-$ & $18$ & \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}