我正在使用这个 ChapterFrame:章节标题在边缘的旋转垂直框中
您应该先编译三次才能看到边距!
我在前三章下面添加了章节框架…用 \ChapFrame 你就能看到!
问题是在第四章中我没有添加任何类似 /chapframe 的内容,但它仍然具有与前一章相同的边距!!我想在第四章停止章节边距!我该怎么做?
\documentclass[headsepline,BCOR=10mm,11pt,twoside,openright,cleardoublepage=empty,bibliography=totoc,numbers=noenddot]{scrbook}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
\usepackage[paperwidth=17cm,paperheight=24cm,top=2.5cm,bottom=2.5cm,inner=2.0cm,outer=1.5cm]{geometry}
\usepackage[
scale=1,
angle=0,
opacity=1,
contents={}
]{background}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage[numbers,comma,square,sort&compress]{natbib}
\usepackage[format=plain,singlelinecheck=false,font={footnotesize,sl},labelfont=bf]{caption}
%\usepackage[toc,page]{appendix}
%\usepackage[onehalfspacing]{setspace}
%\linespread{1.0}
\usepackage[english,dutch,UKenglish]{babel}
%\epstopdfsetup{update} % only regenerate pdf files when eps file is newer
%\usepackage{fullpage}
\usepackage{notoccite}
\usepackage{url}
\usepackage{tikzpagenodes}
\definecolorseries{chcolor}{rgb}{grad}[rgb]{.95,.85,.55}{3,11,17}
\resetcolorseries{chcolor}
\usepackage{everypage}
\usepackage{color}
\pagestyle{plain}
% 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{%
\ifodd\value{page}
\backgroundsetup{contents={%
\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}{\hspace*{.6cm}\parbox[c][0.5cm][t]{3.4cm}{%
\raggedright\textcolor{black}{\scshape\leftmark}}}};
\end{tikzpicture}%
}%
}
\else
\backgroundsetup{contents={%
\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}{\hspace*{.6cm}\parbox[c][0.5cm][t]{3.4cm}{%
\raggedright\textcolor{black}{\scshape\leftmark}}}};
\end{tikzpicture}%
}%
}
\fi
\BgMaterial}%
\stepcounter{chapshift}%
}
% redefinition of \chaptermark to contain only the title
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}
\begin{document}
\chapter[intro]{Introduction}
\ChapFrame
\lipsum[1-7]
\chapter{Results}
\ChapFrame
\lipsum[1-7]
\chapter{Discussion}
\ChapFrame
\lipsum[1-7]
\chapter{prova}
\lipsum[1-7]
\end{document}
答案1
带包装scrlayer-scrpage
和包装chapterthumb
(来自http://ftp.uni-erlangen.de/ctan/info/examples/KOMA-Script-6/Anhang-B/source/chapterthumb.sty或者https://komascript.de/files/KOMA-Script-6-Buch-Beispielcode.zip)您可以将章节框架添加到页面样式中。然后您只需编译一次。
例子:
\documentclass{scrbook}
\usepackage{lipsum}% only for dummy text
\usepackage{xcolor}
\usepackage{scrlayer-scrpage}
\usepackage{chapterthumb}% http://mirrors.ctan.org/info/examples/KOMA-Script-6/Anhang-B/source/chapterthumb.sty
\newcommand\BoxColor{%
\ifcase\value{chapterthumb} blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}
\renewcommand*\firstchapterthumbskip{0pt}
\renewcommand*\chapterthumbheight{1cm}
\renewcommand*\chapterthumbwidth{4cm}
\renewcommand*\chapterthumbformat{%
\centering
\parbox[c][0.5cm][t]{3.4cm}{\raggedright\leftmark}%
}
\renewcommand*\chapterthumbboxcolor{\BoxColor}
\renewcommand*\chapterthumbcolor{black}
\setkomafont{chapterthumb}{\scshape}
\DeclareNewLayer[
clone=chapterthumb,
evenpage,
leftmargin,
width=\chapterthumbheight
]{chapterthumb.even}
\newcommand*\enableChapterFrame{%
\IfLayerAtPageStyle{@everystyle@}{chapterthumb}{}
{\AddLayersToPageStyle{@everystyle@}{chapterthumb}}%
\IfLayerAtPageStyle{@everystyle@}{chapterthumb.even}{}
{\AddLayersToPageStyle{@everystyle@}{chapterthumb.even}}%
}
\newcommand*\disableChapterFrame{%
\RemoveLayersFromPageStyle{@everystyle@}{chapterthumb,chapterthumb.even}%
}
\renewcommand\chaptermarkformat{\thechapter.~}
\pagestyle{plain}
\begin{document}
\enableChapterFrame
\chapter[intro]{Introduction}
\lipsum[1-7]
\chapter{Results}
\lipsum[1-7]
\chapter{Discussion}
\lipsum[1-7]
\cleardoublepage
\disableChapterFrame
\chapter{prova}
\lipsum[1-7]
\end{document}
book
如果您替换,这也适用于标准类
\renewcommand\chaptermarkformat{\thechapter.~}
经过
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}
和KOMA-Script 版本 3.27和 KOMA-Script 类,您还可以使用 do-hook 在新章节开始时自动从页面样式中删除图层:
\documentclass{scrbook}[2019/10/12]% needs version 3.27 or newer
\usepackage{lipsum}% only for dummy text
\usepackage{xcolor}
\usepackage{scrlayer-scrpage}
\usepackage{chapterthumb}
\newcommand\BoxColor{%
\ifcase\value{chapterthumb} blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}
\renewcommand*\firstchapterthumbskip{0pt}
\renewcommand*\chapterthumbheight{1cm}
\renewcommand*\chapterthumbwidth{4cm}
\renewcommand*\chapterthumbformat{%
\centering
\parbox[c][0.5cm][t]{3.4cm}{\raggedright\leftmark}%
}
\renewcommand*\chapterthumbboxcolor{\BoxColor}
\renewcommand*\chapterthumbcolor{black}
\setkomafont{chapterthumb}{\scshape}
\DeclareNewLayer[
clone=chapterthumb,
evenpage,
leftmargin,
width=\chapterthumbheight
]{chapterthumb.even}
\newcommand*\ChapterFrame{%
\AddLayersToPageStyle{@everystyle@}{chapterthumb,chapterthumb.even}%
}
\newcommand*\disableChapterFrame[1]{%
\RemoveLayersFromPageStyle{@everystyle@}{chapterthumb,chapterthumb.even}%
}
\AddtoDoHook{heading/postinit/chapter}{%
\RemoveLayersFromPageStyle{@everystyle@}{chapterthumb,chapterthumb.even}%
}
\renewcommand\chaptermarkformat{\thechapter.~}
\pagestyle{plain}
\begin{document}
\chapter[intro]{Introduction}\ChapterFrame
\lipsum[1-7]
\chapter{Results}\ChapterFrame
\lipsum[1-7]
\chapter{Discussion}\ChapterFrame
\lipsum[1-7]
\chapter{prova}
\lipsum[1-7]
\end{document}
两个示例的结果:
答案2
问题是你的\ChapFrame
宏跨越了每页按照 所指定\AddEverypageHook
。
一个肮脏的解决方案是通过向此命令添加参数来有条件地启用/禁用它:
% the main command; the mandatory argument sets the color of the vertical box
\newcommand\ChapFrame[1]{%
\ifodd#1
\AddEverypageHook{%
\ifodd\value{page}
\backgroundsetup{contents={%
\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}{\hspace*{.6cm}\parbox[c][0.5cm][t]{3.4cm}{%
\raggedright\textcolor{black}{\scshape\leftmark}}}};
\end{tikzpicture}%
}%
}
\else
\backgroundsetup{contents={%
\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}{\hspace*{.6cm}\parbox[c][0.5cm][t]{3.4cm}{%
\raggedright\textcolor{black}{\scshape\leftmark}}}};
\end{tikzpicture}%
}%
}
\fi
\BgMaterial}%
\stepcounter{chapshift}%
\else
\AddEverypageHook{%
\ifodd\value{page}
\backgroundsetup{contents={%
\begin{tikzpicture}[overlay,remember picture]
\node[
draw=white,
fill=white,
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}{\hspace*{.6cm}\parbox[c][0.5cm][t]{3.4cm}{%
\raggedright\textcolor{white}{\scshape\leftmark}}}};
\end{tikzpicture}%
}%
}
\else
\backgroundsetup{contents={%
\begin{tikzpicture}[overlay,remember picture]
\node[
draw=white,
fill=white,
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}{\hspace*{.6cm}\parbox[c][0.5cm][t]{3.4cm}{%
\raggedright\textcolor{white}{\scshape\leftmark}}}};
\end{tikzpicture}%
}%
}
\fi
\BgMaterial}%
\stepcounter{chapshift}%
\fi
}
用于\ChapFrame{1}
启用、\ChapFrame{0}
禁用。
% Previous tex header
\chapter[intro]{Introduction}
\ChapFrame{1}
\lipsum[1-7]
\chapter{Results}
\ChapFrame{1}
\lipsum[1-7]
\chapter{Discussion}
\ChapFrame{1}
\lipsum[1-7]
\chapter{prova}
\ChapFrame{0}
\lipsum[1-7]
tikz
还需要做更多的工作才能使这个解决方案更加合理。
编辑tikz
隐藏残留矩形所需的额外操作是将它们显示为白色。
然而,我仍然认为我的答案是一个脏补丁,而不是“TeX”y 解决方案......