我画了这篇文章中展示的表格,但我不太喜欢这种风格。你有什么更好的设计想法吗,或者看起来还是还可以?
谢谢大家!
表格输出:
代码:
\documentclass{article}
\usepackage{tabu,booktabs,rotating,multirow}
\begin{document}
\begin{table}[H]
\centering
\caption{Divalent and trivalent metallic cations associations in anionic clays ($^{\star}$monovalent, $^{\star\star}$tetravalent)}
\label{tab:association}
\begin{tabu}{ccccccccccc}
\cmidrule[1pt]{3-11}
\multicolumn{1}{l}{} &
\multicolumn{1}{l}{} &
\multicolumn{9}{c}{\textbf{Divalent cations}} \\ \cline{3-11}
\multicolumn{1}{l}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{Mg} &
\multicolumn{1}{c|}{Mn} &
\multicolumn{1}{c|}{Fe} &
\multicolumn{1}{c|}{Co} &
\multicolumn{1}{c|}{Ni} &
\multicolumn{1}{c|}{Cu} &
\multicolumn{1}{c|}{Zn} &
\multicolumn{1}{c|}{Ca} &
\multicolumn{1}{c|}{Li$^{\star}$} \\ \cline{2-11}
\multicolumn{1}{|[1pt]c|}{\multirow{8}{*}{\begin{sideways}\textbf{Trivalent cations}\end{sideways}}} &
\multicolumn{1}{c|}{Al} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} \\ \cline{2-11}
\multicolumn{1}{|[1pt]c|}{} &
\multicolumn{1}{c|}{Cr} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} \\ \cline{2-11}
\multicolumn{1}{|[1pt]c|}{} &
\multicolumn{1}{c|}{Mn} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} \\ \cline{2-11}
\multicolumn{1}{|[1pt]c|}{} &
\multicolumn{1}{c|}{Fe} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} \\ \cline{2-11}
\multicolumn{1}{|[1pt]c|}{} &
\multicolumn{1}{c|}{Co} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} \\ \cline{2-11}
\multicolumn{1}{|[1pt]c|}{} &
\multicolumn{1}{c|}{Ni} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} \\ \cline{2-11}
\multicolumn{1}{|[1pt]c|}{} &
\multicolumn{1}{c|}{La} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} \\ \cline{2-11}
\multicolumn{1}{|[1pt]c|}{} &
\multicolumn{1}{c|}{Ti$^{\star\star}$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{$\times$} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} \\ \cline{2-11}
\end{tabu}
\end{table}
\end{document}
答案1
我认为,如果 (a) 所有数据列的宽度相同,并且 (b) 间距更近一些,表格看起来会更好。例如,可以通过从 切换到c
列w
类型,并减少 的值来实现tabcolsep
,该值是控制插入到每列两侧的空白填充量的参数。
话虽如此,我肯定也会删除几乎所有的\multicolumn{1}{...}{...}
包装器。包装器使代码变得非常乏味,也使应用任何更改或调整变得更加困难。
\documentclass{article}
\usepackage{array} % for 'w' column type
\usepackage{rotating,multirow}
\newcommand\ts{$\times$} % handy shortcut macro
\begin{document}
\begin{table}
\setlength\tabcolsep{4pt} % default: 6pt
\setlength\extrarowheight{1.5pt} % for a more open "look"
\centering
\caption{Divalent and trivalent metallic cations associations in
anionic clays ($^{\star}$monovalent, $^{\star\star}$tetravalent)}
\label{tab:association}
\begin{tabular}{ *{2}{l|} *{9}{w{c}{4mm}|} }
\multicolumn{2}{l}{} & \multicolumn{9}{c}{\textbf{Divalent cations}} \\
\cline{3-11}
\multicolumn{2}{l|}{} & Mg & Mn & Fe & Co & Ni & Cu & Zn & Ca & Li$^{\star}$ \\
\cline{2-11}
\multirow{8.5}{*}{\begin{sideways}\textbf{Trivalent cations}\end{sideways}}
& Al & \ts & & \ts & \ts & \ts & \ts & \ts & \ts & \ts \\
\cline{2-11}
& Cr & & & & & \ts & \ts & \ts & & \\
\cline{2-11}
& Mn & & \ts & & & & & & & \\
\cline{2-11}
& Fe & \ts & & \ts & \ts & & & & & \\
\cline{2-11}
& Co & & & & \ts & \ts & & & & \\
\cline{2-11}
& Ni & & & & & \ts & & & & \\
\cline{2-11}
& La & & & & & \ts & & & & \\
\cline{2-11}
& Ti$^{\star\star}$ & & & & \ts & & & & & \\
\cline{2-11}
\end{tabular}
\end{table}
\end{document}
附录:为了进一步“美化”表格及其相关标题的外观,可以加载包threeparttable
并将\caption
语句和tabular
环境包含在环境中threeparttable
。这样,标题的宽度将设置为tabular
环境的宽度。此添加以及删除加粗行和列标题以及值的进一步减少\tabcolsep
(从 4pt 到 3pt),将导致以下结果:
\documentclass{article}
\usepackage{array} % for 'w' column type
\usepackage{rotating,multirow}
\usepackage{threeparttable} % for 'threeparttable' env.
\newcommand\ts{$\times$} % handy shortcut macro
\begin{document}
\begin{table}
\centering
\begin{threeparttable}
\setlength\tabcolsep{3pt} % default: 6pt
\setlength\extrarowheight{2pt} % for a more open "look"
\caption{Divalent and trivalent metallic cation associations in
anionic clays ($^{\star}$mono\-valent, $^{\star\star}$tetravalent)}
\label{tab:association}
\begin{tabular}{ *{2}{l|} *{9}{w{c}{4mm}|} }
\multicolumn{2}{l}{} & \multicolumn{9}{c}{Divalent cations} \\
\cline{3-11}
\multicolumn{2}{l|}{} & Mg & Mn & Fe & Co & Ni & Cu & Zn & Ca & Li$^{\star}$ \\
\cline{2-11}
\multirow{8.5}{*}{\begin{sideways} Trivalent cations \end{sideways}\,}
& Al & \ts & & \ts & \ts & \ts & \ts & \ts & \ts & \ts \\
\cline{2-11}
& Cr & & & & & \ts & \ts & \ts & & \\
\cline{2-11}
& Mn & & \ts & & & & & & & \\
\cline{2-11}
& Fe & \ts & & \ts & \ts & & & & & \\
\cline{2-11}
& Co & & & & \ts & \ts & & & & \\
\cline{2-11}
& Ni & & & & & \ts & & & & \\
\cline{2-11}
& La & & & & & \ts & & & & \\
\cline{2-11}
& Ti$^{\star\star}$ & & & & \ts & & & & & \\
\cline{2-11}
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
答案2
因此,我采取了回答由@leandriis 作为基础。
使用 booktabs,删除了大部分行。我保留了第一行和第一列的两行,以强调第一列与第一行相似。您可以尝试删除它们。此外,还有一个不同的符号,因此amssymb
包括。
\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{chemmacros}
\usepackage{caption}
\usepackage{amssymb}
\usepackage[column=0]{cellspace}
\begin{document}
\begin{table}
\centering
\caption{Mono- to tetravalent metallic cations associations in anionic clays }
\label{tab:association}
\begin{tabular}{c|*{10}{0c}}
\toprule
\multicolumn{1}{c|}{}
& \ch{Mg^{2+}} & \ch{Mn^{2+}}& \ch{Fe^{2+}} & \ch{Co^{2+}} & \ch{Ni^{2+}} & \ch{Cu^{2+}} & \ch{Zn^{2+}} & \ch{Ca^{2+}} & \ch{Li^{+}} \\
\midrule
\ch{Al^{3+}} & \checkmark & & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\
\ch{Cr^{3+}} & & & & & \checkmark & \checkmark & \checkmark & & \\
\ch{Mn^{3+}} & & \checkmark & & & & & & & \\
\ch{Fe^{3+}} & \checkmark & & \checkmark & \checkmark & & & & & \\
\ch{Co^{3+}} & & & & \checkmark & \checkmark & & & & \\
\ch{Ni^{3+}} & & & & & \checkmark & & & & \\
\ch{La^{3+}} & & & & & \checkmark & & & & \\
\ch{Ti^{4+}} & & & & \checkmark & & & & & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案3
以下是另一个建议:
\documentclass{article}
\usepackage{array,rotating,multirow, booktabs}
\usepackage[table, svgnames]{xcolor}
\usepackage{bbding}
\newcommand\xs{\cellcolor{Gainsboro!50!Lavender}\XSolid}
\newcommand{\mc}[1]{\multicolumn{1}{c}{\bfseries#1}}
\begin{document}
\begin{table}
\setlength\tabcolsep{4pt}
\setlength\extrarowheight{6pt}
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
\centering
\caption{Divalent and trivalent metallic cations associations
in anionic clays ($^{\star}$monovalent, $^{\star\star}$tetravalent)}
\label{tab:association}
\begin{tabular}{ *{2}{ >{\bfseries}l}!{\vrule width 1.2pt}w{c}{5mm} *{8}{|w{c}{5mm}}!{\vrule width 1.2pt}}
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} &
\multicolumn{9}{c}{\textbf{Divalent cations}} \\
\multicolumn{2}{c}{} & \mc{Mg} & \mc{Mn} & \mc{Fe} & \mc{Co} & \mc{Ni} & \mc{Cu} & \mc{Zn} & \mc{Ca} & \mc{Li$^{\star}$} \\[1ex]
\cmidrule[1.2pt](l{-1.2pt}){3-11}
\multirow{8.5}{*}{\begin{sideways}\textbf{Trivalent cations}\end{sideways}\enspace}
& Al & \xs & & \xs & \xs & \xs & \xs & \xs & \xs & \xs \\
\cmidrule[0.4pt](l{-1.2pt}){3-11}
& Cr & & & & & \xs & \xs & \xs & & \\
\cmidrule[0.4pt](l{-1.2pt}){3-11}
& Mn & & \xs & & & & & & & \\
\cmidrule[0.4pt](l{-1.2pt}){3-11}
& Fe & \xs & & \xs & \xs & & & & & \\
\cmidrule[0.4pt](l{-1.2pt}){3-11}
& Co & & & & \xs & \xs & & & & \\
\cmidrule[0.4pt](l{-1.2pt}){3-11}
& Ni & & & & & \xs & & & & \\
\cmidrule[0.4pt](l{-1.2pt}){3-11}
& La & & & & & \xs & & & & \\
\cmidrule[0.4pt](l{-1.2pt}){3-11}
& Ti$^{\star\star}$ & & & & \xs & & & & & \\[-1.2pt]
\cmidrule[1.2pt](l{-1.2pt}){3-11}
\end{tabular}
\end{table}
\end{document}
答案4
在研究工作或论文中添加微小的细节会分散注意力,甚至可能令人反感:该领域的专家知道关于二价或三价或两者兼有的阳离子(论文审阅者将查看是否你我不知道它们是什么意思)。因此,我将省略长标签;如果愿意,您可以重新插入它们。
为了完整性,可以将一些细节添加到标题本身;可选参数\caption
只是为了这个:您可以在实际标题中包含信息,而无需将其包含在表格列表中。
在条目周围添加框线同样会分散注意力。行与行之间留出一些额外的空间可以方便跟踪它们。我将所有单元格的宽度设置为 1.5em 的固定宽度,并\Y
在输入中使用,以避免代码混乱,这样您就可以非常轻松地目视检查输入。
这些\multicolumn{1}{c|}{...}
都是邪恶的!单元格已经声明为c|
,那么为什么要覆盖它们只是为了使用相同的对齐方式?
\documentclass{article}
\usepackage{array,booktabs,caption}
\begin{document}
\begin{table}[htp]
\centering
\caption
[Divalent and trivalent metallic cations associations in anionic clays]
{Divalent and trivalent metallic cations associations in anionic clays;
* is monovalent, ** is tetravalent, rows list trivalent
cations, columns list divalent cations}
\label{tab:association}
% local command for simplifying input and reading
\newcommand{\Y}{$\times$}
\begin{tabular}{@{} w{l}{1.5em} *{9}{w{c}{1.5em}} @{}}
\toprule
& Mg & Mn & Fe & Co & Ni & Cu & Zn & Ca & Li* \\
\midrule
Al & \Y & & \Y & \Y & \Y & \Y & \Y & \Y & \Y \\
\addlinespace
Cr & & & & & \Y & \Y & \Y & & \\
\addlinespace
Mn & & \Y & & & & & & & \\
\addlinespace
Fe & \Y & & \Y & \Y & & & & & \\
\addlinespace
Co & & & & \Y & \Y & & & & \\
\addlinespace
Ni & & & & & \Y & & & & \\
\addlinespace
La & & & & & \Y & & & & \\
\addlinespace
Ti** & & & & \Y & & & & & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
带标签的版本。由于也需要进行一些猜测\multirow
,因此我选择将旋转后的标签设置在表格外部,并将其固定在底部,以便于猜测。
\documentclass{article}
\usepackage{array,booktabs,caption,rotating}
\begin{document}
\begin{table}[htp]
\centering
\caption
[Divalent and trivalent metallic cations associations in anionic clays]
{Divalent and trivalent metallic cations associations in anionic clays;
* is monovalent, ** is tetravalent, rows list trivalent
cations, columns list divalent cations}
\label{tab:association}
% local command for simplifying input and reading
\newcommand{\Y}{$\times$}
\rotatebox{90}{\makebox[11.5\normalbaselineskip]{Trivalent cations}}\quad
\begin{tabular}[b]{@{} w{l}{1.5em} *{9}{w{c}{1.5em}} @{}}
\toprule
& \multicolumn{9}{c}{Divalent cations} \\
& Mg & Mn & Fe & Co & Ni & Cu & Zn & Ca & Li* \\
\midrule
Al & \Y & & \Y & \Y & \Y & \Y & \Y & \Y & \Y \\
\addlinespace
Cr & & & & & \Y & \Y & \Y & & \\
\addlinespace
Mn & & \Y & & & & & & & \\
\addlinespace
Fe & \Y & & \Y & \Y & & & & & \\
\addlinespace
Co & & & & \Y & \Y & & & & \\
\addlinespace
Ni & & & & & \Y & & & & \\
\addlinespace
La & & & & & \Y & & & & \\
\addlinespace
Ti** & & & & \Y & & & & & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}