图片编号粘贴在图表目录中的图片标题上

图片编号粘贴在图表目录中的图片标题上

问题 在图表中:当章节号和图片号过大时,图片号将粘贴在图片标题上。

(表格列表中可能也存在同样的问题,但我的表格不多,所以它没有显示。)

我得到了类似的东西

10.10图片说明...

代替

10.10 图片标题...

工作示例

备注:你需要有一些与“some_pic.png”路径匹配的图像,或者替换“some_pic.png”。

%Preamble
\documentclass[11pt,a4paper,french,oneside,openright]{book}

\usepackage[left=28mm,right=34mm,top=37mm,bottom=44mm]{geometry}

\usepackage{comment}
\begin{comment}
%\usepackage{biblatex}
%\addbibresource{Pages/bibliography.bib}
\end{comment}

\usepackage{float}
\usepackage{afterpage}
\usepackage{lastpage}

\newcommand{\blankpage}{
    \null
    \thispagestyle{empty}
%    \addtocounter{page}{-1}
    \newpage
}
   
\newcommand{\startcontentpagestyle}{
    \pagestyle{fancy}
    \lfoot{"Shortened title..."}
    \rfoot{Page \thepage/\pageref{LastPage}}
    \renewcommand{\headrulewidth}{0.1pt}
    \renewcommand{\footrulewidth}{0.1pt}
    
\fancyhead{}
\lhead{\parbox[t]{0.5\textwidth}{\RaggedRight\rightmark\strut}}
\rhead{\parbox[t]{0.5\textwidth}{\RaggedLeft\leftmark\strut}}
\setlength{\headheight}{0\baselineskip}
\pagestyle{fancy}

    \fancypagestyle{plain}{%
      \fancyhf{}%
      \fancyfoot[L]{"Shortened title..."}%
      \fancyfoot[R]{Page \thepage/\pageref{LastPage}}%
      \renewcommand{\headrulewidth}{0pt}% Line at the header invisible
      \renewcommand{\footrulewidth}{0.1pt}% Line at the footer visible
    }   
}
    
\usepackage{fancyhdr}
\usepackage{ragged2e}
\usepackage{graphicx}
\graphicspath{ {./Images/} }

\usepackage{lipsum}

\usepackage[titles]{tocloft}
\usepackage{calc}
%\renewcommand{\cftchappresnum}{Chapitre }
%\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapitre }}}

\renewcommand*\cftchapnumwidth{2em}
\renewcommand*\cftsecnumwidth{3em}

\title{Complete title}
\author{Author name}
\date{2021}

\usepackage{titlesec}

\usepackage[strings]{underscore}

