add tag
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} 
 
```
![image.png](/image?hash=65f38a60322f30833c74e54a0fde7c813b9870dd5f8819a2525db2b1b033c284)



![image.png](/image?hash=0d82cc0aef66a7d14ab7039e81a183a9f67e7c349dc49fc7c14156b7734d96a0)

at header

![image.png](/image?hash=fecaf72889d58e2544cbff0530a4ee5653470c456ea3bcc3327becf61dba8fbe)
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}  
```

![Screenshot 2024-11-23 at 13.29.38.png](/image?hash=0356f43d7df1c61fdfbc307c3ebd3b29b33d6d000e566dcbed84eb95e6685218)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.