
새로운 환경은 varwidth 및 tikz를 사용하여 정의되어 그 안에 있는 콘텐츠와 동일한 너비의 블록을 얻습니다. 항목화가 포함되지 않는 한 잘 작동합니다. 여기에는 MWE가 제공됩니다.
\documentclass[]{beamer}
\usepackage{tikz}
\usepackage{varwidth}
\tikzstyle{example-box} = [fill=yellow, rectangle]
\newenvironment{autowidthblock}{
\begin{tikzpicture}
\node [example-box] (box)
\bgroup
\begin{varwidth}{\linewidth}
}{
\end{varwidth}
\egroup;
\end{tikzpicture}
}
\begin{document}
\begin{frame}
\begin{autowidthblock}
With normal sentences, the width is rightly fit
\end{autowidthblock}
\begin{autowidthblock}
\begin{itemize}
\item With itemize environment,
\item The width is not auto-set
\item Instead spans the entire textwidth
\end{itemize}
\end{autowidthblock}
\end{frame}
\end{document}