框架封裝和立柱未對準

框架封裝和立柱未對準

我嘗試使用陰影環境,如下所示:

\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

使用minipages 代替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}

在此輸入影像描述

相關內容