# margins or line breaks in koma-script table of content

Entries in my KOMA-script TOC spread too close from the page numbers:

One solution is to use a short title and insert in it a line-break, but this is not an acceptable solution.

I am trying to modify the tocrmarge. Here are my attempts, but all compile with errors:

\makeatletter
% one and one only of the following
\renewcommand*{\settocfeature}{tocrmarge}{10em}
\renewcommand*\l@tocrmarge}{10em}
\renewcommand*{\settocfeature}{\setlength{\@tocrmarge}{10em}}
\makeatother


My understanding of LaTeX is not good enough. I need help to write correctly the command please.

EDIT: add a MWE (not so minimal in the preambul)

\documentclass[english,enlargefirstpage, full]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[paperwidth=148mm,paperheight=210mm]{geometry}
\geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=3cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{-2}
\setcounter{tocdepth}{1}
\usepackage{pifont}
\usepackage{textcomp}
\usepackage{fixltx2e}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}

\makeatletter
\@ifundefined{lettrine}{\usepackage{lettrine}}{}
\@ifundefined{date}{}{\date{}}
\usepackage[english,frenchle]{babel}
\usepackage[nottoc,numbib]{tocbibind}
\renewcommand{\sectfont}{\normalfont\bfseries} %\slshape} %\rmfamily}
\makeatletter
\renewcommand*\l@chapter{\bprot@dottedtocline{1}{1.8em}{3.2em}}
\renewcommand*\l@section{\bprot@dottedtocline{1}{1.8em}{3.2em}}
\renewcommand*\l@subsection{\bprot@dottedtocline{3}{1.8em}{3.2em}}
\makeatother

\frenchspacing
\usepackage{hyphenat}
\hyphenpenalty=3500
\doublehyphendemerits=9000
\finalhyphendemerits=6000

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[babel=true,kerning=french,protrusion=true,expansion=auto,spacing,tracking]{microtype}
\pretolerance=1500
\tolerance=2000
\setlength{\emergencystretch}{2em}

\AtBeginDocument{
\def\labelitemi{\Pisymbol{psy}{42}}
}

\makeatother

\usepackage{babel}
\begin{document}
\title{my book title}
\subtitle{my book subtitle}
\author{\textbf{myself}}
\maketitle
\frontmatter
\chapter{Before}
blublu
\tableofcontents{}
\newpage{}\mainmatter
\part{PROLOG}
\chapter{\emph{chapter 1}}
blabla
\chapter{\emph{chapter 2 title is very long and should look uggly}}
bloblo
\end{document}


And its result (not as uggly as in my real document):

EDIT: Here is the successful build log (in a pastbin, since otherwise I exceed the Stack Exchange 30,000 characters body limit.

• Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 May 17 '14 at 9:26
• I would rather say, that for some reason your entry name is too long. Did you consider a short entry for the toc such as \section[shorttitle]{long title}? – user31729 May 17 '14 at 9:27
• No, the title cannot be shorten. – lalebarde May 17 '14 at 10:00
• Your example does not compile – user31729 May 17 '14 at 18:45
• I have added the successful build log in the OP. I will try to modify the MWE to be really minimal, hoping it will help. Possibly you don't have the french stuff in your setup ? – lalebarde May 18 '14 at 6:37

[...]
\renewcommand*\l@subsection{\bprot@dottedtocline{3}{1.8em}{3.2em}}
\renewcommand*\@pnumwidth{3em}%%%%%%%%%%%%%%%  the width of the page number
\makeatother
[...]


Your preamble looks a bit weird ...

• Thanks Herbert ! For the weirdness of the preambul, I do agree with you. I am considering using texmaker instead of LyX, what will give me full control on things. – lalebarde May 19 '14 at 7:18

I have solved this with one of the two following solutions:

Either:

\renewcommand*\@pnumwidth{2em}


Or:

\renewcommand*\@tocrmarg{3em}