I'm trying to implement a kind of chat inside my document using tcolorbox
. But I either can set the width dynamically or allow a pagebreak inside a "chat-message".
\documentclass[11pt, a4paper]{article}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{blindtext}
\tcbset{breakable, width=.8\linewidth, tcbox width=auto limited, size=title, arc=2mm, boxrule=.5pt, boxsep=1mm}
%page break possible
\newcommand{\coach}[1]{\begin{tcolorbox}[colback=yellow, sharp corners=northwest]#1\end{tcolorbox}}
%dynamic width
\newcommand{\klient}[1]{\tcbox[colback=green, sharp corners=southeast, flush right]{#1}}
\begin{document}
\blindtext[2]
\coach{Hello World}
\klient{Hello World}
\coach{\blindtext[2]}
\klient{\blindtext[3]}
\end{document}
Does anyone know how to meet both requirements?
Thank you in advance.
auto limited
is an option for\tcbox
only, as I understand the documentation, whereasbreakable
is a setting applicable to\tcolorbox
es. These rely on different underlying structures, I think, so what's possible for one is not always possible for the other.\ifdim
statement, comparing the textlength. This meets my requirements.