我当前的目录如下所示:
以下是代码示例:
\documentclass[]{article}
\usepackage[latin1]{inputenc}
\usepackage{tocloft} %pacote para editar ToC
\usepackage{titlesec} %pacote para mudar formatacao de secoes
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\titleformat*{\section}{\bfseries}
\titleformat*{\subsection}{}
\titleformat*{\subsubsection}{\bfseries}
\titleformat*{\paragraph}{\bfseries}
\titleformat*{\subparagraph}{}
\renewcommand{\contentsname}{\hfill\bfseries SUM\'{A}RIO\hfill} %centralizes toc title
\renewcommand{\cftaftertoctitle}{\hfill} %centralizes toc title
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} %places dots on sections lines as well
\begin{document}
\tableofcontents
\clearpage
\section{INTRODU\c{C}\~{A}O}
\subsection{SISTEMAS DE CHUTE}
\subsubsection{\bfseries chucrute}
\paragraph{\bfseries \textit{ablidebob}}
\subparagraph{\textit{abebob}}
\end{document}
但是,我的大学要求目录中的所有内容都左对齐,如下所示:
但我就是做不到。有什么建议吗?
答案1
宏\cftsetindents{<X>}{<left margin>}{<title indent>}
就是您所需要的,其中<X>
是分段单元名称。在所有情况下,我都将左缩进设置为 0pt,将标题缩进设置为 4em。
我还设置\cftdotsep
让点更近,就像 OP 的例子一样。最后我用来\cftsetpnumwidth{1em}
减少点和页码之间的距离。如果你的页数达到 3 位数,可能需要更改它。
\documentclass[]{article}
\usepackage[latin1]{inputenc}
\usepackage{tocloft} %pacote para editar ToC
\usepackage{titlesec} %pacote para mudar formatacao de secoes
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\titleformat*{\section}{\bfseries}
\titleformat*{\subsection}{}
\titleformat*{\subsubsection}{\bfseries}
\titleformat*{\paragraph}{\bfseries}
\titleformat*{\subparagraph}{}
\renewcommand{\contentsname}{\hfill\bfseries SUM\'{A}RIO\hfill} %centralizes toc title
\renewcommand{\cftaftertoctitle}{\hfill} %centralizes toc title
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} %places dots on sections lines as well
\cftsetindents{section}{0pt}{4em}
\cftsetindents{subsection}{0pt}{4em}
\cftsetindents{subsubsection}{0pt}{4em}
\cftsetindents{paragraph}{0pt}{4em}
\cftsetindents{subparagraph}{0pt}{4em}
\def\cftdotsep{1}
\cftsetpnumwidth{1em}
\begin{document}
\tableofcontents
\clearpage
\section{INTRODU\c{C}\~{A}O}
\subsection{SISTEMAS DE CHUTE}
\subsubsection{\bfseries chucrute}
\paragraph{\bfseries \textit{ablidebob}}
\subparagraph{\textit{abebob}}
\end{document}