如何删除左边距和目录之间的空格?

如何删除左边距和目录之间的空格?

我一直在处理一篇论文。我遇到了两个具体问题。

  1. 左边距和目录之间的额外空间如图所示 ToC 左边距和 ToC 之间有额外的空格

  2. 左边距与 LoF 和 LoT 之间的额外空间

我通过以下代码解决了第二个问题。但对于 ToC 的第一个问题,我还没有找到任何解决\@dottedtocline{1}{1.5em}方案。\@dottedtocline{1}{0em}

\makeatletter
\xpatchcmd\@dottedtocline
{\leaders\hbox{$\m@th\mkern\@dotsep mu\hbox{.}\mkern\@dotsep mu$}}
{}
{}{\fail}

% enlarge label width
\renewcommand*\l@figure{\@dottedtocline{1}{0em}{4em}}
\renewcommand*\l@table{\@dottedtocline{1}{0em}{5em}}
\makeatother

MWE 如下所示

\documentclass[12pt,a4paper]{report}


%%--------------Basic Packages------------%%
\usepackage{amsmath,amssymb,amsfonts} 
\usepackage[top=2.54cm, bottom=2.54cm, left=3.56cm, right=2.54cm]{geometry}
%\usepackage[labelfont=bf, labelsep=space]{caption} 
%\usepackage[belowskip=4pt, labelformat=simple]{subcaption} 

\usepackage{titletoc}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{graphicx}



\usepackage{titletoc} % Chapter title formatting in ToC
\titlecontents{chapter}[17pt]{\vskip8pt}{\fontsize{14}{16.8}\selectfont\bfseries\MakeUppercase{chapter}~\thecontentslabel\quad}{\bfseries}{\bfseries\hfill\contentspage}[\vskip5pt]




\begin{document}
\tableofcontents
\listoffigures
\chapter{Introduction}
    \section{Introduction}
    \lipsum[2-3]
    \begin{figure}[!htb]
        \centering
        \includegraphics[width=6cm]{example-image}
        \caption{Light Clock}
    \end{figure}
    \begin{figure}[!htb]
        \centering
        \includegraphics[width=6cm]{example-image}
        \caption{Light Clock}
    \end{figure}
    \begin{figure}[!htb]
        \centering
        \includegraphics[width=6cm]{example-image}
        \caption{Light Clock}
    \end{figure}
    
\end{document}

答案1

我改为17pt,并补充\titlecontents{chapter}[17pt]...0pt

\dottedcontents{section}[2.3em]{}{2.3em}{1pc}
\dottedcontents{figure}[2.3em]{}{2.3em}{1pc}
\dottedcontents{table}[2.3em]{}{2.3em}{1pc}

完整示例

\documentclass[12pt,a4paper]{report}


%%--------------Basic Packages------------%%
\usepackage{amsmath,amssymb,amsfonts} 
\usepackage[top=2.54cm, bottom=2.54cm, left=3.56cm, right=2.54cm]{geometry}
\geometry{showframe}
%\usepackage[labelfont=bf, labelsep=space]{caption} 
%\usepackage[belowskip=4pt, labelformat=simple]{subcaption} 

%\usepackage{titletoc}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{graphicx}



\usepackage{titletoc} % Chapter title formatting in ToC
\titlecontents{chapter}[0pt]{\vskip8pt}{\fontsize{14}{16.8}\selectfont\bfseries\MakeUppercase{chapter}~\thecontentslabel\quad}{\bfseries}{\bfseries\hfill\contentspage}[\vskip5pt]

\dottedcontents{section}[2.3em]{}{2.3em}{1pc}
\dottedcontents{figure}[2.3em]{}{2.3em}{1pc}
\dottedcontents{table}[2.3em]{}{2.3em}{1pc}

\begin{document}
\tableofcontents
\listoffigures
\chapter{Introduction}
    \section{Introduction}
    \lipsum[2-3]
    \begin{figure}[!htb]
        \centering
        \includegraphics[width=6cm]{example-image}
        \caption{Light Clock}
    \end{figure}
    \begin{figure}[!htb]
        \centering
        \includegraphics[width=6cm]{example-image}
        \caption{Light Clock}
    \end{figure}
    \begin{figure}[!htb]
        \centering
        \includegraphics[width=6cm]{example-image}
        \caption{Light Clock}
    \end{figure}
    
\end{document}

在此处输入图片描述 在此处输入图片描述

相关内容