如何\multicolumn
与覆盖一起使用?
\multicolumn
如果有覆盖则失败前它或如果\multicolumn
使用里面一個覆蓋。
我实际上想做最后一件事。\only<2>{\multicolumn{2}{c}{three}\\}
梅威瑟:
\documentclass{beamer}
\usepackage{siunitx}
\begin{document}
\begin{frame}
\begin{tabular}{*{4}{|>{$}{c}<{$}}|}
\hline
a & b & c & d\\
\hline
1 & 2 & 3 & 4\\
\hline
%TODO following works
\multicolumn{2}{c}{one}\\
\only<2>{one\\}
%TODO following doesn't work
%\only<2>{two\\}
%\multicolumn{2}{c}{two}\\
%TODO following doesn't work
%\only<2>{\multicolumn{2}{c}{three}\\}
\end{tabular}
\end{frame}
\end{document}
答案1
据我所知,你想要类似的东西
\documentclass{beamer}
\usepackage{siunitx}
\begin{document}
\begin{frame}
\begin{tabular}{*{4}{|>{$}{c}<{$}}|}
\hline
aaa & b & c & d\\
\hline
1 & 2 & 3 & 4\\
\hline
\multicolumn{1}{l}{th}
\only<1>{\\\multicolumn{2}{l}{}}
\only<2>{\\\multicolumn{2}{l}{th}}
\end{tabular}
\end{frame}
\end{document}
或者以下内容,在这种情况下会产生相同的输出。
\documentclass{beamer}
\usepackage{siunitx}
\begin{document}
\begin{frame}
\begin{tabular}{*{4}{|>{$}{c}<{$}}|}
\hline
aaa & b & c & d\\
\hline
1 & 2 & 3 & 4\\
\hline
\multicolumn{1}{l}{th}\\
\multicolumn{2}{l}{\only<2>{th}}
\end{tabular}
\end{frame}
\end{document}
答案2
现在我得到:
\documentclass{beamer}
\usepackage{siunitx}
\newlength{\widthoffirstcolumn}
\settowidth{\widthoffirstcolumn}{%
\begin{tabular}{>{$}{c}<{$}}% %here are not | on purpose (still not the exact indent)
aaa\\
1
\end{tabular}%
}
\begin{document}
\begin{frame}
\begin{tabular}{*{4}{|>{$}{c}<{$}}|}
\hline
aaa & b & c & d\\
\hline
1 & 2 & 3 & 4\\
\hline
\multicolumn{1}{l}{th}\\ %only for testing the indent of next row
\multicolumn{1}{c}{}\only<2>{&\multicolumn{2}{l}{\hspace{-\widthoffirstcolumn}th}\\}
\end{tabular}
\end{frame}
\end{document}
是\multicolumn{1}{c}{}
没有得到垂直线
返回\hspace{-\widthoffirstcolumn}
到行首
我不确定这是否是一个很好的解决方案,但它确实有效......(行起始没有准确计算)