标题后的段落不再缩进

标题后的段落不再缩进

[重写了原帖。稍后更新见下文。]

似乎我的段落由于使用

\captionof{figure}

在下面的代码中。有任何解决方法或修复建议吗?

\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}

更新

提出了两个建议;由于框不应该浮动,我尝试使用center。然而,这会导致框内文本出现奇怪的间距问题,除非将其放置在略有不同的位置:

\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

我可以证实你的发现。似乎\captionof{...}{caption text}应该封闭在某个环境中。例如

\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}

或者如果abox应该浮动,则替换centerfigure

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

在此处输入图片描述

相关内容