一个段落后面跟着 tcolorbox 环境中的枚举

一个段落后面跟着 tcolorbox 环境中的枚举

在此处输入图片描述

如果我输入一个段落然后枚举,则项目和段落之间没有空格。如果有两个段落然后枚举,则有两个段落。我希望当我只输入一个段落时也有空格。我使用了 [parbox=false],因为我希望框内的 parskip 与外面的相同。

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\setlength{\parskip}{1em}
\usepackage{tcolorbox}


\begin{document}

\begin{tcolorbox}[parbox=false,width=\textwidth]
The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph.

\begin{enumerate}
\item
item item item item item item item item item
\item
item item item item item item item item item
\end{enumerate}
\end{tcolorbox}

\begin{tcolorbox}[parbox=false,width=\textwidth]
The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph.

The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph.

\begin{enumerate}
\item
item item item item item item item item item
\item
item item item item item item item item item
\end{enumerate}
\end{tcolorbox}

\end{document}

答案1

\parskip我建议用特殊风格重复设置parskipsetting,而不是使用parbox=false

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\setlength{\parskip}{1em}
\usepackage{tcolorbox}

\tcbset{parskipsetting/.style={before upper={\parskip=1em}}}


\begin{document}
\begin{tcolorbox}[parskipsetting]
\the\parskip

The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph.

\begin{enumerate}
\item
item item item item item item item item item
\item
item item item item item item item item item
\end{enumerate}
\end{tcolorbox}

\begin{tcolorbox}[parskipsetting]
\the\parskip

The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph.

The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph. The paragraph.

\begin{enumerate}
\item
item item item item item item item item item
\item
item item item item item item item item item
\end{enumerate}
\end{tcolorbox}

\end{document}

在此处输入图片描述

相关内容