Itemize 環境的自動寬度框

Itemize 環境的自動寬度框

使用 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}

在此輸入影像描述 有人可以建議一種方法來使寬度自動用於逐項/枚舉嗎?提前致謝。

相關內容