刪除圖表和其他清單中項目之前的空格

刪除圖表和其他清單中項目之前的空格

我希望刪除數字列表、表格列表等中每個項目之前的空格。

這就是我想做的:

lof、lot 中項目之前的不願意的空格

這是我的 MWE :

\documentclass[11pt, a4paper, dvipsnames, openany, twoside]{book}

%-------------------------------------------------------------------
% Packages
%-------------------------------------------------------------------

\usepackage[francais]{babel}
\usepackage{caption}
\usepackage{etoolbox}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usepackage{tocbasic}
%\usepackage[nottoc, notlof, notlot]{tocbibind}
\usepackage{xcolor}

%-------------------------------------------------------------------
% Structure
%-------------------------------------------------------------------

% Color
\colorlet{maincolor}{Red}

% Lists : settings

    % Set "listof" as sections and not as chapters
    \addtotoclist[float]{lof}
    \renewcommand*\listoffigures{\listoftoc[{\listfigurename}]{lof}}
    \addtotoclist[float]{lot}
    \renewcommand*\listoftables{\listoftoc[{\listtablename}]{lot}}
    \makeatletter
    \doforeachtocfile[float]{\setuptoc{\@currext}{leveldown}}
    \makeatother

    \renewcommand{\numberline}[1]{#1~--~}
    \renewcommand{\thefigure}{Figure~\arabic{chapter}.\arabic{figure}}
    \renewcommand{\thetable}{Tableau~\arabic{chapter}.\arabic{table}}

    \renewcommand\frenchtablename{}
    \renewcommand{\frenchlistfigurename}{Liste des figures}

% Figure

\newcommand{\myfigure}[2][]{\ifstrempty{#1}{\tcbincludegraphics{#2}}{\tcbincludegraphics[arc=8pt, width=7cm, colframe=maincolor, step and label={figure}{fig:#1}, title=\textbf{\thefigure~--~{#1}}, phantom={\addcontentsline{lof}{section}{\protect\numberline{\thefigure}{#1}}},]{#2}}}

%-------------------------------------------------------------------
% Beginning of document
%-------------------------------------------------------------------

\begin{document}

\chapter*{Table des illustrations}

\listoffigures
\listoftables

\chapter{Illustrations diverses}

\section{Première section}

\lipsum[1]
\myfigure[Figure test]{example-image-b}

\end{document}

答案1

您已經在使用 KOMA-Script 套件tocbasic。因此,您可以使用\DeclareTOCStyleEntry和 attribute更改條目的縮排indent。但您的程式碼的問題是,您使用section數字條目而不是figure.所以你也必須改變這一點。

\documentclass[11pt, a4paper, dvipsnames, openany, twoside]{book}

%-------------------------------------------------------------------
% Packages
%-------------------------------------------------------------------

\usepackage[francais]{babel}
\usepackage{caption}
\usepackage{etoolbox}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usepackage{tocbasic}
%\usepackage[nottoc, notlof, notlot]{tocbibind}
\usepackage{xcolor}

%-------------------------------------------------------------------
% Structure
%-------------------------------------------------------------------

% Color
\colorlet{maincolor}{Red}

% Lists : settings

    % Set "listof" as sections and not as chapters
    \addtotoclist[float]{lof}
    \renewcommand*\listoffigures{\listoftoc[{\listfigurename}]{lof}}
    \addtotoclist[float]{lot}
    \renewcommand*\listoftables{\listoftoc[{\listtablename}]{lot}}
    \makeatletter
    \doforeachtocfile[float]{\setuptoc{\@currext}{leveldown}}
    \makeatother

    \renewcommand{\numberline}[1]{#1~--~}
    \renewcommand{\thefigure}{Figure~\arabic{chapter}.\arabic{figure}}
    \renewcommand{\thetable}{Tableau~\arabic{chapter}.\arabic{table}}

    \renewcommand\frenchtablename{}
    \renewcommand{\frenchlistfigurename}{Liste des figures}

% Figure

\newcommand{\myfigure}[2][]{\ifstrempty{#1}{\tcbincludegraphics{#2}}{\tcbincludegraphics[arc=8pt,
    width=7cm, colframe=maincolor, step and label={figure}{fig:#1},
    title=\textbf{\thefigure~--~{#1}},
    phantom={\addcontentsline{lof}
      {figure}% CHANGED
      {\protect\numberline{\thefigure}{#1}}},]{#2}}}

\newcommand*{\numberwithhyphen}[1]{#1~--~}% ADDED (You could use this also to add `\figurename` before the number, if you'd also adapt numwidth attribute.)

\DeclareTOCStyleEntry[indent=0pt,numwidth=5.5em,entrynumberformat=\numberwithhyphen]{tocline}{figure}% ADDED

%-------------------------------------------------------------------
% Beginning of document
%-------------------------------------------------------------------

\begin{document}

\chapter*{Table des illustrations}

\listoffigures
\listoftables

\chapter{Illustrations diverses}

\section{Première section}

\lipsum[1]
\myfigure[Figure test]{example-image-b}

\end{document}

在此輸入影像描述

有關 的更多信息,請參閱 KOMA-Script 手冊\DeclareTOCStyleEntry

順便說一句:tocbasic還提供了一個功能,可以透過字串(如Figure.因此\thefigure,如果這會導致\thefigure.

答案2

我在這裡找到了一個沒有軟體包的乾淨解決方案:

目錄和圖/表列表中的縮排

\makeatletter
\renewcommand*\l@figure{\@dottedtocline{1}{0em}{2.3em}}% Default: 1.5em/2.3em
\let\l@table\l@figure
\makeatother

相關內容