2

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
    \@whilenum\value{table}<10\do{%
        \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?

2
  • 2
    Just out of curiosity: Why do you use \Alph{section} in the definition of \thetable even though section numbers use arabic numerals?
    – Mico
    Aug 13, 2020 at 5:03
  • Thanks, I fixed that in the above example, but for the answer it should not make a difference.
    – EtoAls
    Aug 13, 2020 at 15:21

1 Answer 1

1

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

3
  • thank you exactly what I needed. Did not know this was included in koma script. Just one question: What is dynnumwidth? The manual doesn't say much about it, and you use it for the width.
    – EtoAls
    Aug 13, 2020 at 14:44
  • 1
    dynnumwidth ensures that there is enough space for the numbers: if the value of numwidth (fixed number width) is to low for the widest number plus numsep (minimum space between number and text) than the width of the widest number plus \numsep is used as number width for all entries of this type.
    – esdd
    Aug 13, 2020 at 15:36
  • ah very helpful indeed, thanks for the explanation.
    – EtoAls
    Aug 13, 2020 at 15:39

You must log in to answer this question.

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