我想删除目录中的\section
、\subsection
和的空间\subsubsection
。
这是我的代码:
\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index, intoc]
\begin{document}
\tableofcontents
\chapter{chapter}
\section{Introduction}
In this example several keywords\index{keywords} will be
used which are important and deserve to appear in the
Index\index{Index}.
\subsection{subsection}
Terms like generate\index{generate} and some\index{others}
will also show up. Terms in the index can also be
nested \index{Index!nested}
\clearpage
\section{Second section}
This second section\index{section} may include some special
word, and expand the ones already used\index{keywords!used}.
\printindex
\end{document}
答案1
使用tocloft
,这些长度由包括(for )、(for )和(for )的\cftXindent
其中之一管理:X
chap
\chapter
sec
\section
subsec
\subsection
\documentclass{book}
\usepackage{lipsum}
\usepackage{tocloft}
\setlength{\cftsecindent}{0pt}% Remove indent for \section
\setlength{\cftsubsecindent}{0pt}% Remove indent for \subsection
% \setlength{\cftsubsubsecindent}{0pt}% Remove indent for \subsubsection
\begin{document}
\tableofcontents
\chapter{A chapter}
\section{First section}\lipsum[1-5]
\subsection{A subsection}\lipsum[6-10]
\section{Second section}\lipsum[11-15]
\end{document}
答案2
解决方案如下titletoc
:
\documentclass{book}
\usepackage[showframe]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index, intoc]
\usepackage{titletoc}
\contentsmargin{0.2pt}
\titlecontents{section}
[2.5em]
{\vspace*{\baselineskip}\mdseries}
{\contentslabel[\thecontentslabel]{2.5em}}
{}
{\hfill\thecontentspage}
\titlecontents{subsection}
[2.5em]
{\vspace*{\baselineskip}\mdseries}
{\contentslabel[\thecontentslabel]{2.5em}}
{}
{\hfill\thecontentspage}
[]
\begin{document}
\tableofcontents
\chapter{chapter}
\section{Introduction}
In this example several keywords\index{keywords} will be
used which are important and deserve to appear in the
Index\index{Index}.
\subsection{subsection}
Terms like generate\index{generate} and some\index{others}
will also show up. Terms in the index can also be
nested \index{Index!nested}
\clearpage
\section{Second section}
This second section\index{section} may include some special
word, and expand the ones already used\index{keywords!used}.
\printindex
\end{document}