標題後的段落不再縮排

標題後的段落不再縮排

[重寫了原來的貼文。為了以後更新見下文。

由於使用了,我的段落似乎停止縮進

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

在此輸入影像描述

相關內容