我有下表,并尝试调整行高,以使文本不像现在这样拥挤。有什么方法可以做到这一点吗?
代码:
\documentclass[12pt, a4paper]{report}
\usepackage[margin=20mm]{geometry}
\begin{document}
\begin{table}[]
\begin{tabular}{lll}
\textbf{Variable Conceptualizations} \\
\hline
Variable Function & Variable & Operationalization \\ \hline
Dependent Variable & Z{i,t-1} & $\frac{X_{i,t-1}}{Y_{i,t-1}}$ \\
Independent Variable & Var1 & \begin{tabular}[c]{@{}l@{}}Text\\ Text2\end{tabular} \\
& Var2 & \begin{tabular}[c]{@{}l@{}}Text\\ Text2\end{tabular} \\
Moderator Variable & Var3 & $\frac{X_{i,t}}{Y_{i,t}}$ \\
Control Variable & Var4 & $ln(X)_{i,t}$ \\
& X & $\frac{X_{i,t}} {X_{i,t}}$ \\
& Var5 & $\frac{X_{i,t}}{X_{i,t}}$\\
& Var6 & \begin{tabular}[c]{@{}l@{}}Text \\ Text2\end{tabular} \\
& Var7 & \begin{tabular}[c]{@{}l@{}}Text\\ Text2\end{tabular} \\
& Var8 & $\frac{X}{Y}$ \\
& Var9 & $\frac{X}{Y}$ \\
& Var10 & $\frac{X}{Y}$ \\
& Var11 & Text \\ \hline
& & \\ \hline
\end{tabular}
\caption{CAPTION 1}
\end{table}
\end{document}
谢谢!
答案1
另一种可能性是使用该tabularray
包并相应地设置其参数(例如,在您的情况下 rowsep = 5pt
):
\documentclass[12pt, a4paper]{report}
\usepackage[margin=20mm]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs}
\NewTableCommand\sct{\SetCell{c, m, mode=text}}
\begin{document}
\begin{table}[ht]
\centering
\begin{tblr}{colspec = {l Q[l] Q[c, $]},
row{1} = {font=\bfseries, c},
row{2} = {mode=text},
row{3-Z} = {rowsep = 5pt}
}
\SetCell[c=3]{c} Variable Conceptualizations
& & \\
\midrule[1pt]
Variable Function & Variable & Operationalization \\
\midrule
Dependent Variable & Zi,t-1 & \frac{X_{i,t-1}}{Y_{i,t-1}} \\
Independent Variable & Var1 &\sct {Text\\ Text2} \\
& Var2 &\sct {Text\\ Text2} \\
Moderator Variable & Var3 & \frac{X_{i,t}}{Y_{i,t}} \\
Control Variable & Var4 & \ln(X)_{i,t} \\
& X & \frac{X_{i,t}} {X_{i,t}} \\
& Var5 & \frac{X_{i,t}}{X_{i,t}} \\
& Var6 &\sct {Text\\ Text2} \\
& Var7 &\sct {Text\\ Text2} \\
& Var8 & \frac{X}{Y} \\
& Var9 & \frac{X}{Y} \\
& Var10 & \frac{X}{Y} \\
& Var11 &\sct {Text\\ Text2} \\
\bottomrule
\end{tblr}
\caption{CAPTION 1}
\end{table}
\end{document}
编辑:
如果您可能更喜欢在第二列中使用数学项displaystyle
,则将列规范更改为:
colspec = {l Q[l] Q[c, $$]}
或者
colspec = {l Q[l] Q[c, mode=dmath]}
结果是:
答案2
这是使用包的解决方案 cellspace
,它定义了列的所有单元格中的最小垂直间距,其说明符以字母 S 为前缀(如果加载 ,则为 C ,siunitx
或者使用包加载选项 ,则为您想要的任何字母)。我还冒昧地[column=some letter]
简化了您的代码,用 命令替换了嵌套的表格\makecell
,并用 命令代替 ,提高了生成的 .pdf 的可读性。最后,我用中的s 替换了s 命令,因为它们的上下有一些垂直间距。\dfrac
\frac
\hline
\midrule
booktabs
\documentclass[12pt, a4paper]{report}
\usepackage[margin=20mm]{geometry}
\usepackage{amsmath}
\usepackage{makecell, booktabs}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{6pt}
\setlength{\cellspacebottomlimit}{6pt}
\begin{document}
\begin{table}[]
\begin{tabular}{llSl}
\textbf{Variable Conceptualizations} \\
\midrule
Variable Function & Variable & Operationalization \\ \midrule
Dependent Variable & Z{i,t-1} & $\dfrac{X_{i,t-1}}{Y_{i,t-1}}$ \\
Independent Variable & Var1 & \makecell{Text\\ Text2} \\
& Var2 & \makecell{Text\\ Text2} \\
Moderator Variable & Var3 & $\dfrac{X_{i,t}}{Y_{i,t}}$ \\
Control Variable & Var4 & $\ln(X)_{i,t}$ \\
& X & $\dfrac{X_{i,t}} {X_{i,t}}$ \\
& Var5 & $\dfrac{X_{i,t}}{X_{i,t}}$\\
& Var6 & \makecell{Text \\ Text2} \\
& Var7 & \makecell{Text\\ Text2} \\
& Var8 & $\dfrac{X}{Y}$ \\
& Var9 & $\dfrac{X}{Y}$ \\
& Var10 & $\dfrac{X}{Y}$ \\
& Var11 & Text \\ \midrule
& & \\ \midrule
\end{tabular}
\caption{CAPTION 1}
\end{table}
\end{document}
答案3
与古典类似的{NiceTabular}
环境有一个解决此类问题的关键。nicematrix
{tabular}
cell-space-limits
\documentclass[12pt, a4paper]{report}
\usepackage[margin=20mm]{geometry}
\usepackage{nicematrix,booktabs}
\begin{document}
\begin{table}[]
\begin{NiceTabular}{@{}lll@{}}[cell-space-limits=3pt]
\textbf{Variable Conceptualizations} \\
\toprule
Variable Function & Variable & Operationalization \\
\midrule
Dependent Variable & Z{i,t-1} & $\frac{X_{i,t-1}}{Y_{i,t-1}}$ \\
Independent Variable & Var1 & \begin{tabular}[c]{@{}l@{}}Text\\ Text2\end{tabular} \\
& Var2 & \begin{tabular}[c]{@{}l@{}}Text\\ Text2\end{tabular} \\
Moderator Variable & Var3 & $\frac{X_{i,t}}{Y_{i,t}}$ \\
Control Variable & Var4 & $ln(X)_{i,t}$ \\
& X & $\frac{X_{i,t}} {X_{i,t}}$ \\
& Var5 & $\frac{X_{i,t}}{X_{i,t}}$\\
& Var6 & \begin{tabular}[c]{@{}l@{}}Text \\ Text2\end{tabular} \\
& Var7 & \begin{tabular}[c]{@{}l@{}}Text\\ Text2\end{tabular} \\
& Var8 & $\frac{X}{Y}$ \\
& Var9 & $\frac{X}{Y}$ \\
& Var10 & $\frac{X}{Y}$ \\
& Var11 & Text \\
\bottomrule
\end{NiceTabular}
\caption{CAPTION 1}
\end{table}
\end{document}