目录不一致,一位数字的表格与两位数字的表格空格不同

目录不一致,一位数字的表格与两位数字的表格空格不同

我使用了以下主要代码:

      \documentclass{report}

%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PACKAGES %%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{arabtex}
\usepackage[utf8]{inputenc}

\usepackage{graphicx}
\graphicspath{ {images/} }
%\usepackage[a4paper, width = 150mm, top = 25mm, bottom = 25mm, bindingoffset = 4mm]{geometry}
\usepackage[a4paper,margin=2.5cm, left=4cm, top=2.5cm, right=2.5cm, bottom=2.5cm]{geometry}

\usepackage{sectsty}
\usepackage{titlesec}

\titleformat{\chapter}[display]
{\vspace{0cm}\filcenter}
{\filcenter \LARGE\bfseries
\chaptertitlename\ \justwords{\thechapter}}
{0ex}
{\vspace*{0ex}\filcenter\Huge\bfseries}
\def\justwords#1{\ifcase#1 \or ONE\or TWO\or THREE\or FOUR\or FIVE\fi}
\titlespacing*{\chapter}{0pt}{-30pt}{10pt}

\usepackage[titles]{tocloft}

\usepackage{hyperref}
\usepackage{tocloft}



%%%%%%%%%%%%%

% Define a command for capital Roman numerals
\newcommand{\RomanNumeral}[1]{\uppercase\expandafter{\romannumeral#1\relax}}

% Redefine the chapter format for the table of contents
\renewcommand{\cftchapaftersnum}{-} % add a dot after the chapter number in TOC
\renewcommand{\cftchapleader}{\cftdotfill{ \cftdotsep}} % add dots to the page number
\renewcommand{\cftchappresnum}{\RomanNumeral} % use capital Roman numerals for chapter numbers




%%%%%%%%%%%%%%%%%%%%%%%%%%


\usepackage{caption}
\usepackage{chngcntr}

\counterwithout{figure}{chapter}

% Adjust table numbering to be independent of chapters
\counterwithout{table}{chapter}

\usepackage{etoolbox}
\usepackage{setspace}\setstretch{2}
\usepackage[labelfont=bf]{caption}
\usepackage{enumitem}
\usepackage{pdfpages}
%\usepackage{caption}
\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{\alph{subfigure})}



%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PRELIMINARY PAGES %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}


\thispagestyle{empty}

\pagebreak

\thispagestyle{empty}
\begin{center}
\vspace*{\fill}
\textcopyright\ 2023\\
 
All Rights Reserved \\
\end{center}

\pagenumbering{roman}\setcounter{page}{1}

\pagebreak

\chapter*{ACKNOWLEDGEMENTS}
\addcontentsline{toc}{chapter}{ACKNOWLEDGEMENTS}


\pagebreak
\begin{center}
\LARGE{} \vspace{1cm}
\Large{} \vspace{0cm}

\end{center}
\vspace{-\baselineskip}
\begingroup
{\let\clearpage\relax \chapter*{ABSTRACT}}
\addcontentsline{toc}{chapter}{ABSTRACT}
\endgroup

\newpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TABLE OF CONTENT %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%


\addcontentsline{toc}{chapter}{TABLE OF CONTENTS}
\renewcommand*\contentsname{TABLE OF CONTENTS}
\renewcommand*\listtablename{TABLE OF CONTENTS}

\tableofcontents

\newpage
\addcontentsline{toc}{chapter}{LIST OF TABLES}
\renewcommand*\listtablename{LIST OF TABLES}
\listoftables
\newpage

\addcontentsline{toc}{chapter}{LIST OF FIGURES}
\renewcommand*\listfigurename{LIST OF FIGURES}

\listoffigures
\newpage


\pagenumbering{arabic}\setcounter{page}{1}
 \renewcommand{\chaptername}{CHAPTER}

\chapter{INTRODUCTION}\label{chapter:intro}

\chapter{RELATED WORK}\label{chapter:lit_review}


\chapter{PROPOSED APPROACH}\label{chapter:algorithm}
\input{table}


\end{document}

在另一个文件 table.tex 中(用于测试):

\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}

\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\begin{table}
    \centering
    \begin{tabular}{cc}
         & \\
         & \\
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}

    

结果是:表 1 - 标题表 10 -标题就像新数字从后面的空格中取出一样 -

我还注意到罗马数字和章节名称之间的空格不一致:
I-标题 III-标题

答案1

