非法计量单位 全部章节 titlesec

非法计量单位 全部章节 titlesec

我正在尝试配置章节标题的外观。到目前为止,它们看起来符合我的要求。但是,有一些错误。

我的所有都\chapter遇到了这些错误:

Illegal unit of measure (pt inserted). \chapter{Remediation experiment}
Illegal unit of measure (pt inserted). \chapter{Remediation experiment}
Illegal unit of measure (pt inserted). \chapter{Remediation experiment}
Missing number, treated as zero. \chapter{Remediation experiment}
Missing number, treated as zero. \chapter{Remediation experiment}
Missing number, treated as zero. \chapter{Remediation experiment}

这是我的代码

\documentclass[a4paper,12pt]{report}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\Large\raggedleft\bfseries}
{\chaptertitlename\ \thechapter}
{   \vspace{1ex}
    \titlerule[2pt]%
    \vspace{2ex}%
    }{}
\titlespacing*{\chapter} {}{-60pt}{20pt}   %% adjust these numbers

\usepackage{natbib}
\bibliographystyle{apalike}
\usepackage{glossaries}

\setacronymstyle{long-short}

\begin{document}

\title{Proposal for PhD project}
\author{XXX}
\maketitle
\newpage

\pagenumbering{roman}
\tableofcontents
\newpage
\pagenumbering{arabic}

\chapter{Introduction}

答案1

  1. 该命令的第五个参数titleformat必须是距离,而不是某些乳胶命令
  2. 命令的第二个参数\titlespacing不能为空

\documentclass[a4paper,12pt]{report}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\Large\raggedleft\bfseries}
{\chaptertitlename\ \thechapter}
{1ex}
{ \titlerule[2pt]%
    \vspace{2ex}%
    }
\titlespacing*{\chapter} {0pt}{-60pt}{20pt}   %% adjust these numbers

\usepackage{natbib}
\bibliographystyle{apalike}
\usepackage{glossaries}

\setacronymstyle{long-short}

\begin{document}

\title{Proposal for PhD project}
\author{XXX}
\maketitle
\newpage

\pagenumbering{roman}
\tableofcontents
\newpage
\pagenumbering{arabic}

\chapter{Introduction}

\end{document}

相关内容