I am not sure about certain items in your example, so I changed some of it to be able to target the lack of vertical spacing at the first enumerate
. This code example shows the correct vertical spacing inside and outside the tcolorbox
:
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[skip=1ex]{caption}
\usepackage[most]{tcolorbox}
\newtcolorbox{abox}[1][]{enhanced, fonttitle=\bfseries,
nofloat, % added to prevent tcolorbox becoming a float
attach boxed title to top center={yshift=-2mm},
title=#1}
\usepackage{enumitem} % added to use the resume option
\usepackage{lipsum} % just to insert some random text
\begin{document}
\lipsum[1][1-2]
\begin{abox}[title]
top text
\begin{enumerate}[leftmargin=*]
\item testttttt
\end{enumerate}
testttttt
\begin{enumerate}[resume*]%\setcounter{enumi}{1}
\item testttttt
\end{enumerate}
testttttt
\begin{enumerate}[resume*]%\setcounter{enumi}{2}
\item testttttt
\end{enumerate}
testttttt
\end{abox}
\captionof{figure}{caption}
\medskip
\lipsum[2][1-2]
\end{document}
I made the following changes:
- added the
enumitem
package, so you can use the resume*
option in subsequent enumerate
occurrences without having to reset the counter
- changed the number of variables in your
abox
to just one for the title. You don't need to define a variable for the content of the box
- removed all superfluous brackets as a result of that change
- added the option
nofloat
to your box definition as you clearly stated you don't want the box to be a floating object
- removed the
center
environment as that is no longer required to prevent floating
- since the caption is following the box, but not attached to it, you need to add some vertical space to increase the distance between caption and next paragraph. You can't use the option
before / after skip balanced
from tcolorbox
(see pages 86-88 in the manual)
The result of these changes:

As to why the vertical spacing is altered at the first enumerate
when embedded in a center
environment, I have no clue.
Edited to include options in comments
\documentclass[english]{article}
%\usepackage[T1]{fontenc}
%\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[skip=1ex]{caption}
\usepackage[most]{tcolorbox}
\newtcolorbox{abox}[1][]{enhanced, fonttitle=\bfseries,
nofloat, % added to prevent tcolorbox becoming a float
attach boxed title to top center={yshift=-2mm},
title=#1}
\usepackage{enumitem} % added to use the resume option
\usepackage{lipsum} % just to insert some random text
\begin{document}
\lipsum[1][1-2]
\begin{abox}[title]
caption inside a parbox
\begin{enumerate}[leftmargin=*]
\item testttttt
\end{enumerate}
testttttt
\begin{enumerate}[resume*]%\setcounter{enumi}{1}
\item testttttt
\end{enumerate}
testttttt
\begin{enumerate}[resume*]%\setcounter{enumi}{2}
\item testttttt
\end{enumerate}
testttttt
\end{abox}
\noindent \parbox{\linewidth}{\captionof{figure}{caption}}
\medskip
\lipsum[2][1-2]
\noindent \begin{minipage}{\linewidth}
\begin{abox}[title]
boxed inside a minipage
\begin{enumerate}[leftmargin=*]
\item testttttt
\end{enumerate}
testttttt
\begin{enumerate}[resume*]%\setcounter{enumi}{1}
\item testttttt
\end{enumerate}
testttttt
\begin{enumerate}[resume*]%\setcounter{enumi}{2}
\item testttttt
\end{enumerate}
testttttt
\end{abox}
\captionof{figure}{caption}
\end{minipage}
\medskip
\lipsum[4][4-8]
\end{document}
This code example shows the correct indention after the use of \captionof
:

center
vs\centering
)