latex标记html样式,LaTeX技巧718:设计章节样式示例

5168abc5b769d73aae051ae5a96245a9.png通常,做这类章节样式都会用到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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值