![框架封裝和立柱未對準](https://rvso.com/image/286356/%E6%A1%86%E6%9E%B6%E5%B0%81%E8%A3%9D%E5%92%8C%E7%AB%8B%E6%9F%B1%E6%9C%AA%E5%B0%8D%E6%BA%96.png)
我嘗試使用陰影環境,如下所示:
\documentclass[11pt]{beamer}
\usepackage{xcolor}
\usepackage{framed}
\definecolor{shadecolor}{rgb}{1,0.8,0.3}
\begin{document}
\begin{frame}
\begin{columns}[t, totalwidth=\linewidth]
\begin{column}{0.5\linewidth}
\begin{shaded}
Foo
\end{shaded}
\end{column}
\begin{column}{0.5\linewidth}
Foo
\end{column}
\end{columns}
\end{frame}
\end{document}
我得到以下輸出(儘管奇怪的是,沒有 Overfull hbox 錯誤):
如果沒有第一個“foo”周圍的陰影環境,我得到
我是否需要放棄陰影環境,或者我做錯了什麼?
答案1
使用minipage
s 代替columns
環境可以解決問題。我建議你使用mdframed
或者tcolorbox
代替framed
;以前的軟體包更加通用且易於自訂:
\documentclass[11pt]{beamer}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tcolorbox}
\usepackage{framed}
\definecolor{shadecolor}{rgb}{1,0.8,0.3}
% for mdframed
\newmdenv[
hidealllines=true,
backgroundcolor=shadecolor,
userdefinedwidth=.6\linewidth
]{mybox}
% for tcolorbox
\newtcolorbox{mytbox}[1][]{
colback=shadecolor,
colframe=shadecolor,
arc=0pt,
outer arc=0pt,
#1
}
\begin{document}
\begin{frame}
With \texttt{framed} package:
\begin{minipage}{0.5\linewidth}
\begin{shaded}
Foo
\end{shaded}
\end{minipage}%
\begin{minipage}{0.5\linewidth}
Foo
\end{minipage}\vfill
With \texttt{mdframed} package:
\begin{minipage}{0.5\linewidth}
\begin{mybox}[userdefinedwidth=.95\linewidth]
Foo
\end{mybox}
\end{minipage}%
\begin{minipage}{0.5\linewidth}
Foo
\end{minipage}\vfill
With \texttt{tcolorbox} package:
\begin{minipage}{0.5\linewidth}
\begin{mytbox}[width=.95\linewidth]
Foo
\end{mytbox}
\end{minipage}%
\begin{minipage}{0.5\linewidth}
Foo
\end{minipage}
\end{frame}
\end{document}