非法計量單位所有章節 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}

相關內容