結束 \DeclareCaptionFormat 並恢復為預設標題設定

結束 \DeclareCaptionFormat 並恢復為預設標題設定

我已經為演算法浮點數定義了自己的標題格式,它運作得很好:

\DeclareCaptionFormat{algor}{%
  \hrulefill\par\offinterlineskip\vskip1pt%
  \textbf{#1#2}#3\offinterlineskip\hrulefill}
\DeclareCaptionStyle{algori}{singlelinecheck=off,format=algor,labelsep=space}
\captionsetup[algorithm]{style=algori}

但是,我希望文檔中的圖形具有預設的標題設定。請建議我如何才能做到這一點。

答案1

我發現您透過以下方式定義自己的標題樣式:

\DeclareCaptionFormat{<formatname>}{<code for format>}

然後將此格式用於特定的浮動環境:

\captionsetup[<float_environment>]{singlelinecheck=off, labelsep=colon,format=<formatname>}

這裡labelsep設定為“冒號”,也可以改為“空格”等。

對於給定的問題,可以按以下方式使用此標題格式

\DeclareCaptionFormat{algor}{%
  \hrulefill\par\offinterlineskip\vskip1pt%
  \textbf{#1#2}#3\offinterlineskip\hrulefill}
\DeclareCaptionStyle{algori}{singlelinecheck=off,format=algor,labelsep=space}
\captionsetup[algorithm]{style=algori}

\DeclareCaptionFormat{figur}{%
  \begin{center}
  \textbf{#1#2}#3
  \end{center}}
\captionsetup[figure]{singlelinecheck=off,format=figur,labelsep=colon}

相關內容