1

[Rewritten the original post. For the later update see below.]

It seems that my paragraphs stop indenting due to the use of

\captionof{figure}

in the code below. Any suggestions for a workaround or fix?

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}

\makeatletter

\usepackage{tcolorbox} \tcbuselibrary{most} \usepackage{caption}

\makeatother

\begin{document} \newtcolorbox{abox}[2][]{float, fonttitle=\bfseries,enhanced, attach boxed title to top center={yshift=-2mm}, title={#2},#1}

\begin{abox}{title} {body} \end{abox} \captionof{figure}{caption}

test test test test test test test test test test test test test test test test test test test test test

test test test test test test

test test test test test test test test test test test test test test test test test test test test test test test test \end{document}

Update:

Two suggestions were made; as the box shouldn't float I tried using center. This however causes strange spacing issues of text within the box, unless it is placed slightly differently:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[skip=1ex]{caption}

\usepackage{tcolorbox} \tcbuselibrary{most} \newtcolorbox{abox}[2][]{enhanced, fonttitle=\bfseries, attach boxed title to top center={yshift=-2mm}, title={#2},#1}

\usepackage[unicode=true, pdfusetitle, bookmarks=true, bookmarksnumbered=false, bookmarksopen=false, breaklinks=false, pdfborder={0 0 1}, backref=false, colorlinks=false]{hyperref}

\begin{document}

\begin{abox}{title} {

{\begin{enumerate} \item testttttt \end{enumerate} testttttt \begin{enumerate}\setcounter{enumi}{1} \item testttttt \end{enumerate} testttttt \begin{enumerate}\setcounter{enumi}{2} \item testttttt \end{enumerate}}

} \end{abox} \begin{center} \captionof{figure}{caption} \end{center}

\end{document}

1 Answers1

2

I can confirm your findings. It seems that \captionof{...}{caption text} should be enclosed in some environment. For example

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[skip=1ex]{caption}

\usepackage{tcolorbox} \tcbuselibrary{most} \newtcolorbox{abox}[2][]{enhanced, fonttitle=\bfseries, attach boxed title to top center={yshift=-2mm}, title={#2},#1}

\usepackage[unicode=true, pdfusetitle, bookmarks=true, bookmarksnumbered=false, bookmarksopen=false, breaklinks=false, pdfborder={0 0 1}, backref=false, colorlinks=false]{hyperref}

\begin{document}

\begin{center} \begin{abox}{title} {body} \end{abox} \captionof{figure}{caption} \end{center}

test test test test test test test test test test test test test test test test test test test test test

test test test test test test

test test test test test test test test test test test test test test test test test test test test test test test test \end{document}

or if abox should float, than replace center with figure:

\begin{figure}[ht]
\begin{abox}{title}
{body}
\end{abox}
\caption{caption}
\end{figure}

enter image description here

Zarko
  • 296,517
  • If figure is used, ordinary \caption will work. (Also, you mean center, not canter.) – barbara beeton Mar 17 '23 at 02:52
  • @barbarabeeton, oh apparently I woke up to early in wasn't be careful enough :-). Spelling tipo is now corrected, regarding caption: in example with figure it is used standard \caption, so what I should do about this? – Zarko Mar 17 '23 at 03:00
  • Thanks very much. The box should not float so I tried using center but this causes spacing issues that I do not know how to resolve; see the updated post for an example... – user8463 Mar 17 '23 at 04:33
  • @user8463, what spacing issues? Testing your edited question gives to my opinion a nice result. – Zarko Mar 17 '23 at 04:50
  • 1
    @user8463 -- If the center environment adds too much space, you can instead wrap the box in \begingroup \centering ... \endgroup and adjust the spacing yourself. – barbara beeton Mar 17 '23 at 04:54
  • I think I had already solved it by the time you (Zarko) copy-pasted the code: I moved the \begin{center} part to start just above the \captionof, as it does in the edited version of the opening post. If you move it back to where you originally placed it, it gives rather strange spacing within the box (looks like a bug I would say) – user8463 Mar 17 '23 at 05:06