% a command to tweak \addcontentsline for chapters
\newcommand{\chapitretocentry}{%
    \let\oldacl=\addcontentsline % save original definition
    \def\addcontentsline##1##2##3{% (re)define \addcontentsline
        \def\tempa{##1}\def\tempb{toc}% store ##1 and toc in temp vars
        \ifx\tempa\tempb % check if they are "equal"
            \def\tempa{##2}\def\tempb{chapter}%
            \ifx\tempa\tempb % check if ##2 is "equal" to chapter
                \oldacl{##1}{##2}{\chaptername\space ##3}% apply original \addcontentsline adding \chaptername
% in the other cases, just apply the original \addcontentsline
            \else
                \oldacl{##1}{##2}{##3}%
            \fi
        \else
            \oldacl{##1}{##2}{##3}%
        \fi
    }
}
\AtBeginDocument{\chapitretocentry} % invoke the command at the beginning


%Trying to get long titles in TOC
%Source: https://latex.org/forum/viewtopic.php?t=1267
\makeatletter
\newcommand*\std@chapter{}
\let\std@chapter=\@chapter
\renewcommand*\@chapter[2][]{\std@chapter[#2]{#2}\chaptermark{#1}}
\makeatother



\usepackage{datetime}
\usepackage[titletoc]{appendix}
\usepackage[french]{babel}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,      
    urlcolor=cyan
}

\newcommand{\fig}[5]{
\begin{figure}[H]
\begin{center}
\includegraphics[scale={#2},angle={#1}]{{#3}}
    \caption[{#4}]{{#4}}
    \textbf{\textit{Source :}} \href{{#5}}{{#5}}
\end{center}
\end{figure}
}

\newcommand{\figB}[4]{
\begin{figure}[H]
\begin{center}
\includegraphics[scale={#2},angle={#1}]{{#3}}
    \caption[{#4}]{{#4}}
\end{center}
\end{figure}
}


\begin{document}

    \pagenumbering{gobble}
    \tableofcontents
    \newpage
    \listoffigures
    \listoftables
    \newpage
    \pagenumbering{arabic}
    \setcounter{chapter}{0}
    \setcounter{page}{16}
    \part{Introduction}
    \startcontentpagestyle
    
\chapter{Chapter 1}
\chapter{Chapter 2}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\chapter{Chapter 6}
\chapter{Chapter 7}
\chapter{Chapter 8}
\chapter{Chapter 9}
\chapter{Chapter 10}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\end{document}

答案1

您正在使用该tocloft软件包,那么为什么不利用它的功能呢?

% lofprob.tex  SE 609946

\documentclass{book}
\usepackage{tocloft}

%%%%% change the space for figure caption numbers
\setlength{\cftfignumwidth}{4em}
%%% 

\begin{document}
\listoffigures

\chapter{First}

\begin{figure}
\centering
AN ILLUSTRATION
\caption{First figure}
\end{figure}

\end{document}

在此处输入图片描述

您可以对表格标题编号和章节/部分等编号执行类似操作。阅读tocloft手册了解更多信息。

答案2

例如,\quad在图表列表的标题前添加一个怎么样?

%Preamble
\documentclass[11pt,a4paper,french,oneside,openright]{book}

\usepackage[left=28mm,right=34mm,top=37mm,bottom=44mm]{geometry}

\usepackage{comment}
\begin{comment}
%\usepackage{biblatex}
%\addbibresource{Pages/bibliography.bib}
\end{comment}

\usepackage{float}
\usepackage{afterpage}
\usepackage{lastpage}

\newcommand{\blankpage}{
    \null
    \thispagestyle{empty}
%    \addtocounter{page}{-1}
    \newpage
}
   
\newcommand{\startcontentpagestyle}{
    \pagestyle{fancy}
    \lfoot{"Shortened title..."}
    \rfoot{Page \thepage/\pageref{LastPage}}
    \renewcommand{\headrulewidth}{0.1pt}
    \renewcommand{\footrulewidth}{0.1pt}
    
\fancyhead{}
\lhead{\parbox[t]{0.5\textwidth}{\RaggedRight\rightmark\strut}}
\rhead{\parbox[t]{0.5\textwidth}{\RaggedLeft\leftmark\strut}}
\setlength{\headheight}{0\baselineskip}
\pagestyle{fancy}

    \fancypagestyle{plain}{%
      \fancyhf{}%
      \fancyfoot[L]{"Shortened title..."}%
      \fancyfoot[R]{Page \thepage/\pageref{LastPage}}%
      \renewcommand{\headrulewidth}{0pt}% Line at the header invisible
      \renewcommand{\footrulewidth}{0.1pt}% Line at the footer visible
    }   
}
    
\usepackage{fancyhdr}
\usepackage{ragged2e}
\usepackage{graphicx}
\graphicspath{ {./Images/} }

\usepackage{lipsum}

\usepackage[titles]{tocloft}
\usepackage{calc}
%\renewcommand{\cftchappresnum}{Chapitre }
%\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapitre }}}

\renewcommand*\cftchapnumwidth{2em}
\renewcommand*\cftsecnumwidth{3em}

\title{Complete title}
\author{Author name}
\date{2021}

\usepackage{titlesec}

\usepackage[strings]{underscore}

% a command to tweak \addcontentsline for chapters
\newcommand{\chapitretocentry}{%
    \let\oldacl=\addcontentsline % save original definition
    \def\addcontentsline##1##2##3{% (re)define \addcontentsline
        \def\tempa{##1}\def\tempb{toc}% store ##1 and toc in temp vars
        \ifx\tempa\tempb % check if they are "equal"
            \def\tempa{##2}\def\tempb{chapter}%
            \ifx\tempa\tempb % check if ##2 is "equal" to chapter
                \oldacl{##1}{##2}{\chaptername\space ##3}% apply original \addcontentsline adding \chaptername
% in the other cases, just apply the original \addcontentsline
            \else
                \oldacl{##1}{##2}{##3}%
            \fi
        \else
            \oldacl{##1}{##2}{##3}%
        \fi
    }
}
\AtBeginDocument{\chapitretocentry} % invoke the command at the beginning


%Trying to get long titles in TOC
%Source: https://latex.org/forum/viewtopic.php?t=1267
\makeatletter
\newcommand*\std@chapter{}
\let\std@chapter=\@chapter
\renewcommand*\@chapter[2][]{\std@chapter[#2]{#2}\chaptermark{#1}}
\makeatother



\usepackage{datetime}
\usepackage[titletoc]{appendix}
\usepackage[french]{babel}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,      
    urlcolor=cyan
}

\newcommand{\fig}[5]{
\begin{figure}[H]
\begin{center}
\includegraphics[scale={#2},angle={#1}]{{#3}}
    \caption[{#4}]{{#4}}
    \textbf{\textit{Source :}} \href{{#5}}{{#5}}
\end{center}
\end{figure}
}

\newcommand{\figB}[4]{
\begin{figure}[H]
\begin{center}
\includegraphics[scale={#2},angle={#1}]{{#3}}
    \caption[\quad{#4}]{{#4}} %%% <-----
\end{center}
\end{figure}
}


\begin{document}

    \pagenumbering{gobble}
    \tableofcontents
    \newpage
    \listoffigures
    \listoftables
    \newpage
    \pagenumbering{arabic}
    \setcounter{chapter}{0}
    \setcounter{page}{16}
    \part{Introduction}
    \startcontentpagestyle
    
\chapter{Chapter 1}
\chapter{Chapter 2}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\chapter{Chapter 6}
\chapter{Chapter 7}
\chapter{Chapter 8}
\chapter{Chapter 9}
\chapter{Chapter 10}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\figB{0}{0.42}{some_pic.png}{Pic caption}
\end{document}

在此处输入图片描述

相关内容