我想在化学符号“Nb”和上方单元格的水平线之间留出更多空间。使用\stretcharray
命令有助于添加此空间,但过多增加数字会导致表格太大,“Nb2O5”和所有其他化学符号也是如此。有没有更合适的方法可以添加此空间?
\documentclass[10pt,a4paper]{article}
\usepackage{blindtext}
\usepackage{setspace}
\begin{document}
\renewcommand{\arraystretch}{1.2}% for the vertical padding of table cells
\newcommand*{\myparbox}[2][12mm]{\parbox{#1}{{\footnotesize \bfseries #2}}}
\begin{table}[H]
\setstretch{0.85}
\caption{Input parameters used for the GA optimizer.}
\footnotesize% IMS: need this to get the 9pt text size in table cells % TODO is correct ?
\centering
\begin{tabular}{|l|c|c|l|}
\hline
& {\myparbox[10mm]{Material}} & {\myparbox{Property}} & {\myparbox{Value}} \\
\hline
\parbox[t]{2mm}{ \multirow{7}{*}{\rotatebox[origin=c {90}{Scenario 1}}} & Nb & $m_r$ & 1 \\
& & $\Psi$ & $4.33 \ eV$ \\
& NbN & $m_r$ & $1$\\
& & $\Psi$ & $4.7 \ eV$ \\
\cline{2-4}
& Nb\textsubscript{2}O\textsubscript{5} & $m_r$ & $1$\\
& & $\chi$ & $4.23 \ eV$ \\
& & $K$ & $25$ \\
\hline
\parbox[t]{2mm}{\multirow{8}{*}{\rotatebox[origin=c]{90}{Scenario 2}}} & Al & $m_r$ & 1 \\
& & $\Psi$ & $5 \ eV$ \\
\cline{2-4}
& Nb\textsubscript{2}O\textsubscript{5} & $m_r$ & 1\\
& & $\chi$ & $4.44 \ eV$ \\
& & $K$ & 25 \\
& Al\textsubscript{2}O\textsubscript{3} & $m_r$ & 1\\
& & $\chi$ & $2.32 \ eV$ \\
& & $K$ & 9.7 \\
\hline
\end{tabular}
\label{tab_inputpar}
%\vspace{-\baselineskip}% remove one line of space below this table
\end{table}
\end{document}
对于任何不必要的软件包,我提前表示歉意,因为我在发布之前迅速清理了不必要的软件包。提前致谢。
答案1
我会重新设计你的表格如下:
\documentclass[a4paper]{article}
\usepackage[skip=1ex]{caption}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\usepackage{rotating}
\usepackage{booktabs, makecell, multirow}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{}
\begin{document}
\begin{table}
\caption{Input parameters used for the GA optimizer.}
\label{tab_inputpar}
\centering
%\footnotesize% IMS: need this to get the 9pt text size in table cells % TODO is correct ?
\renewcommand{\arraystretch}{0.9}% for the vertical padding of table cells
\settowidth\rotheadsize{Scenario 2}
\begin{tabular}{l c >{$}c<{$} l }
\toprule
& \thead{Material} & \text{\thead{Property}} & \thead{Value} \\
\midrule
\multirow{7}{*}{\rotcell{Scenario 1}}
& \ce{Nb} & m_r & 1 \\
& & \Psi & \SI{4.33}{eV} \\
\addlinespace
& \ce{NbN} & m_r & 1\\
& & \Psi & \SI{4.7}{eV} \\
\addlinespace
& \ce{Nb2O5} & m_r & 1\\
& & \chi & \SI{4.23}{eV} \\
& & K & 25 \\
\midrule
\multirow{8}{*}{\rotcell{Scenario 2}}
& Al & m_r & 1 \\
& & \Psi & \SI{5}{ eV} \\
\addlinespace
&\ce{Nb2O5} & m_r & 1\\
& & \chi & \SI{4.44}{eV} \\
& & K & 25 \\
\addlinespace
& \ce{Al2O3} & m_r & 1 \\
& & \chi & \SI{2.32}{eV} \\
& & K & 9.7 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
在代码中考虑您问题下面的所有评论。
答案2
我建议使用这个更简单的代码,基于makecell
单元格填充和格式,siunitx
以及chemformula
:
\documentclass[10pt, a4paper]{article}
\usepackage{blindtext}
\usepackage{setspace}
\usepackage{siunitx, chemformula}
\usepackage{float, multirow, rotating, caption, makecell}
\begin{document}
\newcommand*{\myparbox}[2][12mm]{\parbox{#1}{{\footnotesize \bfseries #2}}}
\begin{table}[H]
\caption{Input parameters used for the GA optimizer.}
\setcellgapes{2pt}\makegapedcells
\footnotesize% IMS: need this to get the 9pt text size in table cells % TODO is correct ?
\renewcommand{\theadfont}{\bfseries}
\centering
\begin{tabular}{|l|c|c|l|}
\hline
& \thead{Material} & \thead{Property} & \thead{Value} \\
\hline
\parbox[t]{2mm}{ \multirow{7}{*}{\rotatebox[origin=c]{90}{Scenario 1}}} & \ch{Nb} & $m_r$ & 1 \\
& & $\Psi$ & \SI{4.33}{\eV} \\
& \ch{NbN} & $m_r$ & \Gape[1ex][0pt]{1}% \bigstrut[t]
\\
& & $\Psi$ & \SI{4.7}{\eV} \\
\cline{2-4}
&\ch{Nb2O5} & $m_r$ & $1$\\
& & $\chi$ & \SI{4.23}{\ eV} \\
& & $K$ & $25$ \\
\hline
\parbox[t]{2mm}{\multirow{8}{*}{\rotatebox[origin=c]{90}{Scenario 2}}} & Al & $m_r$ & 1 \\
& & $\Psi$ & \SI{5}{\eV} \\
\cline{2-4}
& \ch{Nb2 O5} & $m_r$ & 1\\
& & $\chi$ & \SI{4.44}{\eV} \\
& & $K$ & 25 \\
& \ch{Al2 O3} & $m_r$ & \Gape[1ex][0pt]{1}\\
& & $\chi$ & \SI{2.32}{\eV} \\
& & $K$ & 9.7 \\
\hline
\end{tabular}
\label{tab_inputpar}
%\vspace{-\baselineskip}% remove one line of space below this table
\end{table}
\end{document}