Because of this answer to Extending table of contents dots up to large page numbers I am using tocbasic and would like to add more spacing between the reference numbers in the
- List of listings
- List of algorithms
and the captions. I have been using this solution
\usepackage{tocbasic} \DeclareTOCStyleEntry[numwidth=3.5em]{tocline}{figure}% for figure entries \DeclareTOCStyleEntry[numwidth=3.5em]{tocline}{table}% for table entries to Spacing problem at List of Figures.
How can I add some spacing between the numbers and the entries?
\documentclass{book} \usepackage[algosection]{algorithm2e} % For writing nice algorithms. \usepackage{etoolbox} \usepackage{float} %% The ordering matters here. \usepackage{listings} %% The ordering matters here. \usepackage{lipsum} \usepackage{tocbasic} % For better TOC alignment \usepackage[nottoc]{tocbibind} \usepackage{todonotes} \usepackage[margin=10pt,font=small,labelfont=bf,labelsep=endash,figurewithin=section,tablewithin=section]{caption} % Caption figures and tables nicely. %% After cleveref. % List of Algorithms (NB, requires french spelling of 'algorithmes') \renewcommand*{\listalgorithmcfname}{List of algorithms} \newcommand{\listofalgorithmes}{\tocfile{\listalgorithmcfname}{loa}} % We want the list of listings to look like all the others. \let\Chapter\chapter \def\chapter{\addtocontents{lol}{\protect\addvspace{10pt}}\Chapter} \makeatletter \patchcmd{\@chapter}{\chaptermark{#1}}{% \chaptermark{#1}% \addtocontents{lol}{\protect\addvspace{10\p@}}% }{\typeout{Chapters patched for list-of-listings.}}{\typeout{Could not patch chapters for list-of-listings.}} \makeatother % So Roman page numbers are right aligned. \DeclareTOCStyleEntries[ rightindent=10em, pagenumberbox=\pagenumberbox ]{tocline}{section,subsection,subsubsection,paragraph,subparagraph,figure,table} \newcommand*\pagenumberbox[1]{\mbox{\hspace{1em}#1}} \DeclareTOCStyleEntry[numwidth=3.5em]{tocline}{figure}% for figure entries \DeclareTOCStyleEntry[numwidth=3.5em]{tocline}{table} %\DeclareTOCStyleEntry[numwidth=3.5em]{tocline}{listing}% <- Doesn't work %\DeclareTOCStyleEntry[numwidth=3.5em]{tocline}{algorithm}% <- Doesn't work \AtBeginDocument{\counterwithin{lstlisting}{section}} % Ensures these are numbered enough \setcounter{secnumdepth}{3} \begin{document} \tableofcontents \listoffigures \listoftables \lstlistoflistings \listofalgorithmes \listoftodos \cleardoublepage \pagenumbering{arabic} \section{Arabic numbering starts} \subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this, Who knows?} \lipsum \cleardoublepage \setcounter{page}{123456789} \section{Several pages later} \subsection{Something} \lipsum \cleardoublepage \pagenumbering{Roman} \section{Now we have Roman numbering} \subsection{Something} \lipsum \clearpage \setcounter{page}{123} \section{Several pages later} \subsection{Something} \lipsum \chapter{title} \section{Some figures} \subsection{title} \subsubsection{title} \begin{figure}[htb]\caption{something}\end{figure} \begin{figure}[htb]\caption{something}\end{figure} \begin{figure}[htb]\caption{something}\end{figure} \begin{figure}[htb]\caption{something}\end{figure} \begin{figure}[htb]\caption{something}\end{figure} \chapter{Chapter} \section{Section}\section{Section}\section{Section} \begin{table}[htb]\caption{A table}\end{table} \begin{figure}[htb]\caption{A figure}\end{figure} \begin{lstlisting}[caption={Some code}] \end{lstlisting} \todo[inline=true,caption={A todo note}]{Must do this.} \begin{algorithm}[htb] \DontPrintSemicolon \KwIn{Input} \KwOut{Output} Code\; \caption{Some algorithm.} \end{algorithm} \begin{table}[htb]\caption{A table}\end{table} \begin{figure}[htb]\caption{A figure}\end{figure} \begin{lstlisting}[caption={Some code}] \end{lstlisting} \todo[inline=true,caption={A todo note}]{Must do this.} \begin{algorithm}[htb] \DontPrintSemicolon \KwIn{Input} \KwOut{Output} Code\; \caption{Some algorithm.} \end{algorithm} \begin{table}[htb]\caption{A table}\end{table} \begin{figure}[htb]\caption{A figure}\end{figure} \begin{lstlisting}[caption={Some code}] \end{lstlisting} \todo[inline=true,caption={A todo note}]{Must do this.} \begin{algorithm}[htb] \DontPrintSemicolon \KwIn{Input} \KwOut{Output} Code\; \caption{Some algorithm.} \end{algorithm} \chapter{Chapter} \section{Section}\section{Section}\section{Section} \begin{table}[htb]\caption{A table}\end{table} \begin{figure}[htb]\caption{A figure}\end{figure} \begin{lstlisting}[caption={Some code}] \end{lstlisting} \todo[inline=true,caption={A todo note}]{Must do this.} \begin{algorithm}[htb] \DontPrintSemicolon \KwIn{Input} \KwOut{Output} Code\; \caption{Some algorithm.} \end{algorithm} \begin{table}[htb]\caption{A table}\end{table} \begin{figure}[htb]\caption{A figure}\end{figure} \begin{lstlisting}[caption={Some code}] \end{lstlisting} \todo[inline=true,caption={A todo note}]{Must do this.} \begin{algorithm}[htb] \DontPrintSemicolon \KwIn{Input} \KwOut{Output} Code\; \caption{Some algorithm.} \end{algorithm} \begin{table}[htb]\caption{A table}\end{table} \begin{figure}[htb]\caption{A figure}\end{figure} \begin{lstlisting}[caption={Some code}] \end{lstlisting} \todo[inline=true,caption={A todo note}]{Must do this.} \begin{algorithm}[htb] \DontPrintSemicolon \KwIn{Input} \KwOut{Output} Code\; \caption{Some algorithm.} \end{algorithm} \end{document} Solution for algorithms
Taken from this answer to List of Algorithms: space between number and algorithm caption too small.
\makeatletter \renewcommand*\l@algocf{\@dottedtocline{1}{1em}{3.2em}}% Original {1}{1em}{2.3em} \makeatother which gives


