JohnPaul
I have a long document (in Vietnamese) with many \subsections. I have a problem like this image. I have two questions:
1. How can I set a space biiger at \section and \subsection in tableofcontent;
2. How can I set lowercase instead Uppercase, e.g Contents instead CONTENTS
```
\documentclass[12pt,a4paper]{book}
\usepackage{fouriernc}
\usepackage[left=2cm, right=2cm, top=2cm, bottom=2cm]{geometry}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{xurl}
\usepackage{fancyhdr}
\usepackage{marvosym}
\usepackage{siunitx}
%\usepackage{setspace}
\linespread{1.3}
\usepackage{lipsum}
\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{\chaptername\space}
\setlength{\cftchapnumwidth}{\widthof{\textbf{Appendix~999~}}}
\makeatletter
\g@addto@macro\appendix{%
\addtocontents{toc}{%
\protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}%
}%
}
\makeatother
\sisetup{output-decimal-marker={,}}
\sisetup{group-minimum-digits=4}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\itshape\nouppercase{\rightmark}}
\fancyhead[RE]{\itshape\nouppercase{\leftmark}}
\renewcommand{\chaptermark}[1]%
{\markboth{{\it \chaptername\,\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]%
{\markright{\it \thesection.\ #1}}
\lhead[\fancyplain{}{\thepage}]%
{\fancyplain{}{\rightmark}}
\rhead[\fancyplain{}{\leftmark}]%
{\fancyplain{}{\thepage}}
\cfoot{}
\usepackage{hyperref}
\hypersetup{pdftex,unicode,colorlinks=true,allcolors=blue,bookmarksnumbered,psdextra}
\begin{document}
\tableofcontents
\chapter{Test}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\end{document}
```


at header

Top Answer
samcarter
1. you can use `\setlength{\cftsecnumwidth}{...}` and `\setlength{\cftsubsecnumwidth}{...}` to set the space for the section and subsection numbers in the toc
2. you can redefine `\renewcommand{\cftmarktoc}{\@mkboth{\contentsname}{\contentsname}}` to change the contents name in the header
```
\documentclass[12pt,a4paper]{book}
\usepackage{fouriernc}
\usepackage[left=2cm, right=2cm, top=2cm, bottom=2cm]{geometry}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{xurl}
\usepackage{fancyhdr}
\usepackage{marvosym}
\usepackage{siunitx}
%\usepackage{setspace}
\linespread{1.3}
\usepackage{lipsum}
\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{\chaptername\space}
\setlength{\cftchapnumwidth}{\widthof{\textbf{Appendix~999~}}}
\setlength{\cftsecnumwidth}{3em}
\setlength{\cftsubsecnumwidth}{5.5em}
\makeatletter
\renewcommand{\cftmarktoc}{\@mkboth{\contentsname}{\contentsname}}
\g@addto@macro\appendix{%
\addtocontents{toc}{%
\protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}%
}%
}
\makeatother
\sisetup{output-decimal-marker={,}}
\sisetup{group-minimum-digits=4}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\itshape\nouppercase{\rightmark}}
\fancyhead[RE]{\itshape\nouppercase{\leftmark}}
\renewcommand{\chaptermark}[1]%
{\markboth{{\it \chaptername\,\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]%
{\markright{\it \thesection.\ #1}}
\lhead[\fancyplain{}{\thepage}]%
{\fancyplain{}{\rightmark}}
\rhead[\fancyplain{}{\leftmark}]%
{\fancyplain{}{\thepage}}
\cfoot{}
\usepackage{hyperref}
\hypersetup{colorlinks=true,allcolors=blue,bookmarksnumbered}
\setlength{\headheight}{15pt}
\begin{document}
\tableofcontents
\chapter{Test}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\section{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\subsection{Something}
\end{document}
```
