0

This is my code:

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

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).

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

1 Answer 1

2

Does tikznode option do what you want?

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[most]{tcolorbox}
\begin{document}

\tcbox[tikznode={align=left}]{%
this is line 1\\ \hspace*{5mm}this is line 2}
\end{document}

enter image description here

1
  • 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 .