0

I end up getting to wide boxes with tcolorbox. I use the following code:

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\usepackage{xcolor}

\definecolor{blue}{RGB}{0,20,150}

\newtcbox
{\mybox}[2][]{colback=blue!5!white,colframe=blue!75!black,fonttitle=\bfseries , title=#2,#1}

\begin{document}
\mybox{Longbox}
{Loooong box box box box box box box box box box box box box box box box box box box box box box box box }

\end{document}

I end up getting this input:

enter image description here

How can I adjust the box to the content?

  • Welcome to TeX.SX! You probably don't want a tcbox, but a tcolorbox. tcboxes are just for "highlighting" and not for long breaking. – TeXnician Nov 18 '17 at 11:19
1

You are using \tcbox which is not intended for line breaks, but rather for highlighting. You should use tcolorbox instead.

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\usepackage{xcolor}

\definecolor{blue}{RGB}{0,20,150}

\newtcolorbox{mybox}[2][]{colback=blue!5!white,colframe=blue!75!black,fonttitle=\bfseries, title=#2,#1}

\begin{document}
\begin{mybox}{Longbox}
    Loooong box box box box box box box box box box box box box box box box box box box box box box box box
\end{mybox}
\end{document}

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.