我试图提醒我的观众注意使用dcolumn
对齐环境的表格中的数字。\alert
当它在普通表格单元格中使用时有效,如下所示。
\documentclass[compress]{beamer}
\usepackage{dcolumn}
\usepackage{booktabs}
\usepackage[english]{babel}
\begin{document}
\begin{frame}{Table}
\begin{table}\begin{tabular}{l D{.}{.}{3}D{.}{.}{3}}
\toprule
& \multicolumn{2}{c}{Both} \\
\cmidrule{2-3}
{\itshape Variables } & \beta & t\text{-stat} \\
\midrule
\multicolumn{3}{l}{{\bfseries 2 Vehicles}}\\
\hspace*{1em} $\log($Current Alternative Share$)$ & -0.417^{***} & -22.1 \\
\hspace*{1em} $\log($Past Alternative Share$)$ & & \\
\midrule
$\rho^2_C$ & \multicolumn{2}{c}{\alert<2>{0.0903}} \\
\bottomrule
\end{tabular}
\end{table}
\end{frame}
\end{document}
但是,在单元格中使用时,它不起作用dcolumn
。下面的框架失败并出现错误missing \endgroup inserted
。
\begin{frame}{Table}
\begin{table}\begin{tabular}{l D{.}{.}{3}D{.}{.}{3}}
\toprule
& \multicolumn{2}{c}{Both} \\
\cmidrule{2-3}
{\itshape Variables }&
\beta & t\text{-stat} \\
\midrule
\multicolumn{3}{l}{{\bfseries 2 Vehicles}}\\
%% ALERT CELL %%
\hspace*{1em} $\log($Current Alternative Share$)$ & \alert<3>{-0.417^{***}} & -22.1 \\
%%%%%%%%%%%%%%%%
\hspace*{1em} $\log($Past Alternative Share$)$ & & \\
\midrule
$\rho^2_C$ & \multicolumn{2}{c}{\alert<2>{0.0903}} \\
\bottomrule
\end{tabular}\end{table}
\end{frame}
我可以用它警告文本,\text{\alert<n>{x}}
但随后我会失去对齐和数学格式。\text{\alert<n>{$x$}}
不起作用。
有小费吗?
答案1
D
您可以定义一个类似于包含警报规范的新列类型:
\documentclass[compress]{beamer}
\usepackage{dcolumn}
\usepackage{booktabs}
\usepackage[english]{babel}
\makeatletter
\newcolumntype{A}[4]{>{\begin{alertenv}<#4>\DC@{#1}{#2}{#3}}c<{\DC@end\end{alertenv}}}
\makeatother
\begin{document}
\begin{frame}{Table}
\begin{table}\begin{tabular}{l D{.}{.}{3}D{.}{.}{3}}
\toprule
& \multicolumn{2}{c}{Both} \\
\cmidrule{2-3}
{\itshape Variables }&
\beta & t\text{-stat} \\
\midrule
\multicolumn{3}{l}{{\bfseries 2 Vehicles}}\\
%% ALERT CELL %%
\hspace*{1em} $\log($Current Alternative Share$)$ & \multicolumn{1}{A{.}{.}{3}{3}}{-0.417^{***}} & -22.1 \\
%%%%%%%%%%%%%%%%
\hspace*{1em} $\log($Past Alternative Share$)$ & & \\
\midrule
$\rho^2_C$ & \multicolumn{2}{c}{{\alert<2>{0.0903}}} \\
\bottomrule
\end{tabular}\end{table}
\end{frame}
\end{document}
这些类型的构造在dcolumn
。
答案2
您可以使用一些重叠来伪造对齐:
\documentclass[compress]{beamer}
\usepackage{dcolumn}
\usepackage{booktabs}
\begin{document}
\begin{frame}{Table}
\begin{table}\begin{tabular}{l D{.}{.}{3}D{.}{.}{3}}
\toprule
& \multicolumn{2}{c}{Both} \\
\cmidrule{2-3}
{\itshape Variables } & \beta & t\text{-stat} \\
\midrule
\multicolumn{3}{l}{{\bfseries 2 Vehicles}}\\
\hspace*{1em} $\log($Current Alternative Share$)$ & \text{\alert<2>{$-0$\rlap{.417$^{***}$}}} & -22.1 \\
\hspace*{1em} $\log($Past Alternative Share$)$ & & \\
\midrule
$\rho^2_C$ & \multicolumn{2}{c}{\alert<2>{0.0903}} \\
\bottomrule
\end{tabular}
\end{table}
\end{frame}
\end{document}
\text
数学模式格式会关闭,因此可以使用 重新激活它$...$
。\rlap
,它提供了内容的r
遮挡lap
(左对齐的零宽度框)。