从帖子中找到的建筑这里由 Gonzalo Medina 开发,我怎样才能使附录部分的标题显示为“附录 A。这是附录 A”,同时仍保持章节缩略图不变。
这是我的代码:
\documentclass{book}
\usepackage[scale=1,angle=0,opacity=1,contents={}]{background}
\usetikzlibrary{calc}
\usepackage{ifthen}
\usepackage{lipsum}
\usetikzlibrary{tikzmark,calc,decorations.pathreplacing}
\pagestyle{plain}
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\newcommand\BoxColor{%
\ifcase\thechapshift blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}
\usepackage{etoolbox,fancyhdr}
\makeatletter
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}}
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage}
\fancyhead[LO]{\rightmark%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
text height=4cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\parbox{4cm}{%
\centering\textcolor{black}{\bf\sffamily\scshape\leftmark}}}};
\end{tikzpicture}}
\fancyhead[RE]{\bf\sffamily\scshape\chaptername~\thechapter. \leftmark%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
text height=4cm,align=center,anchor=north west]
at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\parbox{4cm}{%
\centering\textcolor{black}{\bf\sffamily\scshape\leftmark}}}};
\end{tikzpicture}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\newcommand{\headrulecolor}[1]{\patchcmd{\headrule}{\hrule}{\color{#1}\hrule}{}{}}
%\headrulecolor{blue!70}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
\patchcmd{\@makechapterhead}
{\vskip 40\p@}
{\vskip 40\p@\stepcounter{chapshift}}{}{}
\makeatother
\begin{document}
\part{One}
\chapter[Intro]{Introduction}
\lipsum[1-7]
\section{This is how we do it}
\lipsum[1-7]
\chapter{Results}
\lipsum[1-7]
\chapter{Some Sample Code}
\lipsum[1-7]
\part{Two}
\renewcommand\chaptermark[1]{\markboth{\sffamily\normalsize\bfseries \appendixname~\thechapter}{}}
\appendix
\chapter{This is Appendix A}
\lipsum[1-7]
\chapter{This is Appendix B}
\lipsum[1-7]
\end{document}
答案1
这是你想要的吗?
\documentclass{book}
\usepackage[scale=1,angle=0,opacity=1,contents={}]{background}
\usetikzlibrary{calc}
\usepackage{ifthen}
\usepackage{lipsum}
\usetikzlibrary{tikzmark,calc,decorations.pathreplacing}
\pagestyle{plain}
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\newcommand\BoxColor{%
\ifcase\thechapshift blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}
\usepackage{etoolbox,fancyhdr}
\newcommand{\mymark}{}
\makeatletter
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}}
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage}
\fancyhead[LO]{\rightmark%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
text height=4cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\parbox{4cm}{%
\centering\textcolor{black}{\bf\sffamily\scshape\mymark}}}};
\end{tikzpicture}}
\fancyhead[RE]{\bf\sffamily\scshape\chaptername~\thechapter. \leftmark%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
text height=4cm,align=center,anchor=north west]
at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\parbox{4cm}{%
\centering\textcolor{black}{\bf\sffamily\scshape\mymark}}}};
\end{tikzpicture}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\newcommand{\headrulecolor}[1]{\patchcmd{\headrule}{\hrule}{\color{#1}\hrule}{}{}}
%\headrulecolor{blue!70}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
\patchcmd{\@makechapterhead}
{\vskip 40\p@}
{\vskip 40\p@\stepcounter{chapshift}}{}{}
\makeatother
\renewcommand{\mymark}{\leftmark}
\begin{document}
\part{One}
\chapter[Intro]{Introduction}
\lipsum[1-7]
\section{This is how we do it}
\lipsum[1-7]
\chapter{Results}
\lipsum[1-7]
\chapter{Some Sample Code}
\lipsum[1-7]
\part{Two}
\renewcommand{\chaptername}{Appendix}
\renewcommand{\mymark}{\sffamily\normalsize\bfseries \appendixname~\thechapter}
\appendix
\chapter{This is Appendix A}
\lipsum[1-7]
\chapter{This is Appendix B}
\lipsum[1-7]
\end{document}