KOMA 腳本清單和 LOF 標題下方的空間不相等

KOMA 腳本清單和 LOF 標題下方的空間不相等

我觀察到 scrbook 類別 (xelatex) 和套件中的清單清單出現了一些意外行為listings。 LOF 和清單清單的章節標題之間的間距以及每個清單的第一個條目之間的間距不相同。即使沒有像 MWE 那樣自訂章節標題的外觀,清單包也會產生更大的差距。有人知道問題可能是什麼以及如何解決嗎?謝謝!

微量元素:

\documentclass[
    10pt,
    oneside,
    listof=totoc,
    bibliography=totoc,
]{scrbook}

\usepackage{calc}
\usepackage{graphicx}
\usepackage{listings}

\setkomafont{chapter}{\Large\bfseries\MakeUppercase}
\renewcommand*{\chapterheadstartvskip}{\vspace*{-\topskip+2pt}}

\begin{document}
\listoffigures
\listoftables
\lstlistoflistings
\chapter{A Chapter}
\begin{figure}
    \centering\includegraphics[width=0.5\linewidth]{example-image}
    \caption{First figure}
\end{figure}
\begin{table}
    \caption{First table}
    \centering
    \begin{tabular}[width=0.5\linewidth]{ccc}
        Cell 1 & Cell 2 & Cell 3
    \end{tabular}
\end{table}
\begin{lstlisting}[caption={First listing}]
    Some code
\end{lstlisting}
\end{document}

答案1

您的程式碼日誌檔案中有兩個警告:

班級記錄簿警告:\float@listhead偵測到!的實作\float@listhead在 KOMA-Script v3.01 2008/11/14 中已被棄用,並已被包的幾個更靈活的功能所取代tocbasic。也許\float@listhead很快就會從 KOMA-Script 中刪除 的實作。scrhack如果您使用的套件仍然\float@listhead在輸入行 18 上實作已棄用的接口,則載入套件可能有助於避免此警告。

班級記錄簿警告:\float@addtolists偵測到!的實作\float@addtolist在 KOMA-Script v3.01 2008/11/14 中已被棄用,並已被包的幾個更靈活的功能所取代tocbasic。自版本 3.12 起,對已棄用 \float@addtolist介面的支援僅限於某些 KOMA-Script 功能,並從其他功能中刪除。scrhack如果您使用的套件仍然實作已棄用的\float@addtolist接口,則載入套件可能有助於避免此警告。

scrhack按照警告中的建議加載包

\documentclass[
    10pt,
    oneside,
    listof=totoc,
    bibliography=totoc,
]{scrbook}
\usepackage{scrhack}% <- added

\usepackage{calc}
\usepackage{graphicx}
\usepackage{listings}

\setkomafont{chapter}{\Large}
\RedeclareSectionCommand[
  beforeskip=\dimexpr-\topskip+2pt\relax,
  afterindent=false
]{chapter}

\makeatletter
\renewcommand\chapterlinesformat[3]{%
  \@hangfrom{#2}{\MakeUppercase{#3}}%
}
\makeatother

\begin{document}
\listoffigures
\listoftables
\lstlistoflistings
\chapter{A Chapter}
\begin{figure}
    \centering\includegraphics[width=0.5\linewidth]{example-image}
    \caption{First figure}
\end{figure}
\begin{table}
    \caption{First table}
    \centering
    \begin{tabular}[width=0.5\linewidth]{ccc}
        Cell 1 & Cell 2 & Cell 3
    \end{tabular}
\end{table}
\begin{lstlisting}[caption={First listing}]
    Some code
\end{lstlisting}
\end{document}

在此輸入影像描述

相關內容