删除表格列表和图表列表中元素之间的垂直空格

删除表格列表和图表列表中元素之间的垂直空格

在得到一些关于我最初问题的帮助后,我不得不添加一个方程式列表。我需要以相同的方式格式化图表列表和表格列表,基本上没有每章行的意图。此外,我还需要摆脱每个元素之间的章节空白,因为如果没有按章节区分的元素编号,它在某种程度上毫无意义。

以下是 MWE:

\documentclass[12pt, numbers=noenddot,parskip, headsepline, footsepline,headings=small,
listof=totoc,
index=totoc
]{scrreprt}

\usepackage[a4paper, includeheadfoot, left=3.5cm, right=1.7cm, top=2.5cm, bottom=2.0cm]{geometry}
\renewcommand{\floatpagefraction}{.75}%

\newcommand*{\listappendicesname}{Verzeichnis der Anlagen}

%%% see: https://komascript.de/comment/5578#comment-5578 (Markus Kohm)
\DeclareNewTOC[%
owner=\jobname,
listname=\listappendicesname,% Titel des Verzeichnisses
]{atoc}% Dateierweiterung (a=appendix, toc=table of contents)

\makeatletter
\newcommand*{\useappendixtoc}{%
    \renewcommand*{\ext@toc}{atoc}%
    \scr@ifundefinedorrelax{hypersetup}{}{% damit es auch ohne hyperref funktioniert
        \hypersetup{bookmarkstype=atoc}%
    }%
}
\ifundefinedorrelax{ext@toc}{%
    \newcommand*{\ext@toc}{toc}
    \renewcommand{\addtocentrydefault}[3]{%
        \expandafter\tocbasic@addxcontentsline\expandafter{\ext@toc}{#1}{#2}{#3}%
    }
}{}

\AfterTOCHead[atoc]{%
    % add the appendix TOC to the main TOC:
    {\def\ext@toc{toc}\addchaptertocentry{}{\listappendicesname}}
    \KOMAoptions{toc=nonumberline}
}
\makeatother

\usepackage{xpatch}% loads also etoolbox
\xapptocmd{\appendix}
{
    \useappendixtoc
    \listofatocs
    \renewcommand\chapterformat{\appendixname\ \thechapter:\enskip}%
    \renewcommand\thechapter{\arabic{chapter}}%
    \xpatchcmd{\addchaptertocentry}
    {\addtocentrydefault{chapter}{#1}{#2}}
    {\addtocentrydefault{chapter}{}{\appendixname\ #1:\ #2}}
    {}{\PatchFailed}
    \renewcommand\chaptermark[1]{\markboth{\chaptermarkformat}{\chaptermarkformat}}
    \renewcommand\chaptermarkformat{\appendixname\ \thechapter\autodot}
}
{}{\PatchFailed}


\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{equation}{chapter}
\counterwithout{table}{chapter}

\usepackage{refcount}
\usepackage{multicol}

\usepackage[onehalfspacing]{setspace}
\usepackage[ngerman]{babel}
\usepackage{blindtext}% only for dummy text

\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings; headings is only a synonym
\automark[chapter]{chapter}
\clearpairofpagestyles
\ihead{\headmark}
\ohead{\pagemark}

\RedeclareSectionCommand[beforeskip=-1sp minus -1sp]{chapter}% no skip before the chapter title

\renewcommand{\topfraction}{.75}
\usepackage{enumitem}
\SetLabelAlign{LeftAlignFullWidth}{\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}}

\usepackage{xcolor}
\usepackage{microtype}
\usepackage{dirtytalk}% in TeXLive but not in MiKTeX

\usepackage{graphicx}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[colorlinks=true, linktocpage=true,citecolor=blue]{hyperref}% load as last package

\newcommand\NoIndent[1]{%
    \par\vbox{\parbox[t]{\linewidth}{#1}}%
}
\newcounter{savepage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Added To MWE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}

\DeclareNewTOC[%
tocentryindent=0pt,% kein Einzug im Verzeichnis
tocentrynumwidth=2em,% Einzug für den Text im Verzeichnis
type=equation
]{loe}
\AtBeginDocument{\renewcaptionname{ngerman}{\contentsname}{Inhalt}
    \newcaptionname{ngerman}\equationname{Formel}% 
    \newcaptionname{ngerman}\listequationname{Verzeichnis der Formeln}
    \renewcaptionname{ngerman}{\listfigurename}{Verzeichnis der Abbildungen}    %Figures
    \renewcaptionname{ngerman}{\listtablename}{Verzeichnis der Tabellen}        %Tables
    \renewcaptionname{ngerman}{\figurename}{Abb.}               %Figure
    \renewcaptionname{ngerman}{\tablename}{Tab.}                %Table
    \renewcaptionname{ngerman}{\bibname}{Verzeichnis der Literatur}             %Bibliography
    \newcaptionname{ngerman}{\lstlistlistingname}{Quelltexte} %Table of listings 
    \newcaptionname{ngerman}{\lstlistingname}{Quelltext}  }%


\makeatletter
\newcommand*{\@currententry}{}
% Zwei amsmath-Anweisungen ändern:
\g@addto@macro\make@display@tag{\set@currententry}%
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}%
    \set@currententry}
\newcommand*{\set@currententry}{%
    \typeout{set current entry}%
    \ifx\@currententry\@empty\else
    \addcontentsline{loe}{equation}{\protect\numberline{\@currentlabel}%
        \@currententry}%
    \global\let\@currententry\@empty
    \fi
}
% Neue Benutzeranweisung
\newcommand*{\equationentry}[1]{%
    \gdef\@currententry{#1}%
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Added To MWE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
    \pagenumbering{Roman}
\tableofcontents
\listofequations
\listoffigures
\listoftables
    \setcounter{savepage}{\value{page}}

    \cleardoublepage
    \pagenumbering{arabic}

    %   \blinddocument
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %Added To MWE
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \chapter{Kapitel 1}
    \begin{equation}\label{eq:Eq1}\equationentry{P-Anteil}
    a=b
    \end{equation}
    \newpage

    \centering% center the table
    \captionaboveof{table}{My caption}
    \label{my-label}
    \begin{tabular}{lllll}
        & \multicolumn{2}{l}{XYZ} & \multicolumn{2}{l}{ABC} \\
        & Sex         & P         & Sex         & P         \\
        AGE1 & 0.5         & 1         & 0.6         & 1         \\
        &             &           &             &          
    \end{tabular}


    \begin{figure}
        Test Figure
        \caption{No Intend Here} \label{fig:LableTest}
    \end{figure}

    \begin{figure}
    Test Figure
    \caption{No Intend Here} \label{fig:LableTest2}
\end{figure}
%   \blinddocument
        \begin{equation}\label{eq:Eq2}\equationentry{P-Anteil}
    a=b
    \end{equation}

        \begin{equation}\label{eq:3}\equationentry{P-Anteil}
    a=b
    \end{equation}

    \chapter{Kapitel 2}

            \begin{equation}\label{eq:Eq4}\equationentry{P-Anteil}
    a=b
    \end{equation}

    \begin{equation}\label{eq:5}\equationentry{P-Anteil}
    a=b
    \end{equation}

        \centering% center the table
    \captionaboveof{table}{My caption}
    \label{my-label2}
    \begin{tabular}{lllll}
        & \multicolumn{2}{l}{XYZ} & \multicolumn{2}{l}{ABC} \\
        & Sex         & P         & Sex         & P         \\
        AGE1 & 0.5         & 1         & 0.6         & 1         \\
        &             &           &             &          
    \end{tabular}


    \begin{figure}
        Test Figure
        \caption{No Intend Here} \label{fig:LableTest3}
    \end{figure}
    \blinddocument
    \appendix



\end{document}

答案1

KOMA-Script 类提供了listof=flat表格、图形等平面列表的选项。平面在此上下文中表示不缩进。它们还提供了listof=nochaptergap避免在另一个章节的元素前出现垂直距离的选项。

\documentclass[12pt, numbers=noenddot,parskip, headsepline, footsepline,headings=small,
listof=totoc,listof=nochaptergap,listof=flat,
index=totoc
]{scrreprt}

\begin{document}
  \tableofcontents
  \listoffigures
  \listoftables
  \chapter{First chapter}
  \captionof{table}{First table}
  \captionof{table}{Second table}
  \captionof{figure}{First figure}
  \chapter{Second chapter}
  \captionof{table}{Third table}
  \captionof{figure}{Second figure}
  \captionof{figure}{Third figure}
\end{document}

结果是:

在此处输入图片描述

作为副作用,该选项listof=flat还会自动检测数字所需的宽度。但这意味着,如果您添加带有更宽(或更小)数字的图形或表格,您可能需要额外运行才能获得正确的表格列表。

有关选项以及可以分配给此选项的所有值的更多信息,请参阅 KOMA-Script 手册(scrguien.pdf或)。scrguide.pdflistof

相关内容