我正在写论文。然而,我在格式化图片列表时遇到了一个问题。我想知道如何为图片标题添加悬挂缩进,以便它与第一行对齐。我正在使用论文类,默认情况下不会在图号前写上单词“图”和“表”
因此,我使用tocloft
包在图形和表格编号之前添加了单词“图形”和“表格”。这样做会移动第一行,但第二行保持原样。
有什么方法可以对齐第一行和第二行,同时保持“Figure”一词不变。我提供了我正在使用的一小部分代码。但是,我已经包含了我使用过的所有软件包。
\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
不考虑单词的宽度\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}