目录、图片列表和表格列表之间的间距大于正常标题之间的间距

目录、图片列表和表格列表之间的间距大于正常标题之间的间距

我遇到的问题是文本并不完全位于图表和表格列表的标题下方(见图),因此添加了以下代码片段。但是,图表列表和表格列表不再显示在新页面上,而是所有内容都显示在彼此下方。

如果您现在查看页眉和标题之间的距离,您会发现它比正常标题和页眉之间的距离更大。

我怎样才能减少距离或使文本位于图表或表格列表下方?

在此处输入图片描述

我补充道

%%%%%%%%%%%%%% added
\usepackage{tocloft}
\setlength{\cftfigindent}{0pt}
\setlength{\cfttabindent}{0pt}
...
%and after \listoftables
\clearpage

完整文档

\documentclass[12pt]{report}
\usepackage[a4paper, left={3.5cm}, right={2.5cm}, top={3cm}, bottom={3cm}, headheight=15pt]{geometry}
\usepackage[ngerman]{babel}

\usepackage[%
backend=bibtex      % biber or bibtex
%,style=authoryear    % Alphabeticalsch
,style=numeric-comp  % numerical-compressed
,sorting=none        % no sorting
,sortcites=true      % some other example options ...
,block=none
,indexing=false
,citereset=none
,isbn=true
,url=true
,doi=true            % prints doi
,natbib=true         % if you need natbib functions
]{biblatex}
\DefineBibliographyStrings{ngerman}{%
    urlseen = {aufgerufen am}
}
\addbibresource{bibliography.bib}  % better than \bibliography



\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{titlesec}
\setcounter{secnumdepth}{4}
\usepackage{verbatim}
\usepackage{float} 
\usepackage[nohyperlinks, printonlyused]{acronym}
\usepackage{graphicx}
\usepackage[driverfallback=hypertex]{hyperref} 
\titleformat{\chapter}
  {\normalfont\LARGE\bfseries}{\thechapter}{1em}{}
\titlespacing*{\chapter}{0pt}{-10pt}{40pt}


\usepackage{fancyhdr}
\usepackage{lipsum}% just to generate text for the example

\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}} % for vertical centering text in X column
\usepackage{caption}
\captionsetup[table]{position=bottom}


\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyhead[L]{\nouppercase{\leftmark}}%
  \fancyfoot[R]{\thepage}}
\pagestyle{plain}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter. #1}{}}
\usepackage[parfill]{parskip}

