0

Facing the same problem described here, I noticed that when there are paragraphs inside the tcolorbox, insertion of line breaks is not so clever. Here there is unused space on the sides:

enter image description here

On the 2nd and 3rd lines, it seems like tcolorbox prefers to hyphen the words rather than breaking the lines.

The output I prefer is somthing like the following (produced by the 2nd code block in the MWE)

enter image description here

Is there anyway I can tell tcolorbox to print something closer to the 2nd image?

\documentclass{article}
\newlength\wdthA \setlength\wdthA{7.7cm}
\usepackage[fitting]{tcolorbox}
\tcbset{
  width=\wdthA,height=2.0cm, frame empty,
  valign=center, halign=center, nobeforeafter,
  size=tight,
  fit algorithm=areasize
}

\begin{document} % 1st screenshot \tcboxfit[]{ Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Sed nibh quam, ultricies vel cursus sit amet, lobortis lacinia dui.

Vivamus ut nulla quis risus auctor accumsan non eget risus. } \vskip 1cm

% 2nd screenshot \fontsize{8.0pt}{9.6pt}\selectfont \setlength{\fboxsep}{0pt} \fbox{% \begin{minipage}[m][2.0cm][c]{\dimexpr \wdthA-2\fboxrule-2\fboxsep} \centering Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Sed nibh quam, ultricies vel cursus sit amet, lobortis lacinia dui.

Vivamus ut nulla quis risus auctor accumsan non eget risus. \end{minipage} } \end{document}

tush
  • 1,115
  • Well, I don't really understand what do you mean by breaking words, but tcolorbox gives ugly output because the box does not contain enough material to fill its height with filled lines. Try for example with height=1.5cm. Maybe \tcboxfit is not suited for your task. – Udi Fogiel May 06 '23 at 16:28
  • Question edited – tush May 06 '23 at 20:06

0 Answers0