1

In the list of tables, I have to change the space between a table title and its page number. I was able to change the space between the table number and the table header thanks to the codes I found here, but the above problem still persists. Actually, I found a code like the below:

\makeatletter

\renewcommand{\@pnumwidth}{4em}

\makeatother

However, this code only keeps constant the gap between dots and the page number. If the title of the table is long, words can cross the limit. Example,

enter image description here

I want the word "ratios" line up with the dots. Or let the word "ratios" be on the next line, but let the word "SPN" line up with the dots. Also, the same problem applies to the table of contents and the list of figures.

Many thanks in advance!

Best regards

1
  • Please provide an MWE (from \documentclass... to \end{document}) that we can compile that shows your problem. Otherwise we have no idea what you have done. Feb 2, 2021 at 19:32

2 Answers 2

1

Here is a solution (by adding the command: \renewcommand{\@tocrmarg}{4.2em}):

\documentclass[a4paper,12pt]{article}
\usepackage{array,caption}
\usepackage{tocloft}
\usepackage[left=3cm, top=3cm, right=2.5cm, bottom=2.5cm]{geometry}
\renewcommand{\listtablename}{\hfill\bfseries\normalsize List of Tables\hfill\vspace{24pt}}
\renewcommand{\cfttabdotsep}{0.25}
\newlength\mylength
\cftsetindents{table}{0cm}{0.9cm}
\renewcommand\cfttabpresnum{\tablename~}
\settowidth\mylength{\cfttabpresnum}
\addtolength\cfttabnumwidth{\mylength}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{etoolbox}
\makeatletter
\renewcommand{\@tocrmarg}{4.2em}% -> Here!!!
\renewcommand{\@pnumwidth}{4.2em}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{sloppypar}
\listoftables
\end{sloppypar}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\vspace{-2cm}
{\noindent
$
\begin{array}{llr}
\hspace{-0.2cm}\textbf{Table No}& \hspace{-0.2cm}\textbf{Table Title} &  \hspace{9cm}\textbf{Page No}
\end{array}
$}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\begin{table}[h]
\caption{Mean SSIM results for 20 traditional images with different SPN ratios ranging from bla bla bla}
xxx
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

enter image description here

2
  • 1
    Thank you for your help. The solution worked.
    – Burak
    Feb 3, 2021 at 14:53
  • Welcome @Burak ... Happy TeXing!
    – koleygr
    Feb 3, 2021 at 15:08
0

I guess that the following MWE will be enough.

\documentclass[a4paper,12pt]{article}
\usepackage{array,caption}
\usepackage{tocloft}
\usepackage[left=3cm, top=3cm, right=2.5cm, bottom=2.5cm]{geometry}
\renewcommand{\listtablename}{\hfill\bfseries\normalsize List of Tables\hfill\vspace{24pt}}
\renewcommand{\cfttabdotsep}{0.25}
\newlength\mylength
\cftsetindents{table}{0cm}{0.9cm}
\renewcommand\cfttabpresnum{\tablename~}
\settowidth\mylength{\cfttabpresnum}
\addtolength\cfttabnumwidth{\mylength}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\renewcommand{\@pnumwidth}{4.2em}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\listoftables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\vspace{-2cm}
{\noindent
$
\begin{array}{llr}
\hspace{-0.2cm}\textbf{Table No}& \hspace{-0.2cm}\textbf{Table Title} &  \hspace{9cm}\textbf{Page No}
\end{array}
$}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\begin{table}[h]
\caption{Mean SSIM results for 20 traditional images with different SPN ratios ranging from bla bla bla}
xxx
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

For the above example, YAP is as follows:

Page 1 enter image description here

Page 2 enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .