utpvW通常,做这类章节样式都会用到titlesec包,这个包用起来也很简单,命令格式如下

\titleformat{命令}[形式]{格式}{标题头定义}{间距}{前命令}[后命令]

命令就是需要修改的标题命令,如\chapter, \section等 形式是titlesec包定义好的,主要有如下几个hang  这是默认参数,即标题头与标题内容是放在同一行的。 block  是将标题放在一个小页环境中,对于居中的标题或者带有特殊命令的标题非常有帮助,如标题中有插图。 display 是将标题编号和标题内容放在不同的段落。 runin  是将标题放在段落里。 leftmargin  是将标题放在左边的边注空白里。 rightmargin  是将标题放在右边的边注空白里。 wrap 是将标题放在左边,并且第一个段落对它进行绕排。格式 是对标题进行字体或者内容的格式化,如加粗,字号更改等等。 标题头定义  是定义标题的编号的部分,若是空白的话,将没有标题头。 间距  指的是标题编号与标题内容之间的间距。 前命令 是在排版这一个标题前所执行的命令。 后命令 是在排版这一个标题后执行的命令。 下面我们看看上述例子的实现代码如下

\documentclass{book}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage[dotinlabels]{titletoc}

% chapter tiltes formatting
\titleformat{\chapter}[display]
  {\normalfont\sffamily\bfseries\LARGE}
  {\renewcommand{\thechapter}{\Roman{chapter}}\hspace*{0.5em}\colorbox{black}{%
    \parbox[c][1.2cm][c]{1cm}{%
      \centering\textcolor{white}  {\Huge\thechapter}}}}
  {-1ex}
  {\titlerule\vspace{.7ex}\filleft\MakeUppercase{#1}}
  [\vspace{.2ex}\titlerule]
% chapter tiltes spacing
\titlespacing*{\chapter}{0pt}{50pt}{80pt}

% section tiltes formatting
\titleformat{\section}
  {\normalfont\Large\bfseries}{\MySecSquare\ \thesection}{1em}{#1}
\titleformat{name=\section,numberless}
  {\normalfont\Large\bfseries}{\MySecSquare}{1em}{#1}

% formatting for chapter entries in ToC  
\titlecontents{chapter}
  [1.5em]{}
  {\sffamily\bfseries\contentslabel{1.5em}}
  {\hspace*{-1.5em}}
  {\hfill\sffamily\bfseries\contentspage}
% formatting for section entries in ToC  
\titlecontents{section}
  [3.8em]{}
  {\sffamily\contentslabel{2.3em}}
  {\hspace*{-2.3em}}
  {\titlerule*[1pc]{.}\sffamily\contentspage}

% Square to be used in itemize
\newcommand\MySquare{%
  \leavevmode\hbox to 1.2ex{\hss\vrule height .9ex width .7ex depth -.2ex\hss}}
% Square to be used in section titles
\newcommand\MySecSquare{%
  \leavevmode\hbox to 1.2ex{\hss\vrule height 1.3ex width 1.1ex depth -.2ex\hss}}

% First level of itemize uses a square
\renewcommand\labelitemi{\MySquare}

\begin{document}

\tableofcontents

\chapter{Test Chapter One}
\section{Test Section One One}
\begin{itemize}
\item First item.
\item Second item.
\item Third item.
\end{itemize}
\section{Test Section One Two}
\chapter{Test Chapter Two}
\chapter{Test Chapter Three}

\end{document}
选自:http://tex.stackexchange.com/questions/66559/book-layout-contents-chapter-section

点赞(0)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部