titlesec 似乎不起作用(编号)

titlesec 似乎不起作用(编号)

我想写一个关于这个book课程的文档。我从每个章节标题中删除了“章节”一词。为了添加罗马章节编号,我使用了titlesec。但自从我安装了新的 Linux 发行版(Mint 17.3 -> Mint 18.3)后,它似乎不再起作用了。我使用标准配置的 TeXStudio(编译器:)pdflatex

在最小的工作示例中,您可以看到章节编号仍然适用于页眉和目录,但不适用于章节标题本身。

\documentclass[11pt,a4paper]{book}

\usepackage                             {dsfont}
\usepackage                             {emptypage}
\usepackage                             {fancyhdr}
\usepackage                             {geometry}
\usepackage[latin1]                     {inputenc}
\usepackage                             {lipsum}
\usepackage                             {lmodern}
\usepackage                             {subfig}
\usepackage                             {titlesec}
\usepackage[nottoc,chapter,numbib]      {tocbibind}
\usepackage[subfigure]                  {tocloft}
\usepackage                             {ucs}

% % % Title configuration % % %

\renewcommand{\thechapter}{\Roman{chapter}}
\setcounter{secnumdepth}{1}
\titleformat{\chapter}[hang]
    {\Huge\bfseries}{\thechapter.\ }{0pt}{}
\titleformat{\section}[hang] 
    {\Large\bfseries}{\thesection\ }{0pt}{}
\titlespacing*{\chapter}{0pt}{-15pt}{10pt}
\titlespacing*{\section}{0pt}{10pt}{5pt}

% % % more changes % % %

\parindent0pt
\geometry{top=20mm, outer=10mm, inner=20mm, bottom=20mm}

% % % Header % % %

\fancypagestyle{plain}{
    \fancyhf{}
    \fancyhead[RE,LO]{\nouppercase{\leftmark}}
    \fancyhead[RO,LE]{\textbf{\thepage}}
}
\setlength{\headheight}{14pt}
\pagestyle{plain}
\renewcommand{\chaptermark}[1]{ \markboth{\thechapter.\ #1}{} }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

%Contents
\setcounter{tocdepth}{1}
\setlength{\cftchapnumwidth}{3em}
\setlength{\cftsecnumwidth}{3em}
\tableofcontents
\newpage

\chapter{Chapter name}
\section{Section name}
\lipsum[1-40]
\end{document}

答案1

这似乎是一个众所周知的错误。解决方案可以在这里找到:

https://bugs.launchpad.net/ubuntu/+source/texlive-extra/+bug/1574052

编辑:

该错误出现在 titlesec 软件包的 2.10.1 版本中,并在几天后得到修复。ubuntu 16.04 存储库中的 texlive 软件包(来自 2015 年)包含具有此版本号的 titlesec 软件包。解决方案是添加以下 ppa,其中包含 2017 年的 texlive 软件包,其中包含带有错误修复的 titlesec 软件包(版本 2.10.2)。

sudo add-apt-repository ppa:jonathonf/texlive-2017
sudo apt-get update

相关内容