如何在报告类的目录和目录章节号后面添加点

如何在报告类的目录和目录章节号后面添加点

亲爱的,上次收到消息真的很快。我检查了这里和互联网上的一些解决方案,但这些解决方案对我不起作用。我正在放置 MWE

\documentclass[12pt,a4paper,twoside]{report}
\usepackage[top=25mm, bottom=25mm, outer=15mm, inner=35mm]{geometry}

\renewcommand{\baselinestretch}{1.15}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{polski}
\usepackage[polish]{babel}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{fancyhdr}

\titleformat
{\part} 
[display]
{\bfseries \huge \itshape\centering} 
{Część \ \thepart} 
{0.5ex} 
{
    \rule{\textwidth}{0pt}
    \vspace{1ex}
    \centering
} 
[
\vspace{-0.5ex}
\rule{\textwidth}{0pt}
] 

\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}
{\thechapter}{18pt}{\huge}
\titlespacing*{\chapter}{0pt}{50pt}{20pt}

\pagestyle{fancy}
\fancyhf{}


\fancypagestyle{plain}{}
\pagenumbering{arabic}
\rfoot{Strona ~\thepage~} 
\renewcommand{\headrulewidth}{0pt}

\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother

\usepackage{etoolbox}
\makeatletter
\patchcmd\chapter
{\if@openright\cleardoublepage\else\clearpage\fi}
{\par}% Inserting a \par here!
{}{}
\makeatother

\begin{document}
    \tableofcontents
    \part{The Part name}
    ...
    \chapter{The First Chapter name}
    ...
    \chapter{The Second Chapter name}
    ...
    \chapter{The Third Chapter name}
    ...

\end{document}

我想在目录和内容中在章节号后面添加点。有人能帮我解决这个问题吗?

答案1

以下是titlesec及其配套软件包的解决方案titlepstitletoc

\documentclass[12pt, a4paper, twoside, openright]{report}
\usepackage[vmargin=25mm, outer=15mm, inner=35mm, showframe]{geometry}
\usepackage{setspace}
\setstretch{1.15}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{polski}
\usepackage[polish]{babel}
\usepackage[newparttoc, clearempty, explicit, newparttoc]{titlesec}
\usepackage{titletoc}
\usepackage{lipsum}

\titleformat
{\part}
[display]
{\bfseries \huge \itshape\filcenter}
{Część \ \thepart}
{3.5ex}
{#1 }

\titleformat{\chapter}[hang]
{\thispagestyle{empty}\normalfont\huge\bfseries}
{\thechapter.}{18pt}{\huge}
\titlespacing*{\chapter}{0pt}{50pt}{20pt}

\newpagestyle{myplain}{%
\sethead{}{}{}
\setfoot[~Strona ~\thepage][][]{}{}{Strona ~\thepage~}
}

\pagestyle{myplain}

    \titlecontents{chapter}
    [0em] %
    {\bigskip\bfseries\large}
    {\thecontentslabel.\enspace}%\thecontentslabel
    {}
    {\hfill\contentspage}[\smallskip]

\begin{document}

    \tableofcontents
    \part{The Part name}
    \lipsum[1-3]
    \chapter{The First Chapter name}
    \lipsum[4-12]
    \chapter{The Second Chapter name}
    \lipsum[13-24]
    \chapter{The Third Chapter name}
    \lipsum[25-30]

\end{document} 

在此处输入图片描述 在此处输入图片描述

答案2

在 Bernard 给出答案后,我想澄清一下需要做什么才能做出我的问题中描述的更改。我在需要添加的内容旁边添加了注释。

\documentclass[12pt,a4paper,twoside]{report}
\usepackage[top=25mm, bottom=25mm, outer=15mm, inner=35mm]{geometry}

\renewcommand{\baselinestretch}{1.15}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{polski}
\usepackage[polish]{babel}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{fancyhdr}

\titleformat
{\part} 
[display]
{\bfseries \huge \itshape\centering} 
{Część \ \thepart} 
{0.5ex} 
{
    \rule{\textwidth}{0pt}
    \vspace{1ex}
    \centering
} 
[
\vspace{-0.5ex}
\rule{\textwidth}{0pt}
] 

\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}
{\thechapter.}{18pt}{\huge} %%--you had to add dot at the end of thechapter word
\titlespacing*{\chapter}{0pt}{50pt}{20pt}

\pagestyle{fancy}
\fancyhf{}


\fancypagestyle{plain}{}
\pagenumbering{arabic}
\rfoot{Strona ~\thepage~} 
\renewcommand{\headrulewidth}{0pt}

\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother

\usepackage{etoolbox}
\makeatletter
\patchcmd\chapter
{\if@openright\cleardoublepage\else\clearpage\fi}
{\par}
{}{}
\makeatother

%%--you have to put this phrase which formatting the table of content appearance
\titlecontents{chapter}
[0em] 
{\bigskip\bfseries\large}
{\thecontentslabel.\enspace}%\thecontentslabel
{}
{\hfill\contentspage}[\smallskip]


\begin{document}
    \tableofcontents
    \part{The Part name}
    ...
    \chapter{The First Chapter name}
    ...
    \chapter{The Second Chapter name}
    ...
    \chapter{The Third Chapter name}
    ...

\end{document}

相关内容