![如何正确使用表格](https://linux22.com/image/290602/%E5%A6%82%E4%BD%95%E6%AD%A3%E7%A1%AE%E4%BD%BF%E7%94%A8%E8%A1%A8%E6%A0%BC.png)
如何使用表格绘制表格
\documentclass{beamer}
\begin{document}
\begin{frame}{Cs}
\centering
\begin{table}
\centering
\caption{C}
\begin{tabular}{|l|l|}
\hline
u & i\\
\hline
~58Ko & ~1Mo.\\
\hline
DqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsd. & FDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsdDqsdqsdqsdqsd.
\end{tabular}
\end{table}
\end{frame}
\end{document}
使用这个,我得到了一个溢出框架的大表。请问如何修复这个问题?
答案1
、l
或列类型不允许文本换行;如果要文本换行,则需要使用列类型r
:c
p{<length>}
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Test frame}
\begin{table}
\centering
\caption{A test table}
\begin{tabular}{|p{5cm}|p{5cm}|}
\hline
u & i \\
\hline
~58Ko & ~1Mo.\\
\hline
text text text text text text text text text text text text text text text text text
&
text text text text text text text text text text text text text text text text text \\
\hline
\end{tabular}
\end{table}
\end{frame}
\end{document}
同一张表使用booktabs
(特别是没有垂直规则):
\documentclass{beamer}
\usepackage{booktabs}
\begin{document}
\begin{frame}
\frametitle{Test frame}
\begin{table}
\centering
\caption{A test table}
\begin{tabular}{p{5cm}p{5cm}}
\toprule
u & i \\
\midrule
~58Ko & ~1Mo.\\
text text text text text text text text text text text text text text text text text
&
text text text text text text text text text text text text text text text text text \\
\bottomrule
\end{tabular}
\end{table}
\end{frame}
\end{document}