我尝试在里面放两行\fbox
,但没有成功。下面是我的代码
\documentclass{beamer}
\usepackage{vietnam}
\begin{document}
\begin{frame}
\frametitle{Exhaustive Search}
{\centering\fbox{ One billion searches per second $\Rightarrow 36 yrs \newline All this to recover only $10$ bits !}}
\end{frame}
\end{document}
答案1
A\fbox
不允许换行。但是,您有几种可能性:
在 内使用 a \parbox
(或 a minipage
)\fbox
:
\documentclass{beamer}
\usepackage{vietnam}
\begin{document}
\begin{frame}
\frametitle{Exhaustive Search}
\fbox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}{\centering One billion searches per second $\Rightarrow$ 36 yrs \\ All this to recover only $10$ bits !}}%
\end{frame}
\end{document}
在里面\fbox
,如果您希望宽度自动调整,请使用包varwidth
中的环境:varwidth
\documentclass{beamer}
\usepackage{vietnam}
\usepackage{varwidth}
\begin{document}
\begin{frame}
\centering
\fbox{\begin{varwidth}{\textwidth}
\centering
One billion searches per second $\Rightarrow$ 36 yrs \\ All this to recover only $10$ bits !
\end{varwidth}}
\end{frame}
\end{document}
或者使用以下定义的框tcolorbox
:
\documentclass{beamer}
\usepackage{vietnam}
\usepackage[most]{tcolorbox}
\tcbuselibrary{fitting}
\begin{document}
\begin{frame}
\frametitle{Exhaustive Search}
\begin{tcolorbox}[minipage,colback=white,arc=0pt,outer arc=0pt]
\centering
One billion searches per second $\Rightarrow$ 36 yrs \\ All this to recover only $10$ bits !
\end{tcolorbox}
\end{frame}
\end{document}
\node
或者使用带有密钥的TikZ align
:
\documentclass{beamer}
\usepackage{vietnam}
\usepackage{tikz}
\begin{document}
\begin{frame}
\frametitle{Exhaustive Search}
\centering
\tikz
\node[draw,align=center]
{One billion searches per second $\Rightarrow$ 36 yrs \\ All this to recover only $10$ bits !};
\end{frame}
\end{document}
或者...
答案2
如果您要插入手动换行符,您也可以构造一个tabular
:
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Exhaustive Search}
\centering
\fbox{\begin{tabular}{@{}c@{}}
One billion searches per second $\Rightarrow 36$ yrs \\
All this to recover only $10$ bits !
\end{tabular}}
\end{frame}
\end{document}
...或者使用纯粹的tabular
方法:
\documentclass{beamer}
\begin{document}
\begin{frame}
\frametitle{Exhaustive Search}
\centering
\begin{tabular}{|c|}
\hline
One billion searches per second $\Rightarrow 36$ yrs \\
All this to recover only $10$ bits ! \\
\hline
\end{tabular}
\end{frame}
\end{document}