\documentclass[11pt, a4paper]{book} \usepackage{geometry} \geometry{% papersize={19.7cm,27cm}, centering, textwidth=380pt, textheight=650pt} \usepackage{fancyhdr} \usepackage{tikz} \usepackage{lipsum}% just to generate text automatically \newlength\mylen \setlength\mylen{\dimexpr1in+\hoffset+18pt\relax} \setlength\headheight{13.6pt} \fancyhfoffset[L,R]{\dimexpr1in+\hoffset+18pt\relax} \fancyhf{} \fancyhead[LE]{% \begin{tikzpicture}[overlay] \fill[lightgray] (0,-4pt) rectangle (\mylen,\headheight+1in); \node[anchor=east,font=\sffamily] at (\mylen,0) {\strut\chaptername~\thechapter}; \node[anchor=west,font=\slshape\sffamily] at (\mylen,0) {\strut\leftmark}; \end{tikzpicture}% } \fancyhead[RE]{% \begin{tikzpicture}[overlay] \fill[lightgray] (0,-4pt) rectangle (\mylen,\headheight+1in); \node[anchor=east,font=\slshape\sffamily] at (-90pt,0) {\strut Author}; \end{tikzpicture}% } \fancyhead[RO]{% \begin{tikzpicture}[overlay] \fill[lightgray] (-\mylen,-4pt) rectangle (0,\headheight+1in); \node[anchor=east,font=\slshape\sffamily] at (-\mylen,0) {\strut\leftmark}; \node[anchor=west,font=\sffamily] at (-\mylen,0) {\strut\chaptername~\thechapter}; \end{tikzpicture}% } \fancyhead[LO]{% \begin{tikzpicture}[overlay] \node[anchor=west,font=\slshape\sffamily] at (\mylen,0) {\rightmark}; \end{tikzpicture}% } \fancyfoot[C]{% \begin{tikzpicture}[overlay] \fill[lightgray] (-30pt,0) rectangle (30pt,-30pt); \node[anchor=center,font=\bfseries\sffamily] at (0,-15pt) {\thepage}; \draw (-\textwidth,0) -- (\textwidth,0); \end{tikzpicture}% } \parindent=0pt \pagestyle{fancy} \renewcommand\chaptermark[1]{\markboth{#1}{}} \renewcommand\sectionmark[1]{\markright{\thesection\ #1}} \begin{document} \chapter{Title of chapter} \section{Title of a Section} \lipsum[1-30] \end{document}
选自:http://tex.stackexchange.com/questions/119772/a-tikzpicture-on-pages-without-chapter-and-index
发表评论 取消回复