Anonymous 8536
Based on [the answer](https://topanswers.xyz/tex?q=8060),
```
\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}
```
How can I lign like this image?
![Toan.png](/image?hash=8887ffb08f172fd40ff51740949d645e3f14adbd5b3082e46b549584555566a7)
Top Answer
samcarter
You can use `\setlength{\cftsubsecindent}{...}` to change the indentation for subsection entries (the exact value in the example below might need fine-tuning, I just picked it by eye):
```
\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}
\setlength{\cftsubsecindent}{4.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}
\subsection{Something}
\end{document}
```
![Screenshot 2024-11-23 at 17.09.54.png](/image?hash=8a0f5453be02773860d0ea14864c7c3d4cba507e848a1ef8a6affe9ee56df64f)