用tikz设计一个灰色页眉
页眉页脚的设计前文涉及不多,这里分享一个稍微可变的页眉设计,把tikz嵌入进来进行设计制作,我们可以制作更多变的样式效果出来。
效果图如下:
代码如下:
\documentclass[12pt,twoside]{scrbook} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[ngerman]{babel} \usepackage[table,dvipsnames,svgnames]{xcolor} \usepackage{calc} %Schrift \usepackage{mathptmx,charter,courier} \usepackage[scaled]{helvet} \usepackage{microtype} \usepackage{blindtext} % TikZ-Pakete \usepackage{tikz} \usetikzlibrary{positioning,backgrounds,shapes} % Kopf- und Fußzeile \usepackage[automark]{scrpage2} \clearscrheadings \clearscrplain \tikzset{pagenumber/.style={rectangle,rounded corners=5pt,inner sep=6pt, fill=gray!20,draw=gray!30,line width=0.1em}} \lohead{\begin{tikzpicture}[remember picture,overlay] \begin{pgfonlayer}{background} \draw[fill=gray!10, fill opacity=1.0, draw=none] (-.65\paperwidth,0cm) rectangle (\paperwidth+2cm,2cm); \end{pgfonlayer} \path (current page.north west) node[anchor=west,xshift=1.58cm, yshift=-0.9cm,pagenumber] {\parbox{\widthof{\Large 1111}}{\centering \color{black} \bfseries\Large \thepage}}; \end{tikzpicture}} \rohead{\begin{tikzpicture}[remember picture,overlay] \path (current page.north east) node[anchor=east,xshift=-3.4cm, yshift=-0.9cm] {\color{black}\upshape Beispieldokument}; \end{tikzpicture}} \lehead{\begin{tikzpicture}[remember picture,overlay] \begin{pgfonlayer}{background} \draw[fill=gray!10, fill opacity=1.0, draw=none] (-.65\paperwidth,0cm) rectangle (\paperwidth+2cm,2cm); \end{pgfonlayer} \path (current page.north west) node[anchor=west,xshift=3.4cm, yshift=-1.0cm] {\color{black}\upshape \Large \headmark}; \end{tikzpicture}} \rehead{\begin{tikzpicture}[remember picture,overlay] \path (current page.north east) node[anchor=east,xshift=-1.58cm, yshift=-0.9cm,pagenumber] {\parbox{\widthof{\Large 1111}}{\centering \color{black}\bfseries\Large \thepage}}; \end{tikzpicture}} \setlength{\headsep}{1.1cm} \begin{document} \pagestyle{scrheadings} \chapter{Einleitung} \Blindtext \Blindtext \chapter{Hauptteil} \blindtext \end{document}
选自:http://web.slzm.de/blog/latex/latex-schone-kopfzeilen/#more-345
Tikz设计页眉设计样例分享
效果图:
代码如下:
\documentclass{book} \usepackage[a6paper]{geometry} \usepackage{fancyhdr} \usepackage{tikzpagenodes} \usetikzlibrary{shapes.geometric} \usepackage{lipsum} \pagestyle{fancy} \fancyhf{} \renewcommand\headrulewidth{0pt} \fancyhead[OC]{\begin{tikzpicture}[remember picture,overlay] \node[diamond,draw,font=\small\itshape] at (current page header area.south west) (dia) {\thepage}; \draw[double=white] (dia.east) -- (current page header area.south east); \end{tikzpicture}} \fancyhead[EC]{\begin{tikzpicture}[remember picture,overlay] \node[diamond,draw,font=\small\itshape] at (current page header area.south east) (dia) {\thepage}; \draw[double=white] (dia.west) -- (current page header area.south west); \end{tikzpicture}} \fancyhead[OR]{\small\nouppercase\leftmark} \fancyhead[EL]{\small\nouppercase\rightmark} \begin{document} \chapter{Test chapter} \lipsum[2] \section{Test section} \lipsum[2]\lipsum[2]\lipsum[2]\lipsum[2]\lipsum[2] \end{document}
效果图:
代码如下:
\documentclass{book} \usepackage[a6paper]{geometry} \usepackage{fancyhdr} \usepackage{tikzpagenodes} \usetikzlibrary{shapes.geometric} \usepackage{lipsum} \pagestyle{fancy} \fancyhf{} \renewcommand\headrulewidth{0pt} \fancyhead[OC]{\begin{tikzpicture}[remember picture,overlay] \node[diamond,draw,font=\small\itshape] at (current page header area.south west) (dia) {\thepage}; \draw (dia.3) -- (current page header area.south east|-dia.3); \draw (dia.357) -- ([xshift=-7pt]current page header area.south east|-dia.357); \end{tikzpicture}} \fancyhead[EC]{\begin{tikzpicture}[remember picture,overlay] \node[diamond,draw,font=\small\itshape] at (current page header area.south east) (dia) {\thepage}; \draw (dia.177) -- (current page header area.south west|-dia.177); \draw (dia.183) -- ([xshift=7pt]current page header area.south west|-dia.183); \end{tikzpicture}} \fancyhead[OR]{\small\nouppercase\leftmark} \fancyhead[EL]{\small\nouppercase\rightmark} \begin{document} \chapter{Test chapter} \lipsum[2] \section{Test section} \lipsum[2]\lipsum[2]\lipsum[2]\lipsum[2]\lipsum[2] \end{document}
效果图:
代码如下:
\documentclass{book} \usepackage[a6paper]{geometry}% just for the example \usepackage{fancyhdr} \usepackage{stackengine} \usepackage{graphicx} \usepackage{lipsum}% just to generate text for the example \pagestyle{fancy} \fancyhf{} \renewcommand\headrulewidth{0pt} \fancyhead[OC]{% \def\stackalignment{c}% \topinset{\itshape\thepage}{\scalebox{5}{\(\diamond\)}}{1.5ex}{}% \rule{-.2ex}{0ex}% \def\stackalignment{l}% \stackon[1pt]{\rule[2.8ex]{2.5in}{.1ex}}{\rule{2.55in}{.1ex}}} \fancyhead[EC]{% \def\stackalignment{r}% \stackon[1pt]{\rule[2.8ex]{2.5in}{.1ex}}{\rule{2.55in}{.1ex}}% \rule{-.2ex}{0ex}% \def\stackalignment{c}% \topinset{\itshape\thepage}{\scalebox{5}{\(\diamond\)}}{1.5ex}{}} \begin{document} \lipsum[2]\lipsum[2]\lipsum[2]\lipsum[2] \end{document}