原作者所说的目录和表格列表中的间距不一致,其他人往往认为这完全正常。除非你的大学或雇主要求你做出改变,否则我会选择 LaTeX 默认布局方案。

我还想建议你简化一些相当巴洛克风格的编程习惯。下面的代码提供了一些关于如何简化序言代码的建议。

在此处输入图片描述


在此处输入图片描述


\documentclass{report}

% Create a scratch file "on the fly":
\begin{filecontents}[overwrite]{tables.tex}
\begin{table}[h] \caption{Caption a} \label{tab:my_label1} \end{table}
\begin{table}[h] \caption{Caption b} \label{tab:my_label2} \end{table}
\begin{table}[h] \caption{Caption c} \label{tab:my_label3} \end{table}
\begin{table}[h] \caption{Caption d} \label{tab:my_label4} \end{table}
\begin{table}[h] \caption{Caption e} \label{tab:my_label5} \end{table}
\begin{table}[h] \caption{Caption f} \label{tab:my_label6} \end{table}
\begin{table}[h] \caption{Caption g} \label{tab:my_label7} \end{table}
\begin{table}[h] \caption{Caption h} \label{tab:my_label8} \end{table}
\begin{table}[h] \caption{Caption i} \label{tab:my_label9} \end{table}
\begin{table}[h] \caption{Caption j} \label{tab:my_label10} \end{table}
\begin{table}[h] \caption{Caption k} \label{tab:my_label11} \end{table}
\begin{table}[h] \caption{Caption l} \label{tab:my_label12} \end{table}
\end{filecontents}

\usepackage{arabtex}
%\usepackage[utf8]{inputenc} % that's the default nowadays
%\usepackage[T1]{fontenc}

\usepackage{graphicx}
\graphicspath{ {images/} }
\usepackage[a4paper, left=4cm, right=2.5cm, vmargin=2.5cm]{geometry}

\usepackage{titlesec}
\titleformat{\chapter}[display]%
   {\vspace{0cm}\filcenter}
   {\filcenter\LARGE\bfseries
   \chaptertitlename\ \justwords{\value{chapter}}}
   {0ex}
   {\vspace*{0ex}\filcenter\Huge\bfseries}
\def\justwords#1{\ifcase#1 \or ONE\or TWO\or THREE\or FOUR\or FIVE\fi}
\titlespacing*{\chapter}{0pt}{-30pt}{10pt}

\usepackage[titles]{tocloft}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} 
\cftsetindents{chap}{0em}{2.5em}
\cftsetindents{table}{0em}{2em}

\usepackage[colorlinks,allcolors=blue,linktocpage]{hyperref}

\renewcommand\thechapter{\Roman{chapter}}
\renewcommand{\chaptername}{CHAPTER}

\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}

\usepackage{setspace}
\setstretch{2}
\usepackage{enumitem}
\usepackage{pdfpages}

\usepackage[labelfont=bf]{caption}
\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{\alph{subfigure})}



\begin{document}

\thispagestyle{empty}
\pagebreak

\thispagestyle{empty}
\begin{center}
\vspace*{\fill}
\textcopyright\ 2023
 
All Rights Reserved 
\end{center}
\pagebreak

\pagenumbering{roman}

\chapter*{ACKNOWLEDGEMENTS}
\addcontentsline{toc}{chapter}{ACKNOWLEDGEMENTS}
\pagebreak

\begin{center}
\LARGE{} \vspace{1cm}
\Large{} \vspace{0cm}
\end{center}
\vspace{-\baselineskip}
\begingroup
{\let\clearpage\relax \chapter*{ABSTRACT}}
\addcontentsline{toc}{chapter}{ABSTRACT}
\endgroup
\newpage

\addcontentsline{toc}{chapter}{TABLE OF CONTENTS}
\renewcommand*\contentsname{TABLE OF CONTENTS}
\tableofcontents
\newpage

\addcontentsline{toc}{chapter}{LIST OF TABLES}
\renewcommand*\listtablename{LIST OF TABLES}
\listoftables
\newpage

\addcontentsline{toc}{chapter}{LIST OF FIGURES}
\renewcommand*\listfigurename{LIST OF FIGURES}
\listoffigures
\newpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%

\pagenumbering{arabic}

\chapter{INTRODUCTION}\label{chapter:intro}

\chapter{RELATED WORK}\label{chapter:lit_review}

\chapter{PROPOSED APPROACH}\label{chapter:algorithm}
\input tables % load contents of 'tables.tex'

\end{document}

相关内容