I have a tcolorbox
environment that I use on its own, and sometimes inside a wrapfigure
. On its own, it works perfectly - paragraphs are spaced according to my document's parskip
and parindent
. However, inside wrapfigure
those settings seem to be ignored.
Here is a MWE:
% !TEX program = xelatex
\documentclass{scrbook}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{tcolorbox}
\setlength{\parskip}{3mm}
\setlength{\parindent}{0pt}
\newtcolorbox[auto counter]{sidebar}[2][]{
parbox=false, % normal paragraph spacing (unless wrapped!)
sharp corners,
colframe=black,
colback=black!15!white,
title=#2,
#1
}
\begin{document}
\begin{sidebar}{Test without wrapping}
Paragraph 1.
Paragraph 2.
\end{sidebar}
\begin{wrapfigure}{r}{0.5\linewidth}
\begin{sidebar}{Test with wrapping and no explicit parksip}
Paragraph 1.
Paragraph 2.
\end{sidebar}
\end{wrapfigure}
\begin{wrapfigure}{r}{0.5\linewidth}
\begin{sidebar}{Test with wrapping and explicit parskip}
\setlength{\parskip}{3mm}\setlength{\parindent}{0pt}Paragraph 1.
Paragraph 2.
\end{sidebar}
\end{wrapfigure}
\end{document}
Here is the output:
Is there any way I can avoid the need to explicitly specify parskip
(and parindent
) inside my wrapped tcolorbox
?
parskip
class option? Or you can always add it to the default code executed at the beginning of the boxes usingtcolorbox
's configuration, can't you? Possibly annoying, but you don't have to do it for every box - only once or once per type of box, depending on your needs, I guess. You could also just box the box, I suspect. Certainly if you boxed first, it should work. But even inside might do.