24

I am using the tcolorbox to provide some beautiful frames around certain parts of my document; I use the parskip to give nice spacing between paragraphs.

When I have more than one paragraph inside a tcolorbox the parskip is not obeyed, as highlighted in the screen shot below. I have searched the manual, but it seems to describe before and after skips, but not 'during'. How can this be fixed?

screenshot

Here's a complete MWE that demonstrates the problem:

% arara: pdflatex
\documentclass{article}

\usepackage{tcolorbox}
\usepackage{lipsum}
\usepackage{parskip}

\begin{document}

\begin{tcolorbox}
\lipsum[1]

\lipsum[2]
\end{tcolorbox}

\lipsum
\end{document}
  • Just in case. If you use KOMA-Script classes, you just need to add \KOMAoptions{parskip = half-} inside the tcolorbox environment. – Manuel Jan 19 '14 at 19:21
  • Don't set \parskip, it's easier. ;-) – egreg Jan 19 '14 at 20:56
  • @egreg could you elaborate? do you recommend against the parskip package? – cmhughes Jan 20 '14 at 3:20
  • I recommend against using a nonzero parskip, which is useful only for commercial letters, in my opinion. – egreg Jan 20 '14 at 7:55
24

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 3.15 Text Characteristics on page 67.

\documentclass{article}

\usepackage{tcolorbox}
\usepackage{lipsum}
\usepackage{parskip}

\begin{document}

\begin{tcolorbox}[parbox=false]
\lipsum[1]

\lipsum[2]
\end{tcolorbox}

\lipsum
\end{document}

enter image description here

  • Awesome, thanks so much :) Sorry I missed this in the documentation :) I love your package, thanks so much for all of the work that you have done :) – cmhughes Jan 20 '14 at 16:50
  • 1
    I also missed that option in the documentation; fortunately we have you here :-) – Gonzalo Medina Jan 20 '14 at 18:36
  • @GonzaloMedina My subsection title Text Characteristics may also be better chosen ... ;-) – Thomas F. Sturm Jan 21 '14 at 6:37
9

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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.