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}
5
  • 1
    your example makes three paragraphs all indented, add more text so you see the indent Mar 17 at 1:06
  • Oops you're right! Give me a few minutes whilst I add more code to see if I can find the issue...
    – user8463
    Mar 17 at 1:09
  • Is it possible you have no blank lines between \end{abox} and the following paragraph? Mar 17 at 1:53
  • Adding a blank line there doesn't seem to fix it, as far as I can tell.
    – user8463
    Mar 17 at 2:06
  • 1
    Since your original question is already solved (with accepted answer), I suggest that for new problem you ask new question. Vertical distances of caption is very different problem.
    – Zarko
    Mar 17 at 7:27

1 Answer 1

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

6
  • If figure is used, ordinary \caption will work. (Also, you mean center, not canter.) Mar 17 at 2: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 at 3: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 at 4:33
  • @user8463, what spacing issues? Testing your edited question gives to my opinion a nice result.
    – Zarko
    Mar 17 at 4: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. Mar 17 at 4:54

You must log in to answer this question.

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