用 titletoc 和缩进指向目录

用 titletoc 和缩进指向目录

如果有人能教我如何在目录中的章节编号后面添加一个点,那就太好了。我使用 titletoc 包。

此外,我对缩进还有两个问题。我怎样才能在章节标题后的第一行获得缩进?我怎样才能(全局地)定义两个段落之间的空格(而不丢失缩进)?

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{titlesec}
\titleformat{\section}{\large\scshape}{\thesection.}{0.5em}{}
\usepackage{titletoc}
\titlecontents{section}[1.5em]{\large}{\contentslabel{1.5em}}{\hspace*{-1.5em}}{\titlerule*[1pc]{.}\contentspage}[\vspace*{0.3em}]
\begin{document}
\renewcommand\contentsname{\normalfont\large\textsc{Contents}}
\tableofcontents
\section{The first section}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, 
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, 
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
\section{The second section}
\end{document}

答案1

就是这样:您必须使用 \contentslabel 的可选参数。请注意,您不需要重新定义 \contentsname

 \documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[indentafter]{titlesec}
\titleformat{\section}{\large\scshape}{\thesection.}{0.5em}{}
\usepackage{titletoc}
\titlecontents{section}[1.5em]{\large}{\contentslabel[\thecontentslabel.]{1.5em}}{\hspace*{-1.5em}}{\titlerule*[1pc]{.}\contentspage}[\vspace*{0.3em}]

\begin{document}

    {\titleformat*{\section}{\centering\large\scshape}\tableofcontents}

\section{The first section}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
\section{The second section}

\end{document} 

在此处输入图片描述

相关内容