![フレーム付きパッケージと柱の位置ずれ](https://rvso.com/image/286356/%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E4%BB%98%E3%81%8D%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%81%A8%E6%9F%B1%E3%81%AE%E4%BD%8D%E7%BD%AE%E3%81%9A%E3%82%8C.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}