如何使(LOF)图形列表中的图号右对齐?

如何使(LOF)图形列表中的图号右对齐?

在此处输入图片描述

现在的情况就是这样

我想要的是,看起来像这样

Figure    1.1.1: xxxxx  
Figure   1.1.11: xxxxx  
Figure    2.1.1: xxxxxx

我尝试重新定义标题样式:

\usepackage{caption}
\DeclareCaptionLabelFormat{mycap}{#1\ \makebox[2em][r]{#2}}
\captionsetup{labelformat=mycap}

在主体中有效,但在 LOF 中无效

有人能帮我吗?提前谢谢

测试用MES:

\documentclass[12pt]{article}

\usepackage{graphicx}
\usepackage[titles]{tocloft}


\renewcommand{\cftdotsep}{2} 
\renewcommand{\cftfigindent}{0em}  
\renewcommand{\cftfignumwidth}{8.5em}  
\renewcommand{\cftfigpresnum}{Figure \ } 
\renewcommand{\cftfigaftersnum}{:} 

\renewcommand\thefigure{\thesection.\arabic{figure}}

\begin{document}

\section{the fist section}

\begin{figure}[h]
\includegraphics{testfig.png}
\caption{Fig for Test}
\end{figure}

\addtocounter{figure}{111}
\begin{figure}[h]
    \includegraphics*{testfig.png}
    \caption{Fig for Test}
\end{figure}

\listoffigures    
\end{document}

在此处输入图片描述

答案1

您需要修改包的宏\cftfigpresnum和,例如\cftfigaftersnumtocloft

\renewcommand{\cftfigpresnum}{Figure\hfill} 
\renewcommand{\cftfigaftersnum}{:\ } 

我还会将 的值减小\cftfignumwidth到约 6em。

完整的 MWE:

在此处输入图片描述

\documentclass[12pt]{article}

\renewcommand\thefigure{\thesection.\arabic{figure}}

\usepackage[titles]{tocloft}
\renewcommand{\cftdotsep}{2} 
\renewcommand{\cftfigindent}{0em}  
\renewcommand{\cftfignumwidth}{6em}  
\renewcommand{\cftfigpresnum}{Figure\hfill} 
\renewcommand{\cftfigaftersnum}{:\ } 

\begin{document}
\listoffigures    

\setcounter{section}{2}
\begin{figure}[h]
\caption{A caption}
\end{figure}
\addtocounter{figure}{111}
\begin{figure}[h]
\caption{Another caption}
\end{figure}
\end{document}

答案2

标题目录

使用班级

\documentclass[11pt,oneside]{book}
\usepackage[top=2.5cm,bottom=2.5cm,left=2.5cm,right=2cm,headsep=15pt,footskip=27pt,a4paper]{geometry}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{float}
%\usepackage{titlesec}
\usepackage{titletoc}
\captionsetup[figure]{labelfont=bf}
%--------------------
% figure text styling
\titlecontents{figure}
    [7.5em]%
    {\normalsize\addvspace{3pt}}
    {\contentslabel[\normalsize\bfseries Figure\hfill\thecontentslabel:]{7.2em}\hphantom{v}}
    {}%
    {\enspace\titlerule*[.6pc]{.}\contentspage}%
    [\addvspace{1pt}]

\begin{document}
\tableofcontents
\listoffigures
\chapter{Title one}
\section{Figures of 1-digit number}
\begin{figure}[H]
  \centering\includegraphics{map1}
  \caption{This is a beautiful map.}
\end{figure}

\setcounter{chapter}{22}
\chapter{Title two}
\section{Figures of 2-digit number}
\setcounter{figure}{22}
\begin{figure}[H]
  \centering\includegraphics{map1}
  \caption{This is a beautiful map.}
\end{figure}

\section{Figures of 3-digit number}
\setcounter{figure}{111}
\begin{figure}[H]
    \centering
    \includegraphics{testfig.png}
    \caption{Fig for Test}
\end{figure}

\end{document}

结果:

结果

答案3

使用示例tocbasic

\documentclass[12pt]{article}

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  indent=0em,
  dynnumwidth,% calculates needed numwidth,
  numsep=0pt,% no additional space between number and text
  entrynumberformat=\loffignum
]{tocline}{figure}
\newcommand*\loffignum[1]{%
  \figurename\ \hfill#1:\ %
}

\makeatletter
\renewcommand{\@dotsep}{2}
\makeatother
\renewcommand\thefigure{\thesection.\arabic{figure}}

\begin{document}
\section{the fist section}
\begin{figure}[h]
\caption{Fig for Test}
\end{figure}
\addtocounter{figure}{111}
\begin{figure}[h]
\caption{Fig for Test}
\end{figure}
\listoffigures
\end{document}

运行三次得到:

在此处输入图片描述

相关内容