KoMaScript 版本 3.14 的重要更新

KoMaScript 版本 3.14 的重要更新

我發現了一些人們想要的帖子和問題消除垂直間距會自動添加到圖形列表中,但我的問題(完全)相反:

我使用scrartcl帶有節的文檔類別作為最高級別的分隔符號。在我的圖表清單中,不同部分的圖表之間沒有分隔。

如何加入這樣的視覺分隔?

請參閱以下最小工作範例和下面的輸出:

\documentclass[11pt,a4paper]{scrartcl}

\usepackage{amsmath}

\numberwithin{figure}{section}

\begin{document}

\listoffigures

\section{Section}

\begin{figure}[ht]\caption{Figure}\end{figure}
\begin{figure}[ht]\caption{Figure}\end{figure}

\section{Section}

\begin{figure}[ht]\caption{Figure}\end{figure}

\end{document}

氣象站的輸出

答案1

您需要修補該\@startsection命令;修補\section也是可能的,但它也會為\section*.沒什麼大不了的,但如果可以避免的話就更好了。

\documentclass[11pt,a4paper]{scrartcl}

\usepackage{amsmath}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@startsection}
  {\@dblarg}
  {\artemis@space@loft{#2}\@dblarg}
  {}{}
\newcommand{\artemis@space@loft}[1]{%
  \ifnum#1=\sectionnumdepth
    \doforeachtocfile[float]{%
      \addtocontents{\@currext}{\protect\addvspace{\@sectionlistsgap}}%
    }%
  \fi
}
\newcommand{\@sectionlistsgap}{5pt} % <-- change here the desired gap
\makeatother

\numberwithin{figure}{section}

\begin{document}

\listoffigures

\section{Section}

\begin{figure}[ht]\caption{Figure}\end{figure}
\begin{figure}[ht]\caption{Figure}\end{figure}

\section{Section}

\subsection{SUB}

\begin{figure}[ht]\caption{Figure}\end{figure}

\end{document}

說明:僅當我們有without\@dblarg時才執行;因此,在 TeX 執行之前,我們添加,在和文件中添加垂直空間註釋。這與類別的做法相同(那裡使用 10pt,在文章中較小的空間似乎更合適)。它使用了建議的技術\section*\artemis@space@loft.lof.lotbook\chapter約翰內斯_B利用 Koma-Script 的一項功能;這樣,新定義的浮點類型也將得到相同的處理。

參數#2to\@startsection是節級別,因此我們檢查它是否與 相同\sectionnumdepth。因為應該在 的正文中article使用\@ne而不是.\sectionnumdepth\artemis@space@loft

我添加的目的\subsection是為了檢查是否僅為部分添加了間距(確實如此)。

在此輸入影像描述

KoMaScript 版本 3.14 的重要更新

當安裝了新發布的 3.14 版 KoMaScript 類別和套件後,上述修補程式將不再運作。

對於這個版本,必須進行更改

\patchcmd{\@startsection}
  {\@dblarg}
  {\artemis@space@loft{#2}\@dblarg}
  {}{}

進入

\patchcmd{\scr@startsection}
  {\scr@section@dblarg}
  {\artemis@space@loft{#2}\scr@section@dblarg}
  {}{}

感謝 Johannes_B 這麼早就注意到了(新版本於 2014 年 12 月 8 日在 TeX Live 上傳)。

如果當其中一方尚未更新 KoMaScript 時,兩個修補程式對於合作工作都是必要的,那麼

\makeatletter
\ifdefined\scr@startsection
  \patchcmd{\scr@startsection}
    {\scr@section@dblarg}
    {\artemis@space@loft{#2}\scr@section@dblarg}
    {}{}
\else
  \patchcmd{\@startsection}
    {\@dblarg}
    {\artemis@space@loft{#2}\@dblarg}
    {}{}
\fi
\newcommand{\artemis@space@loft}[1]{%
...

應該做。

相關內容