精致的章节样式
如何制作一个这样的小结样式的标签,如下图:
源代码如下:
\documentclass{article} \usepackage[a5paper,vmargin=2cm]{geometry} \usepackage{background} \usepackage{etoolbox} \usepackage{totcount} \usepackage{lipsum} % to have access to the total number of sections \regtotcounter{section} % every section starts on a new page \pretocmd{\section}{\clearpage}{}{} % auxiliary lengths for the height of the frame and the width of each tab \newlength\mylen \newlength\mylena % style for the section tabs \tikzset{tab/.style={ text width=\mylena,anchor=south, draw=gray,thick,rectangle,rounded corners=12pt,rotate=270, align=center,text height=20pt, text depth=25pt,inner sep=0pt,fill=gray!20, yshift=-18pt,font=\sffamily\LARGE}} % style for the current section tab \tikzset{selectedtab/.style={tab,color=white,fill=gray!90}} % the page number is showed in the background material \pagestyle{empty} \AtBeginDocument{ % calculation of the width for each tab \setlength\mylen{\dimexpr\textheight+2cm\relax} \ifnum\totvalue{section}>0 \setlength\mylena{\dimexpr\mylen/\totvalue{section}\relax} \fi % the main part; as background material we place the border, % the section (current and other) tabs and the page number \SetBgScale{1} \SetBgColor{black} \SetBgAngle{0} \SetBgOpacity{1} \SetBgContents{ \begin{tikzpicture}[remember picture, overlay] \node[inner sep=0pt,text width=\the\dimexpr\textwidth+1.5cm\relax] at (current page.center) (border) {\rule{0pt}{\dimexpr\textheight+2cm\relax}}; \foreach \valsection in {0,...,\numexpr\totvalue{section}-1\relax} { \node[\ifnum\thesection<\numexpr\valsection+1\relax tab\else \ifnum\thesection>\numexpr\valsection+1\relax tab\else selectedtab\fi\fi,xshift=(0.5+\valsection)*\mylena] at (border.north east) (tab-\valsection) {Section \the\numexpr\valsection+1\relax}; } \node[draw=gray,line width=2pt,rectangle,rounded corners=10pt,inner sep=0pt, text width=\the\dimexpr\textwidth+1.5cm\relax,fill=white] at (current page.center) {\rule{0pt}{\dimexpr\textheight+2cm\relax}}; \node[font=\LARGE\sffamily,fill=white] at (border.south) {\makebox[3em][c]{\thepage}}; \end{tikzpicture}} } \begin{document} \section{Test Section One} \lipsum[1-3] \section{Test Section Two} \lipsum[1-3] \section{Test Section Three} \lipsum[1-3] \section{Test Section Four} \lipsum[2] \end{document}
选自:http://tex.stackexchange.com/questions/75637/how-to-print-section-titles-like-tab-list
精致的章节样式
在TeX使用中,很多时候想别出心裁地设计属于自己的版面或者文章样式,尤其是用TeX来设计版面和样式,做起来非所见所得,对于设计来说有了更高要求,需要我们有较多绘图和版面的知识。
如下几个样式来自网络供大家参考:选自:http://web.slzm.de/blog/latex/schone-kapiteltitelseiten-in-latex/
效果图:
代码设计:
\documentclass{scrbook} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[ngerman]{babel} \usepackage {xcolor} \usepackage{blindtext} \usepackage{fix-cm} \usepackage{titlesec} \usepackage{tikz} % Style 2, 3, 4 \usetikzlibrary{calc} % 2, 3, 4 \usetikzlibrary{decorations,decorations.shapes,shapes} % 3 % Style 1 %\renewcommand{\thechapter}{\Roman{chapter}} \titleformat{\chapter}[display] {\bfseries\Large} { %\Huge\textsc{\chaptertitlename} \hfill\fontsize{120}{70}\selectfont\color{lightgray}\textbf{\thechapter}} {-2ex} {\filleft\fontsize{50}{70}\selectfont\scshape} [\vspace{0ex}] % Style 2 \titleformat{\chapter}[display] {\bfseries\Large} {\hfill \tikz[remember picture] \node[] (nr) {\fontsize{120}{70}\selectfont\color{lightgray}\textbf{\thechapter}}; \begin{tikzpicture}[overlay,remember picture] \coordinate (leftborder) at ($(nr)-(100,0)$); \coordinate (left) at ($(nr.west)-(1.5,0)$); \draw[line width=2em] ($(nr.north east)+(0,1)$) -- ($(nr.north west)+(0,1)$) -- (left) -- (leftborder); \end{tikzpicture}} {-2ex} {\filleft\fontsize{50}{70}\selectfont\scshape} [\vspace{0ex}] % Style 3 \titleformat{\chapter}[display] {\bfseries\Large} {\hfill \tikz[remember picture] \node[] (nr) {\fontsize{120}{70}\selectfont\color{lightgray}\textbf{\thechapter}}; \begin{tikzpicture}[overlay,remember picture] \coordinate (leftborder) at ($(nr)-(100,0)$); \coordinate (left) at ($(nr.west)-(1.5,0)$); \draw[decoration={shape backgrounds,shape size=.5cm,shape=signal},signal from=west, signal to=east,decorate, draw=red!50!black, fill=red!50, decoration={shape sep=.5cm},line join=round] (leftborder) -- (left); \end{tikzpicture}} {-2ex} {\filleft\fontsize{50}{70}\selectfont\scshape} [\vspace{0ex}] % Style 4 \titleformat{\chapter}[display] {\bfseries\Large} {\hfill \tikz[remember picture] \node[] (nr) {\fontsize{120}{70}\selectfont\color{blue!50!black}\textbf{\thechapter}~}; \begin{tikzpicture}[overlay,remember picture] \coordinate (leftborder) at ($(nr)-(100,0)$); \coordinate (leftborderhigh) at ($(nr.north west)-(100,0)$); \coordinate (leftborderlow) at ($(nr.south west)-(100,0)$); \coordinate (left) at ($(nr.west)-(1.5,0)$); \fill[blue!20!white] (leftborderhigh) -- ($(nr.north west)+(0,0.5)$) -- (left) -- (leftborder) -- cycle; \fill[blue!20!white] (leftborderlow) -- ($(nr.south west)-(0,0.5)$) -- (left) -- (leftborder) -- cycle; \draw[blue!50!black,line width=0.1em,line join=round] (left) -- ($(nr.south west)-(0,0.5)$) -- ($(nr.south east)-(0,0.5)$) -- ($(nr.north east)+(0,0.5)$) -- ($(nr.north west)+(0,0.5)$) -- (left) -- (leftborder); \end{tikzpicture}} {-2ex} {\filleft\fontsize{50}{70}\selectfont\scshape} [\vspace{0ex}] % ========================== % DOKUMENT % ========================== \begin{document} \chapter{Einleitung} \blindtext \chapter{Hauptteil} \blindtext \chapter{Schluss} \blindtext \end{document}
LaTeX手工制作漂亮的章节样式
LaTeX的默认样式,很多用户觉得太朴实了,总想让自己的样式有些新意。下面便是一个很好的例子,这个样式在memoir class中也有,稍有差异。
效果图:
代码如下:
\documentclass[parskip,headsepline, headtopline, % footsepline, oneside, 12pt, headings=small]{scrbook} \usepackage[ngerman, english]{babel} \usepackage[utf8]{inputenc} \usepackage{color} \usepackage{pdfpages} % To include other PDFs % To insert dummy text \usepackage{blindtext} % Provide a command to include pretty quotes \usepackage{ragged2e} %justify dictum \renewcommand*{\dictumwidth}{.5\textwidth} \newcommand{\setChapterQuote}[3]{\setchapterpreamble[o]{% \dictum[#2 \emph{#3}]{\justifying {#1}}}} %Set font to times \usepackage{txfonts} % Define own Chapter style % Pretty chapter pages %------------------------------------------ \definecolor{nicered}{rgb}{.647,.129,.149} \usepackage{soul} \makeatletter \newsavebox{\feline@chapter} \newcommand\feline@chapter@marker[1][4cm]{% \sbox\feline@chapter{% \resizebox{!}{#1}{\fboxsep=1pt% \colorbox{nicered}{\color{white}\bfseries\sffamily\thechapter}% }}% \rotatebox{90}{% \resizebox{% \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}% {!}{\scshape\so\@chapapp}}\quad% \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}% } \newcommand\feline@chm[1][4cm]{% \sbox\feline@chapter{\feline@chapter@marker[#1]}% \makebox[0pt][l]{% aka \rlap \makebox[1cm][r]{\usebox\feline@chapter}% }} \renewcommand*{\chapterformat}{% \hspace{\leftmargin} \feline@chm[2.5cm] % Height of the colored box \hspace{2cm} } \makeatother \begin{document} % Chapter A \setChapterQuote{A thought is an idea in transit.}{Pythagoras}{582 B.C. - 497 B.C.} \chapter{First chapter} \blindtext[5] % Chapter B \setChapterQuote{Much wisdom often goes with fewest words.}{Sophocles}{496 B.C. - 406 B.C.} \chapter{Second chapter} \blindtext[5] \end{document}