I want the text in a
{tcolorbox}to exhibit the same paragraph style as the main body. As far as I know (as per the first reference) this requires using\RestoreParskip:\newcommand*{\RestoreParskip}{% \setlength{\parskip}{\currentparskip}% \setlength{\parindent}{\currentparindent}% }%where
\currentparskipand\currentparindentneeds to be initialized before the{tcolorbox}.From the documentation, this appears to be exactly what
parbox=falseis intended to do:If the key value is set to false, the normal main text behavior is restored.
However, this feature is marked as experiemntal as of 2015-10-14 with the caveat:
In some situations, this has some unwanted side effects. It is recommended that you use this experimental setting only where you really want to have this feature.
As I defintely want the same paragraph spacing inside
{tcolorbox}, it seems I should use this.Secondly, using
hyphenationfix=trueseems to be useful:Long words at the beginning of paragraphs in very narrow boxes will not be hyphenated using pdflatex. This problem is circumvented by applying the hyphenationfix option.
However, there is a warning:
Using the example text given in the documentation, one can see that parbox=false, hyphenationfix=true together don't seem to work (see 3. in the output of the MWE). I can fix this by leaving parbox=true using \RestoreParskip manually (see 4).
Results without {parskip} and with {parskip}:
Questions:
- What else is
parbox=falsedoing (besides the\RestoreParskipfunctionality) that causes it to fail withhyphenationfix=true? - What functionality am I losing by manually using
\RestoreParskip? - When will
parbox=falsefunctionality leave the experimental designation? I realize that this particluar question can only be answered by the package author, but as I have experienced the pain of having experimental features removed, it would be good to know if this is still really experimental or just that the documentation has not been updated.
Notes:
- For now, I do not require
breakable=true, but might need it in the future. In case it is relevant, comments addressing these cases separately would be useful.
References:
Code:
\documentclass{article}
\usepackage{tcolorbox}
\usepackage[textwidth=4cm]{geometry}
%\usepackage{parskip}% Needs to also work with parskip
\newlength{\currentparskip}
\newlength{\currentparindent}
\setlength{\currentparskip}{\parskip}
\setlength{\currentparindent}{\parindent}
\newcommand*{\RestoreParskip}{%
\setlength{\parskip}{\currentparskip}%
\setlength{\parindent}{\currentparindent}%
}%
\newcommand*{\Mytext}{%
Rechnungsadjunktentochter.\par
Statthaltereikonzipist.
}
\begin{document}
\begin{tcolorbox}[title={1. Default}]
\Mytext
\end{tcolorbox}
\begin{tcolorbox}[hyphenationfix, title={2. hyphenationfix}]
\Mytext
\end{tcolorbox}
\begin{tcolorbox}[hyphenationfix, parbox=false, title={3. hyphenationfix, parbox=false}]
\Mytext
\end{tcolorbox}
\setlength{\currentparskip}{\parskip}
\begin{tcolorbox}[
hyphenationfix,
before upper=\RestoreParskip\noindent,
title={4. hyphenationfix, \texttt{\string\RestoreParskip}},
]
\Mytext
\end{tcolorbox}
\end{document}


