# Squeeze tcolorbox to text width

I want to keep the format of my tcb exactly as it is except I would like to squeeze it horizontally to the text width (plus an aesthetic but minimal margin.) The box should stay centered but the white space (gray actually) inside the box should be reduced.

\documentclass[preprint,nofootinbib]{revtex4-2}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}

\begin{document}

\lipsum[1]\newline

\begin{tcolorbox}[breakable]
$~$ \newline
\noindent \textsf{ {\large Matthew 6:9-13 (NIV)} }

\noindent \textsf{9}This, then, is how you should pray:

\kern 0.03emOur Father in [\textit{the future}],

$\qquad$[\textit{in the present}] as it is in [\textit{the future}].

\textsf{11}     Give us today our daily bread.

\textsf{12}     And forgive us our debts,

$\qquad$as we also have forgiven our debtors.

\textsf{13}     And lead us not into temptation,

$\qquad$but deliver us from the evil one.'
$~$ \newline
\end{tcolorbox}

\end{document}

• What about {\centering \begin{tcolorbox}[breakable,width=0.55\textwidth] in combination with a } after \end{tcolorbox}? Mar 10, 2021 at 21:28

You can collect the contents and measure it with the help of varwidth that makes a tight bounding box. Then the text is typeset again to allow for breaking across pages.

\documentclass{article}
\usepackage{lipsum}

\usepackage{varwidth}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}

\newsavebox{\myboxbox}
\NewDocumentEnvironment{mybox}{+b}% find a better name
{%
\centering
\setlength{\parindent}{0pt}%
% measure the text width
\sbox{\myboxbox}{\begin{varwidth}{\columnwidth}#1\end{varwidth}}%
\begin{tcolorbox}[
breakable,
width=\dimexpr\wd\myboxbox+8mm,
top=8mm,
bottom=8mm,
]
#1
\end{tcolorbox}%
}{}
% 4mm is the default for left and right margins inside a tcolorbox

\begin{document}

\lipsum[1]

\begin{mybox}
\textsf{\large Matthew 6:9-13 (NIV)} \\[1ex]
\textsf{9} This, then, is how you should pray: \\
\kern 0.03emOur Father in [\textit{the future}], \\
Instead of $~$\newline it's better to act on the parameters top and bottom. And, instead of all those blank lines, \\ seems handier.