TransWikia.com

List of tables horizontal space too small

TeX - LaTeX Asked on May 26, 2021

I have the following issue: I would like to label my tables for part of the document differently, based on subsections. I am using the code renewcommand{thetable}{arabic{section}.arabic{subsection}.arabic{table}} for it. That works fine. But when I create the LOT, the spacing seems off – the caption touches the number of the table to the left for the table with number 10. Is there anything that can be done?
I am also flexible for other solutions than using renewcommand{thetable}{arabic{section}.arabic{subsection}.arabic{table}}, but it works nicely. If I am not mistaken, that is not the problem.
The solution must work with scrreprt.

documentclass[11pt]{scrreprt}
usepackage{caption}
usepackage[USenglish]{babel}
usepackage{setspace}
usepackage[a4paper,showframe=true]{geometry}

begin{document}
    
    listoftables
    
    chapter{Introduction}
    
    renewcommand{thetable}{arabic{section}.arabic{subsection}.arabic{table}}
    
    section{Section}
    subsection{Subsection}
    
    makeatletter
    @whilenumvalue{table}<10do{%
        captionof{table}{This is test table thetable}
    }
    makeatother
    
end{document}

Thanks for any hints.
Edit: I tried listof=flat. It works nicely, but in some cases of longer table headings, it seems to reach a bit too far to the right. Edit: The indentation is wrong using this approach (when the caption reaches over two line, indentation is not right). Therefore this solution is not recommended. Any alternatives?

One Answer

You can use

DeclareTOCStyleEntry[dynnumwidth]{tocline}{table}

Example:

documentclass{scrreprt}
usepackage[USenglish]{babel}
usepackage{showframe}% to show the page layout
usepackage{blindtext}% only for dummy text

DeclareTOCStyleEntry[dynnumwidth]{tocline}{table}

begin{document}
listoftables
chapter{Introduction}
renewcommand{thetable}{Alph{section}.arabic{subsection}.arabic{table}}
section{Section}
subsection{Subsection}
captionof{table}{This is test table thetable}
setcounter{table}{9}
captionof{table}{This is test table thetable}
captionof{table}{blindtext}
end{document}

Run three times to get

enter image description here

You could also change the indent:

DeclareTOCStyleEntry[dynnumwidth,indent=0pt]{tocline}{table}

enter image description here

But if you need dynnumwidth,indent=0pt for both figures and tables

DeclareTOCStyleEntries[dynnumwidth,indent=0pt]{tocline}{figure,table}

you could also use class option listof=flat:

documentclass[listof=flat]{scrreprt}
usepackage[USenglish]{babel}
usepackage{showframe}% to show the page layout
usepackage{blindtext}% only for dummy text

begin{document}
listoftables
chapter{Introduction}
renewcommand{thetable}{Alph{section}.arabic{subsection}.arabic{table}}
section{Section}
subsection{Subsection}
captionof{table}{This is test table thetable}
setcounter{table}{9}
captionof{table}{This is test table thetable}
captionof{table}{blindtext}
end{document}

Run three times to get

enter image description here

Correct answer by esdd on May 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP