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?

1
  • 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
    Commented Nov 18, 2017 at 11:19

1 Answer 1

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}

You must log in to answer this question.

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