在 Latex 的圖形條目清單中新增懸掛縮排

在 Latex 的圖形條目清單中新增懸掛縮排

我正在寫論文。然而,我在格式化圖列表時遇到問題。我想知道如何在圖形標題中添加懸掛縮進,以便它與第一行對齊。我正在使用論文類,預設不會在圖號之前寫入單字“圖”和“表”

不帶 tocloft 的初始輸出

因此,我使用tocloft包在圖形和表格編號之前添加單字圖形和表格。這樣做會移動第一行,但第二行保持在原來的位置。

使用 tocloft 包

有什麼方法可以對齊第一行和第二行,保持“圖”一詞完整。我提供了我正在使用的一小部分程式碼。不過,我已經包含了我使用過的所有軟體包。

\documentclass[12pt, a4paper, oneside, openright]{Thesis} % Paper size, default font size and one-sided paper
\usepackage{subfigure}
\usepackage[subfigure]{tocloft}
\usepackage{notoccite}
\usepackage{wrapfig}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{amsmath, nccmath}
\usepackage{comment}
\usepackage{afterpage}
\usepackage{multirow}
\usepackage{notoccite}
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{times}
\usepackage{cleveref}
\usepackage{wasysym}
\usepackage{rotating}
\usepackage[square, numbers]{natbib}


\hypersetup{urlcolor=black, colorlinks=true} % Colors hyperlinks in blue - change to black if annoyingv`    
\title{\ttitle} % Defines the thesis title 
\setlength{\parindent}{20pt}


\setlength\cftbeforefigskip{8pt}    % To add line spacing between entries in LOF
\setlength\cftbeforechapskip{8pt}   % To add line spacing between entries in LOC
\setlength\cftbeforetabskip{8pt}    % To add line spacing between entries in LOT

\begin{document}
\makeatletter
\renewcommand*{\NAT@nmfmt}[1]{\textsc{#1}}
\makeatother

\frontmatter 

\fancyhead{} % Clears all page headers and footers
\rhead{\thepage} % Sets the right side header to show the page number
\lhead{} % Clears the left side page header

\pagestyle{fancy} % Finally, use the "fancy" page style to implement the FancyHdr headers

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % New command to make the lines in the title page

% PDF meta-data
\hypersetup{pdftitle={\ttitle}}
\hypersetup{pdfsubject=\subjectname}
\hypersetup{pdfauthor=\authornames}
\hypersetup{pdfkeywords=\keywordnames}


\pagestyle{plain}

\acknowledgements{Some Random texts}
\newpage
\addtotoc{Abstract} % Add the "Abstract" page entry to the Contents
\abstract{Some random Texts for Abstract}
\newpage 

\pagestyle{fancy} % The page style headers have been "empty" all this time, now use the "fancy" headers as defined before to bring them back
\addtotoc{Contents}
\lhead{\emph{Contents}} % Set the left side page header to "Contents"
\tableofcontents % Write out the Table of Contents
\newpage
\addtotoc{List of Figures}
\lhead{\emph{List of Figures}} % Set the left side page header to "List of Figures"

%Fragment of code for Writing "Figure" in front of Figure number
{
  \let\oldnumberline\numberline%
  \renewcommand{\numberline}{\figurename~\oldnumberline}%
\listoffigures % Write out the List of Figures
}
\newpage

\addtotoc{List of Tables}
\lhead{\emph{List of Tables}} % Set the left side page header to "List of Tables"
%Fragment of code for Writing "Figure" in front of Figure number
{
  \let\oldnumberline\numberline%
  \renewcommand{\numberline}{\tablename~\oldnumberline}%
\listoftables % Write out the List of Tables
}

\mainmatter % Begin numeric (1,2,3...) page numbering

\pagestyle{fancy} % Return the page headers back to the "fancy" style

% Include the chapters of the thesis as separate files from the Chapters folder
% Uncomment the lines as you write the chapters

\input{Chapters/Chapter1}
\input{Chapters/Chapter2}
\input{Chapters/Chapter3}
\input{Chapters/Chapter4}
\input{Chapters/Chapter5}

\clearpage % Start a new page
\appendix % Cue to tell LaTeX that the following 'chapters' are Appendices

% Include the appendices of the thesis as separate files from the Appendices folder
% Uncomment the lines as you write the Appendices

\input{Appendices/AppendixA}

\backmatter

\label{References}

\lhead{\emph{References}} % Change the page header to say "Bibliography"
\renewcommand\bibname{References}
\bibliographystyle{unsrt} % Use the "custom" BibTeX style for formatting the Bibliography

\bibliography{references} % The references (bibliography) information are stored in the file named "Bibliography.bib"

\newpage
\include{LOP}
\newpage
\end{document}

我哪裡做錯了?

答案1

您重新定義的方式\numberline

\let\oldnumberline\numberline%
\renewcommand{\numberline}{\figurename~\oldnumberline}

Makecftfignumwidth不考慮 word 的寬度\figurename~。因為這是指揮之外的\numberline。你不應該\numberline這樣重新定義。相反,包tocloft提供命令\cftfigpresnum\cftfigaftersnum在數字之前和之後放置額外的內容。

以下是如何使用這些命令來實現您想要的目的的範例:

\documentclass{book}
\usepackage{graphicx}
\usepackage{tocloft}

\setlength\cftbeforefigskip{8pt}
\settowidth{\cftfignumwidth}{Figure~1.100~}% set the \cftfignumwidth to certain length of text in case you have a huge numbered figure, e.g., Figure~1.100~
\renewcommand{\cftfigpresnum}{Figure~}% add the word figure and a space before the number
\renewcommand{\cftfigaftersnum}{~} % add a space after the number

\begin{document}
\listoffigures
\chapter{One}
\begin{figure}
    \centering
    \includegraphics{example-image}
    \caption{A very very very very very very very very very very very very very very very very very very very very very very long Caption}
\end{figure}
\setcounter{figure}{10}
\begin{figure}
    \centering
    \includegraphics{example-image}
    \caption{A very very very very very very very very very very very very very very very very very very very very very very long Caption}
\end{figure}
\setcounter{figure}{100}
\begin{figure}
    \centering
    \includegraphics{example-image}
    \caption{A very very very very very very very very very very very very long Caption}
\end{figure}
\end{document}

在此輸入影像描述

相關內容