更新

更新

我可以在周围添加边框\lrboxbeamer

我有一个minipage里面lrbox

我知道我可以使用\fbox

更新

抱歉造成混淆。我需要在数据块周围加一个边框,它位于 内,而lrbox又位于 内resizebox。我需要边框lrbox,因为我无法verbatim直接在 内使用resizebox

这是我的代码:

\documentclass{beamer}

\begin{document}

\newsavebox\myint

\begin{lrbox}{\myint}
    \begin{minipage}{0.8\textwidth}

    \begin{verbatim}
class int(object)
 |  int(x[, base]) -> integer
 |  
 |  Convert a string or number to an integer, if possible.  A floating point
 |  argument will be truncated towards zero (this does not include a string
 |  representation of a floating point number!)  When converting a string, use
 |  the optional base.  It is an error to supply a base when converting a
 |  non-string.  If base is zero, the proper base is guessed based on the
 |  string content.  If the argument is outside the integer range a
 |  long object will be returned instead.
    \end{verbatim}
    \end{minipage}
\end{lrbox}

\begin{frame}[fragile]{Object}
    \begin{center} 
        \resizebox{0.4\textwidth}{0.2\textheight}{\usebox\myint}
    \end{center}
\end{frame}

\end{document}

答案1

不确定为什么需要lrbox投影仪(也许你可以解释一下你想要达到什么效果),但下面的代码可以帮助你入门:

\documentclass{beamer}
\newsavebox{\mybox}

\begin{document}
\begin{frame}
% First set the contents of the lrbox
\begin{lrbox}{\mybox}
  \begin{minipage}{8em}
    This is a test.
    \begin{itemize}
      \item Foo
      \item Bar
    \end{itemize}
  \end{minipage}
\end{lrbox}

% Now typeset it inside a fbox
\fbox{\usebox\mybox}
\end{frame}
\end{document}

结果:

结果

更新

由于的目的lrbox是包含逐字代码,我建议使用可以框架代码的包fancyvrblistings(除其他外)。此外,您的代码行太长,迫使您重新缩放框。我认为最好减小列表的字体大小(fancyvrb 也可以这样做),或者减少行的长度。例如:

\documentclass{beamer}
\usepackage{fancyvrb}

\begin{document}
\begin{frame}[fragile]{Object}
    \begin{center}
      \begin{Verbatim}[frame=single, fontsize=\fontsize{7pt}{8pt}\selectfont]
class int(object)
 |  int(x[, base]) -> integer
 |
 |  Convert a string or number to an integer, if possible.  A floating point
 |  argument will be truncated towards zero (this does not include a string
 |  representation of a floating point number!)  When converting a string, use
 |  the optional base.  It is an error to supply a base when converting a
 |  non-string.  If base is zero, the proper base is guessed based on the
 |  string content.  If the argument is outside the integer range a
 |  long object will be returned instead.
    \end{Verbatim}
    \end{center}
\end{frame}
\end{document}

生成:

结果

相关内容