Eliminar espacio antes del elemento en la tabla de figuras y otras listas

Eliminar espacio antes del elemento en la tabla de figuras y otras listas

Estoy buscando eliminar el espacio antes de cada elemento en listaffigures, listoftables, etc.

Esto es lo que quiero hacer:

El espacio involuntario antes del artículo en lof, lote.

Aquí está mi 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}

Respuesta1

Ya estás utilizando el paquete KOMA-Script tocbasic. Entonces puedes cambiar la sangría de las entradas, con \DeclareTOCStyleEntryy atributo indent. Pero el problema con tu código es que utilizas sectionentradas para las cifras en lugar de figure. Entonces también tienes que cambiar esto.

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

ingrese la descripción de la imagen aquí

Consulte el manual de KOMA-Script para obtener más información sobre \DeclareTOCStyleEntry.

Por cierto: tocbasictambién proporciona una función para prefijar las entradas con una cadena como Figure. Por lo tanto, no sería necesario agregar esto a \thefigure, si genera problemas con otros usos de \thefigure.

Respuesta2

Encontré una solución limpia sin paquetes aquí:

Sangría en TOC y listas de figuras/tablas

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

información relacionada