平均能量损失
\documentclass{book}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{ifthen}
\usepackage{lipsum}
\pagestyle{plain}
\newif\ifFrame
\Frametrue
% background common settings
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
contents={}
}
% auxiliary counter
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
% the list of colors to be used (add more if needed)
\newcommand\BoxColor{%
\ifcase\thechapshift blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}
% the main command; the mandatory argument sets the color of the vertical box
\newcommand\ChapFrame{%
\AddEverypageHook{%
\ifFrame
\ifthenelse{\isodd{\value{page}}}
{\backgroundsetup{contents={%
\begin{tikzpicture}[overlay,remember picture]
\node[
fill=\BoxColor,
inner sep=0pt,
rectangle,
text width=2cm,
text height=4cm,
align=center,
anchor=north east
]
at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\hspace*{.3cm}%
\parbox[c][1.5cm][t]{3.4cm}{%
\raggedright\textcolor{black}{\scshape\leftmark}}}};
\end{tikzpicture}}}%
}
{\backgroundsetup{contents={%
\begin{tikzpicture}[overlay,remember picture]
\node[
fill=\BoxColor,
inner sep=0pt,
rectangle,
text width=2cm,
text height=4cm,
align=center,
anchor=north west
]
at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\hspace*{.3cm}%
\parbox[c][1.5cm][t]{3.4cm}{%
\raggedright\textcolor{black}{\scshape\leftmark}}}};
\end{tikzpicture}}}
}
\BgMaterial%
\fi%
}%
\stepcounter{chapshift}
}
% redefinition of \chaptermark to contain only the title
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}
\begin{document}
\part{PART I}
\chapter[intro]{Introduction}
\ChapFrame
\lipsum[1-7]
\chapter{Results}
\ChapFrame
\lipsum[1-7]
\cleardoublepage
\setcounter{page}{1}
%\setcounter{chapshift}{0} <<<--- ?
\Framefalse
\thispagestyle{empty}
\part{PART II}
\chapter{Discussion}
\Frametrue
\ChapFrame
\lipsum[1-7]
\chapter{Conclusion}
\Frametrue
\ChapFrame
\lipsum[1-7]
\end{document}
我想\ChapFrame
重置第二部分。从页面右上角开始,因此从位置开始第一部分。或者重置线路。我相信这对于鉴赏家来说可能很容易,但我做不到。
相关 :章节标题位于边缘的旋转垂直框中
答案1
下面的代码行完全按照我想要的方式工作。
\setcounter{chapshift}{-1}