章节标题与编号在同一行

章节标题与编号在同一行

我在用:

\usepackage{titlesec}
\titleformat{\chapter}[hang]{\normalfont\huge\bfseries}{\chaptertitlename~\thechapter:}{0.5 em}{}

...但它不会将文本移动到与“第 XXX 章:”相同的行

其他软件包会干扰这个吗?我加载了不少软件包:

\usepackage[inner=1.125in, outer=1in, top=1in, bottom=1in]{geometry}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{array}
\usepackage{placeins}
\usepackage{cite}
\usepackage{wrapfig}
\usepackage[etex]{adjustbox}
\usepackage{mwe}
\usepackage{index}
\usepackage[table]{xcolor}
\usepackage{blindtext}
\usepackage[english]{babel}
\usepackage[math]{mathspec}
\usepackage{fontspec,xltxtra,xunicode}

答案1

\documentclass[12pt, bindingoffset=0.5in]{book}
\usepackage[inner=1.125in, outer=1in, top=1in, bottom=1in]{geometry}  
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{array}
\usepackage{placeins}
\usepackage{cite}
\usepackage[etex]{adjustbox}
\usepackage{mwe}
\usepackage{wrapfig}
\usepackage{index}
\usepackage[table]{xcolor}
\definecolor{darkblue}{rgb}{0.0, 0.0, 0.55}
\definecolor{darkolivegreen}{rgb}{0.33, 0.42, 0.18}

\usepackage{titlesec}
\titleformat{\chapter}[block]{\normalfont\huge\bfseries}{\chaptertitlename~\thechapter:}{0.5 em}{}

\usepackage{blindtext}
\usepackage[english]{babel}

\usepackage[math]{mathspec}

\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{DTL Valiance TPRO} 
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{DTL Caspari TOT Medium}
\setmonofont[Scale=MatchLowercase]{Andale Mono}
\setmathsfont(Digits,Latin,Greek)[Numbers={Lining,Proportional}]{DTL Valiance TPRO}
\titleformat{\chapter}[display]
  {\normalfont\sffamily\huge\bfseries\color{darkolivegreen}}
  {\chaptertitlename\ \thechapter}{8pt}{\Huge}
\titleformat{\section}
  {\normalfont\sffamily\Large\bfseries\color{darkblue}}
  {\thesection}{1em}{}


\title{\textsf{This is the title}}
\author{John Doe}
\date{}
\begin{document}
\chapter{This is the first chapter}
This is text for the first chapter
\end{document}

相关内容