代码赏析:changepage包是非常常用的,作为判断页面奇数或者偶数非常简洁,lipsum包用于生成随机文本。前面的几个包这里不再详细表述。可参看:arsclassica
\documentclass[headinclude,footinclude,openany]{scrbook} \usepackage[eulerchapternumbers,pdfspacing]{classicthesis} \usepackage{arsclassica} \usepackage{tikz} \usepackage{changepage} \usepackage{lipsum}% just to generate text for the example \strictpagecheck
下面看章节的具体设计代码如下:
\titleformat{\chapter}[block]% {\normalfont\Large\sffamily}% {{\color{halfgray}\chapterNumber\thechapter% \hspace{10pt}\vline} }{10pt}% {\spacedallcaps}[\chapterdecoration]
这是典型的titlesec的设计代码,我们可以看到其命令的最后都执行了一个\chapterdecoration命令,下面看看这个命令是如何定义的:
\definecolor{halfgray}{gray}{0.55}%定义所需颜色 \newcommand\anglei{-45}%定义角度 \newcommand\angleii{45} \newcommand\angleiii{225} \newcommand\angleiv{135} %绘制版面镶边代码 \newcommand\chapterdecoration{% \begin{tikzpicture}[remember picture,overlay,shorten >= -10pt] \coordinate (aux1) at ([yshift=-15pt]current page.north east); \coordinate (aux2) at ([yshift=-410pt]current page.north east); \coordinate (aux3) at ([xshift=-4.5cm]current page.north east); \coordinate (aux4) at ([yshift=-150pt]current page.north east); \checkoddpage \ifoddpage \else \coordinate (aux1) at ([yshift=-15pt]current page.north west); \coordinate (aux2) at ([yshift=-410pt]current page.north west); \coordinate (aux3) at ([xshift=4.5cm]current page.north west); \coordinate (aux4) at ([yshift=-150pt]current page.north west); \renewcommand\anglei{-135} \renewcommand\angleii{135} \renewcommand\angleiii{-45} \renewcommand\angleiv{45} \fi \begin{scope}[halfgray!40,line width=12pt,rounded corners=12pt] \draw (aux1) -- coordinate (a) ++(\angleiii:5) -- ++(\anglei:5.1) coordinate (b); \draw[shorten <= -10pt] (aux3) -- (a) -- (aux1); \draw[opacity=0.6,halfgray,shorten <= -10pt] (b) -- ++(\angleiii:2.2) -- ++(\anglei:2.2); \end{scope} \draw[halfgray,line width=8pt,rounded corners=8pt,shorten <= -10pt] (aux4) -- ++(\angleiii:0.8) -- ++(\anglei:0.8); \begin{scope}[halfgray!70,line width=6pt,rounded corners=8pt] \draw[shorten <= -10pt] (aux2) -- ++(\angleiii:3) coordinate[pos=0.45] (c) -- ++(\anglei:3.1); \draw (aux2) -- (c) -- ++(\angleiv:2.5) -- ++(\angleii:2.5) -- ++(\anglei:2.5) coordinate[pos=0.3] (d); \draw (d) -- +(\angleii:1); \end{scope} \end{tikzpicture}% }
如上是较为常见的pgf绘制方式,注意代码中做了奇数页和偶数页的区隔。其效果图如上。
发表评论 取消回复