\newcommand{\secref}[1]{\ref{#1} \nameref{#1}}



\usepackage{hyperref}
\usepackage[ngerman]{cleveref}

\hypersetup{
    colorlinks   = true, %Colours links instead of ugly boxes
    urlcolor     = black, %Colour for external hyperlinks
    linkcolor    = black, %Colour of internal links
    citecolor   = black %Colour of citations
}


\usepackage{listings}
\crefname{lstlisting}{Code}{Code} 
\renewcommand{\lstlistingname}{Code}
\renewcommand\lstlistlistingname{Codeverzeichnis}

\usepackage{xcolor}

%\usepackage{color}
\definecolor{codegray}{gray}{0.9}
\newcommand{\code}[1]{\colorbox{codegray}{\texttt{#1}}}

%New colors defined below
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray_s}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{HTML}{f5f5f5}

%Code listing style named "mystyle"
\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour}, commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray_s},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

%"mystyle" code listing set
\lstset{style=mystyle}


\usepackage[bottom]{footmisc}

\makeatletter
\def\@makefnmark{%
    \leavevmode
    \raise.9ex\hbox{\fontsize\sf@size\z@\normalfont\tiny\@thefnmark}}
\makeatother

%%%%%%%%%%%%%% added
\usepackage{tocloft}
\setlength{\cftfigindent}{0pt}
\setlength{\cfttabindent}{0pt}



\begin{document}
    



\pagenumbering{roman} % Nummeriung Römisch





\tableofcontents

\clearpage

\listoffigures
\addcontentsline{toc}{chapter}{Abbildungsverzeichnis}
\clearpage

% 
\listoftables
\addcontentsline{toc}{chapter}{Tabellenverzeichnis}
\clearpage






\clearpage
\pagenumbering{arabic} % Nummeriung Arabisch



\newpage
\printbibliography[title=Literaturverzeichnis]


\chapter{Figure}
\begin{figure}
\centering
\includegraphics[width=8cm]{Pgfplot3d3}
\caption{Three dimensional graph.}
\label{fig:figure1}
\end{figure}

\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{pgfplots3dexample.png}
\caption{Second 3D plot.}
\label{fig:figure2}
\end{figure}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis
facilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet
mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus velit ultrices
augue, a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie
ut, ultricies vel, semper in, velit. Ut porttitor. Praesent in sapien. Lorem
ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque.

\subsection{Table}

\begin{table}[h]
\centering
 \begin{tabular}{||c c c c||} 
 \hline
 Col1 & Col2 & Col2 & Col3 \\ [0.5ex] 
 \hline\hline
 1 & 6 & 87837 & 787 \\ 
 \hline
 2 & 7 & 78 & 5415 \\
 \hline
 3 & 545 & 778 & 7507 \\
 \hline
 4 & 545 & 18744 & 7560 \\
 \hline
 5 & 88 & 788 & 6344 \\ [1ex] 
 \hline
 \end{tabular}
\caption{First table.}
\label{tab:table1}
\end{table}

Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a
leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit
mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis.
Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan
semper.

\begin{figure}
\centering
\includegraphics[scale=0.5]{Scattered}
\caption{Scatter plot.}
\label{fig:figure3}
\end{figure}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis
facilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet
mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus velit ultrices
augue, a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie
ut, ultricies vel, semper in, velit. Ut porttitor. Praesent in sapien. Lorem
ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque.

\begin{table}[h]
\centering
\begin{tabular}{ | p{3cm} | p{3cm} | p{3cm} |  }
 \hline
 \multicolumn{3}{|c|}{Country List} \\
 \hline
 Country Name    or Area Name& ISO ALPHA 2 Code &ISO ALPHA 3 \\
 \hline
 Afghanistan & AF &AFG \\
 Aland Islands & AX & ALA \\
 Albania    &AL & ALB \\
 Algeria    &DZ & DZA \\
 American Samoa & AS & ASM \\
 Andorra & AD & AND \\
 Angola & AO & AGO \\
 \hline
 \end{tabular}
\caption{Dummy table.}
\label{tab:table2}
\end{table}

Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a
leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit
mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis.
Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan
semper.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis
facilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet
mi nec ante. Donec ullamcorper, felis non sodales commodo, lectus velit ultrices
augue, a dignissim nibh lectus placerat pede. Vivamus nunc nunc, molestie
ut, ultricies vel, semper in, velit. Ut porttitor. Praesent in sapien. Lorem
ipsum dolor sit amet, consectetuer adipiscing elit. Duis fringilla tristique neque.

\begin{table}[h]
\centering
\begin{tabular}{ | c | c | c | } 
  \hline
  cell1 & cell2 & cell3 \\ 
  cell4 & cell5 & cell6 \\ 
  cell7 & cell8 & cell9 \\ 
  \hline
\end{tabular}
\caption{Third table.}
\label{tab:table3}
\end{table}

Sed interdum libero ut metus. Pellentesque placerat. Nam rutrum augue a
leo. Morbi sed elit sit amet ante lobortis sollicitudin. Praesent blandit blandit
mauris. Praesent lectus tellus, aliquet aliquam, luctus a, egestas a, turpis.
Mauris lacinia lorem sit amet ipsum. Nunc quis urna dictum turpis accumsan
semper
\end{document}

答案1

这不是答案,因此是社区 wiki,而是为了展示您的代码可以减少到什么程度,以便您了解什么对想要帮助您的人有帮助。您的代码可以从 282 行减少到 41 行:

梅威瑟:

\documentclass{report}
\usepackage[ngerman]{babel}
\usepackage{titlesec}
\usepackage{tocloft}
\usepackage{hyperref}           %---- Hyperref should always come last except for glossaries, cleverref etc.

\setlength{\cftfigindent}{0pt}
\setlength{\cfttabindent}{0pt}

\begin{document}

\tableofcontents
\clearpage

\listoffigures
\addcontentsline{toc}{chapter}{Abbildungsverzeichnis}
\clearpage

\listoftables
\addcontentsline{toc}{chapter}{Tabellenverzeichnis}
\clearpage

\chapter{Figure}
\begin{figure}
\caption{figure 2}
\end{figure}

\begin{figure}
\caption{figure 2}
\end{figure}

\section{Table}

\begin{table}[h]
\caption{First table.}
\end{table}

\begin{table}[h]
\caption{First table.}
\end{table}

\end{document}

这将产生以下输出:

在此处输入图片描述

在此处输入图片描述

当我将原始代码改为(后\addbibresource{bibliography.bib运行\addbibresource{biblatex-examples.bib}笔记:我们无权访问您的 .bib 文件,因此请使用biblatex-examples.bib或方法)并使用选项filecontents更改您使用的图形(即)这是我得到的:demo\usepackage[demo]{graphicx}\includegraphics[width=0.5\textwidth]{demo}

在此处输入图片描述

在此处输入图片描述

您能否删除任何生成的文件(例如.aux.lof),.lot然后尝试重新编译您的文档。这里的人很乐意提供帮助,我也尽力用我有限的知识提供帮助,但您的错误无法重现,并且您的代码太长。希望这能有所帮助,如果在删除任何相关的生成文件后错误仍然存​​在,请编辑您的问题或添加评论。

相关内容