![Удалить пробел перед элементом в таблице рисунков и других списках](https://rvso.com/image/461915/%D0%A3%D0%B4%D0%B0%D0%BB%D0%B8%D1%82%D1%8C%20%D0%BF%D1%80%D0%BE%D0%B1%D0%B5%D0%BB%20%D0%BF%D0%B5%D1%80%D0%B5%D0%B4%20%D1%8D%D0%BB%D0%B5%D0%BC%D0%B5%D0%BD%D1%82%D0%BE%D0%BC%20%D0%B2%20%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D0%B5%20%D1%80%D0%B8%D1%81%D1%83%D0%BD%D0%BA%D0%BE%D0%B2%20%D0%B8%20%D0%B4%D1%80%D1%83%D0%B3%D0%B8%D1%85%20%D1%81%D0%BF%D0%B8%D1%81%D0%BA%D0%B0%D1%85.png)
Я хочу удалить пробел перед каждым элементом в listoffigures, listoftables и т. д.
Вот что я хочу сделать:
Вот мой 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
атрибута и 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}
\DeclareTOCStyleEntry
Более подробную информацию о . см. в руководстве KOMA-Script .
Кстати: 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