This is my code:

this is line 1\\
\hspace*{5mm}this is line 2

This is the code's output (red line is where the right side of the box should've been if it were automatically adjustable to the text size):

If I specify [hbox] option, it adjusts automatically but ignores the text's line breaks (which I need to keep).

  • Use a tabular for the content. Aug 28, 2017 at 7:37

1 Answer 1


Does tikznode option do what you want?


this is line 1\\ \hspace*{5mm}this is line 2}

enter image description here

  • 1
    @bp2017 default alignment is center (use \tcbox[tikznode]{...}) . I think you don't need to much tikznode options because it's only used for the text, the surrounding box is drawn by tcolorbox.
    – Ignasi
    Aug 28, 2017 at 17:19

You must log in to answer this question.

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