3

Consider the following MWE:

\documentclass{article}
\usepackage{lipsum}
\usepackage{tcolorbox}
%%% this two following packages are used in the format I have to use
\usepackage[parfill]{parskip}

\begin{document}
\lipsum[1]

\begin{tcolorbox}
     checking content
\end{tcolorbox}

\lipsum[1]
\end{document}

it compiles well, with correctly aligned boxes, but it gives a

mwe-tcbox.tex|12 warning| Overfull \hbox (30.0pt too wide) in paragraph at lines 12--12

I tried the tcbset trick adapted from this answer, but it does not work; the line

\tcbset{before app=\parfillskip0pt}

(adding [hooks] to the tcolorbox package) is silent, but does not solve the warning.

If I remove the \usepackage[parfill]{parskip} from the code all is well --- but I really can't do that, because it is in the format I have to use for this document. I can hack it with something like width=0.9\linewidth in the options of the tcolorbox, but well --- It's a hack.

I also could manage to silence the warnings using the silence package --- but again, this will also shut off real warnings.

Can I avoid the warning and still using the full textwidth for the color boxes?

1 Answer 1

2

The parfill option to the parskip package sets \parfillskip to 30pt plus 1fil, in order to avoid the final line of a paragraph to end (almost) flush with the right margin: no wonder you get an overfull line by exactly 30pt.

Redefine the parskip style to issue \parfillskip=0pt:

\documentclass[draft]{article}
\usepackage{lipsum}
\usepackage{tcolorbox}

%%% this two following packages are used in the format I have to use
\usepackage[parfill]{parskip}

\tcbset{
  parskip/.style={
    before={\par\pagebreak[0]\parindent=0pt},
    after={\parfillskip=0pt\par},
  },
}

\begin{document}

\lipsum[1]

\begin{tcolorbox}
     checking content
\end{tcolorbox}

\lipsum[1]

\the\parfillskip

\end{document}

I added \the\parfillskip to show it's correctly reset and also the draft option to prove there's no overfull box.

enter image description here

7
  • It works mot of the time (thanks!). I still have the overfull box warning if I use breakable and a break occurs into the box...
    – Rmano
    Dec 1, 2015 at 8:13
  • ...and the problem is that in the manual it is stated that "The given /tcb/before and /tcb/after values are used only before the first and after the last part of the break sequence." --- I was not able to find hooks for the breaks...
    – Rmano
    Dec 1, 2015 at 8:26
  • ...so I finally added \parfillskip=0pt plus 1fil\relax to the preamble. ;-) I am not sure about the aesthetic of the 30pt fixed thing, anyway.
    – Rmano
    Dec 1, 2015 at 8:43
  • @Rmano Just remove the parfill option, then.
    – egreg
    Dec 1, 2015 at 9:28
  • Yes, that would be the perfect thing. Unfortunately I do not control the class file... so I have to do it after-the-fact. No one will notice ;-)
    – Rmano
    Dec 1, 2015 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .