![在表格的最后一列换行以适合幻灯片](https://linux22.com/image/397786/%E5%9C%A8%E8%A1%A8%E6%A0%BC%E7%9A%84%E6%9C%80%E5%90%8E%E4%B8%80%E5%88%97%E6%8D%A2%E8%A1%8C%E4%BB%A5%E9%80%82%E5%90%88%E5%B9%BB%E7%81%AF%E7%89%87.png)
我的演示文稿中有下表:
\documentclass[11pt]{beamer}
\setbeamertemplate{headline}{}
\AtBeginSection[]
{
\begin{frame}<beamer>
\tableofcontents[currentsection]
\end{frame}
}
\begin{document}
\begin{frame}
\begin{tabular}
{|| c | c | c||}
\hline
\hline Construct & Formal formulation & Practical formulation \\
\hline
\hline Control & $\phi: H \times \mathcal{T} \to \mathbb{Z}$ & $\langle h_0, \ldots, h_k \rangle \equiv \langle \ldots h_{i,\tau} \ldots \rangle$ \\
\hline Parametrized values & $\psi: \Phi \to \mathbb{Z}$ & Terms of expression language implemented as DAGs. \\
\hline State & $\sigma: L \to \Psi$ & Through derivation, state is read and updated according to the synthesis semantics \\
\hline Set of controls & $\Phi$ & Constraints on the control values \\
\hline
\end{tabular}
\end{frame}
\end{document}
问题是最后一列超出了表格的右边距。我尝试了网站上的几种解决方案,但都没有奏效?
答案1
以下其中一个怎么样:
\documentclass[11pt]{beamer}
\usepackage{tabularx}
\usepackage{booktabs} % Only needed for the third example.
\setbeamertemplate{headline}{}
\AtBeginSection[]
{
\begin{frame}<beamer>
\tableofcontents[currentsection]
\end{frame}
}
\begin{document}
\begin{frame}
\begin{tabularx}{\textwidth}{|| c | c | >{\centering\arraybackslash}X||}
\hline
\hline Construct & Formal formulation & Practical formulation \\
\hline
\hline Control & $\phi: H \times \mathcal{T} \to \mathbb{Z}$ & $\langle h_0, \ldots, h_k \rangle \equiv \langle \ldots h_{i,\tau} \ldots \rangle$ \\
\hline Parametrized values & $\psi: \Phi \to \mathbb{Z}$ & Terms of expression language implemented as DAGs. \\
\hline State & $\sigma: L \to \Psi$ & Through derivation, state is read and updated according to the synthesis semantics \\
\hline Set of controls & $\Phi$ & Constraints on the control values \\
\hline
\end{tabularx}
\end{frame}
\begin{frame}
\begin{tabularx}{\textwidth}{|| p{2.1cm} | p{2.5cm} | >{\centering\arraybackslash}X||}
\hline
\hline Construct & Formal \newline formulation & Practical formulation \\
\hline
\hline Control & $\phi: H \times \mathcal{T} \to \mathbb{Z}$ & $\langle h_0, \ldots, h_k \rangle \equiv \langle \ldots h_{i,\tau} \ldots \rangle$ \\
\hline Parametrized values & $\psi: \Phi \to \mathbb{Z}$ & Terms of expression language implemented as DAGs. \\
\hline State & $\sigma: L \to \Psi$ & Through derivation, state is read and updated according to the synthesis semantics \\
\hline Set of \newline controls & $\Phi$ & Constraints on the control values \\
\hline
\end{tabularx}
\end{frame}
\begin{frame}
\begin{tabularx}{\textwidth}{ p{2.1cm} p{2.5cm} X}
\toprule
Construct & Formal \newline formulation & Practical formulation \\
\midrule
Control & $\phi: H \times \mathcal{T} \to \mathbb{Z}$ & $\langle h_0, \ldots, h_k \rangle \equiv \langle \ldots h_{i,\tau} \ldots \rangle$ \\ \addlinespace
Parametrized values & $\psi: \Phi \to \mathbb{Z}$ & Terms of expression language implemented as DAGs. \\ \addlinespace
State & $\sigma: L \to \Psi$ & Through derivation, state is read and updated according to the synthesis semantics \\ \addlinespace
Set of \newline controls & $\Phi$ & Constraints on the control values \\
\bottomrule
\end{tabularx}
\end{frame}
\end{document}