\tcbset behaves differently in preamble and main body

By default tcolorbox uses the autoparskip. This option sets at the begin of the document the before and after keys to values sensible in dependance of the current value of \parskip.

If you are changing after in the preamble you are disabling autoparskip. In this case you have to set before yourself.

\documentclass[a4paper,10pt]{scrartcl}

\usepackage{tcolorbox}
\tcbset{before={\par\pagebreak[0]\smallskip\parindent=0pt},after={\par\noindent}}

\begin{document}


Before the box.
\begin{tcolorbox}
  The box.
\end{tcolorbox}
After the box.

\end{document}

In the preamble, use \AtBeginDocument{\tcbset{after={\par\noindent}}}.

\documentclass[a4paper,10pt]{scrartcl}

\usepackage{tcolorbox}
\AtBeginDocument{\tcbset{after={\par\noindent}}}

\begin{document}
%\tcbset{after={\par\noindent}}

Before the box.
\begin{tcolorbox}
  The box.
\end{tcolorbox}
After the box.

\end{document}

enter image description here

Tags:

Tcolorbox