![図表やその他のリストの項目の前のスペースを削除します](https://rvso.com/image/461915/%E5%9B%B3%E8%A1%A8%E3%82%84%E3%81%9D%E3%81%AE%E4%BB%96%E3%81%AE%E3%83%AA%E3%82%B9%E3%83%88%E3%81%AE%E9%A0%85%E7%9B%AE%E3%81%AE%E5%89%8D%E3%81%AE%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%82%92%E5%89%8A%E9%99%A4%E3%81%97%E3%81%BE%E3%81%99.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}
の詳細については、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