How do I control parskip within a tcolorbox?
Yes, there is a native tcolorbox
solution. The content of a tcolorbox
is processed with the typical settings of parbox
and minipage
. You can switch this kind processing by setting parbox=false
to do a mimicry of 'normal' processing.
You find this in the tcolorbox
documentation as Text Characteristics (4.18 Text Characteristics on p. 98, for current tcolorbox
version 4.22 [2019/11/15]).
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\usepackage{parskip}
\begin{document}
\begin{tcolorbox}[parbox=false]
\lipsum[1]
\lipsum[2]
\end{tcolorbox}
\lipsum
\end{document}
One option would be to use the settings from parskip
inside a new environment defined using tcolorbox
:
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\usepackage{parskip}
\newenvironment{mycolorbox}[1][]
{\if\detokenize{#1}\relax\relax
\begin{tcolorbox}
\else
\begin{tcolorbox}[#1]
\fi
\parskip=0.5\baselineskip \advance\parskip by 0pt plus 2pt
\parindent=0pt
}
{\end{tcolorbox}}
\begin{document}
\begin{mycolorbox}
\lipsum[1]
\lipsum[2]
\end{mycolorbox}
\lipsum
\end{document}