\begin{table}[ht]
\caption{Using Quasi-Experimental Variation}
\begin{center}
\begin{tabular}{@{}lccc@{}}
\hline
\hline
& & Is the Good Rival in Consumption?: (Yes)
& Is the Good Rival in Consumption?: (No)
\\
\hline
Is the Good Excludable?
& (Yes)
& Private good (ice cream)
& Impure public good (TV streaming)
\\
\hline
Is the Good Excludable?
& (No)
&
Impure public good (crowded city sidewalk)
& Pure public good (national defense)
\\
\hline
\hline
\end{tabular}
\end{center}
\end{table}
比如像我用箭头演示的位置,把“好东西是否可排除”移到第三行和第四行的前面。
答案1
一些建议:
不要使用
table
和环境。在文档中使用和环境center
毫无意义,因为环境不会“浮动”(在 Latex 意义上)。table
figure
beamer
不要使用
\caption
。而是将其参数移动到 的参数\frametitle
。使用
tabularx
环境而不是tabular
环境,并允许在两个数据列中换行。合并前两列,并为标题行和第一列提供更多结构。本质上,避免重复问题
Is the Good Rival in Consumption?
和Is the Good Excludable?
加载
booktabs
包并使用其线条绘制宏来代替\hline
。
\documentclass{beamer}
\usepackage{tabularx,booktabs}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\renewcommand\tabularxcolumn[2]{m{#1}}
\begin{document}
\begin{frame}[t]
\frametitle{Using Quasi-Experimental Variation}
\setlength{\tabcolsep}{4pt} % default: 6pt
\begin{tabularx}{\textwidth}{@{} cCC @{}}
\toprule
Is the Good Excludable?
& \multicolumn{2}{c@{}}{Is the Good Rival in Consumption?}\\
\cmidrule(l){2-3}
& Yes & No \\
\midrule
Yes
& Private good (ice~cream) & Impure public good (TV streaming) \\
\addlinespace
No
& Impure public good (crowded city sidewalk) & Pure public good (national defense) \\
\bottomrule
\end{tabularx}
\end{frame}
\end{document}
附录以解决 OP 的后续请求。这里有两个备选解决方案,它们都将字符串“Is the Good Excludable”单独放在最左侧的一列中,同时允许在该列中换行。第一个替代方案使用全宽规则,第二个替代方案使用仅跨越第 3 列和第 4 列的规则。(非常感谢 @vonbrand 留下建议第二个替代方案的评论!)
\documentclass{beamer}
\usepackage{tabularx,booktabs,multirow}
% define a centered, variable-width version of the 'X' column type:
\newcolumntype{C}[1]{>{\centering\arraybackslash%
\hsize=#1\hsize\linewidth=\hsize}X}
\renewcommand\tabularxcolumn[1]{m{#1}}
\newlength\mylen
\settowidth\mylen{Excludable?} % measure width of first col.
\begin{document}
\begin{frame}
\frametitle{Using Quasi-Experimental Variation}
%%% First alternative solution: rules span full width of the text block
\begin{tabularx}{\textwidth}{@{}
>{\raggedright}p{\mylen} c C{1.1} C{0.9} @{}}
\toprule
& & \multicolumn{2}{c@{}}{Is the Good Rival in Consumption?}\\
\cmidrule(l){3-4}
& & Yes & No \\
\midrule
\multirow{3}{=}{Is the Good Excludable?}
& Yes
& Private good (ice~cream)
& Impure public good (TV streaming) \\ \addlinespace
& No
& Impure public good (crowded city sidewalk)
& Pure public good (national defense) \\
\bottomrule
\end{tabularx}
\bigskip\medskip
%%% Second alternative solution: rules span only columns 3 and 4
\begin{tabularx}{\textwidth}{@{}
>{\raggedright}p{\mylen} c C{1.1} C{0.9} @{}}
\cmidrule[\heavyrulewidth](l){3-4}
& & \multicolumn{2}{c@{}}{Is the Good Rival in Consumption?}\\
\addlinespace %
& & Yes & No \\
\cmidrule[\lightrulewidth](l){3-4}
\multirow{3}{=}{Is the Good Excludable?}
& Yes
& Private good (ice~cream)
& Impure public good (TV streaming) \\ \addlinespace
& No
& Impure public good (crowded city sidewalk)
& Pure public good (national defense) \\
\cmidrule[\heavyrulewidth](l){3-4}
\end{tabularx}
\end{frame}
\end{document}