Remova o espaço antes do item na tabela de figuras e outras listas

Remova o espaço antes do item na tabela de figuras e outras listas

Estou tentando remover o espaço antes de cada item em listoffigures, listoftables, etc.

Aqui está o que eu quero fazer:

O espaço relutante antes do item em lof, lot

Aqui está meu 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}

Responder1

Você já está usando o pacote KOMA-Script tocbasic. Assim você pode alterar o recuo das entradas, com \DeclareTOCStyleEntrye atributo indent. Mas o problema com o seu código é que você usa sectionentradas para as figuras em vez de figure. Então você também tem que mudar isso.

\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}

insira a descrição da imagem aqui

Consulte o manual KOMA-Script para obter mais informações sobre \DeclareTOCStyleEntry.

BTW: tocbasictambém fornece um recurso para prefixar entradas por uma string como Figure. Portanto \thefigure, não seria necessário adicionar isso se resultar em problemas com outro uso do \thefigure.

Responder2

Encontrei uma solução limpa sem pacotes aqui:

Recuo no sumário e listas de figuras/tabelas

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

informação relacionada