我在这里使用了 Gonzalo 提供的代码
我遇到的问题是:
我也使用
\part
s 来划分我的文档并且该框也出现在我不想要的部分页面中;当我编译时,我收到一系列溢出警告,在 \output 处于活动状态时发生 \hbox 溢出(7.58957pt 太宽)[][]\T1/mdbch/m/fsc/24.88 5[] []
我正在使用b5
布局。这是可以复制的版本
\documentclass[openright,titlepage,numbers=enddot,headinclude=true,footinclude=true,fontsize=10pt,paper=b5,10pt,headinclude, footinclude=true]{scrbook}
\usepackage[parts,linedheaders,pdfspacing,dottedtoc,eulerchapternumbers,manychapters,listings]{classicthesis}
\usepackage[b5paper,layout=b5paper]{geometry}
\usepackage{lipsum}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{ifthen}
% background common settings
\SetBgScale{1}
\SetBgAngle{0}
\SetBgOpacity{1}
\SetBgContents{}
% auxiliary counter
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\newcounter{chapNum}
% 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}
%\ifcase\thechapshift black!80 \else black!80 \fi}
% the main command; the mandatory argument sets the color of the vertical box
\makeatletter
\newcommand\ChapFrame{%
\AddEverypageHook{%
\ifthenelse{\isodd{\thepage}}
{\SetBgContents{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=black!80,inner sep=0pt,rectangle,text width=1.3cm,
text height=1.4cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0.0cm,-2*\thechapshift cm) $)
{{\parbox[c][1.0cm][t]{0.2cm}{%
\Huge\textcolor{white}{\scshape\thechapNum}}}};
\end{tikzpicture}}%
}
{\SetBgContents{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=black!80,inner sep=0pt,rectangle,text width=1.3cm,
text height=1.4cm,align=center,anchor=north west]
at ($ (current page.north west) + (+0.0cm,-2*\thechapshift cm) $)
{{\parbox[c][1.0cm][t]{0.2cm}{%
\Huge\textcolor{white}{\scshape\thechapNum}}}};
\end{tikzpicture}}
}
\bg@material}%
\stepcounter{chapshift}
\stepcounter{chapNum}
}
\makeatother
\begin{document}
\part{Pluto}
\chapter{Topolino}
\ChapFrame
\lipsum
\chapter{Minnie}
\ChapFrame
\lipsum
\part{Pippo}
\chapter{Gambadilegno}
\ChapFrame
\lipsum
\end{document}
我不想要部分页面中的方框
答案1
针对第一个问题,您的 MWE 可进行以下工作:
\documentclass[openright,titlepage,numbers=enddot,headinclude=true,footinclude=true,fontsize=10pt,paper=b5]{scrbook}
\usepackage[parts,linedheaders,pdfspacing,dottedtoc,eulerchapternumbers,manychapters,listings]{classicthesis}
\usepackage[b5paper]{geometry}
\usepackage{lipsum}
\usepackage{tikz,everypage}
\usetikzlibrary{calc}
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\newcounter{chapNum}
\newcommand*\MyOddChapFrame{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=black!80,inner sep=0pt,rectangle,text width=1.3cm,
text height=1.4cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0.0cm,-2*\thechapshift cm) $)
{{\parbox[c][1.0cm][t]{0.2cm}{%
\Huge\textcolor{white}{\scshape\thechapNum}}}};
\end{tikzpicture}%
}
\newcommand*\MyEvenChapFrame{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=black!80,inner sep=0pt,rectangle,text width=1.3cm,
text height=1.4cm,align=center,anchor=north west]
at ($ (current page.north west) + (+0.0cm,-2*\thechapshift cm) $)
{{\parbox[c][1.0cm][t]{0.2cm}{%
\Huge\textcolor{white}{\scshape\thechapNum}}}};
\end{tikzpicture}%
}
\makeatletter
\newcommand\ChapFrame{%
\let\MyOddFrame\MyOddChapFrame
\let\MyEvenFrame\MyEvenChapFrame
\AddEverypageHook{%
\ifthispageodd
{\MyOddFrame}
{\MyEvenFrame}
}%
\stepcounter{chapshift}
\stepcounter{chapNum}
}
\titleformat{\part}[display]{%
\normalfont\centering\large}{%
\thispagestyle{empty}\partname~\MakeTextUppercase{\thepart}}{1em}{%
\color{Maroon}\spacedallcaps}[\bigskip\normalfont\normalsize\color{Black}\begin{quote}\ct@parttext\end{quote}\global\let\MyOddFrame\relax\global\let\MyEvenFrame\relax]
\makeatother
\begin{document}
\part{Pluto}
\chapter{Topolino}
\ChapFrame
\lipsum
\chapter{Minnie}
\ChapFrame
\lipsum
\part{Pippo}
\chapter{Gambadilegno}
\ChapFrame
\lipsum
\end{document}
我没有调查第二个问题,因为我认为重新考虑你的方法会更好。如果你看看输出,你会发现关于盒子过满/不足的投诉只是你收到的一些警告。此外,你还收到很多警告,scrbook
因为你严重践踏了它对页面布局的尝试。我认为你应该决定是否要使用scrbook
或者带有 等的标准类classicthesis
。geometry
如果您坚持使用scrbook
,请使用 Koma Script 的功能来管理页面布局、标题等。如果您想使用等,请使用geometry
,例如,这样您就不会有相互竞争的工作方式而造成混乱。(请注意,在这种情况下,您需要使用并将代码改回原始代码以检查您是否在奇数页上。)titlesec
book
ifthen
以下是您应该查看的消息示例。typearea
抱怨您将页面做得比纸张还大:
Package typearea Warning: page content and margins higher than paper.
(typearea) This may result in page footer out of paper.
(typearea) You should decrease DIV, decrease foot height,
(typearea) or decreate height of text area.
scrbook
警告您有关使用titlesec
并解释使用它会破坏东西:
Class scrbook Warning: Usage of package `titlesec' together
(scrbook) with a KOMA-Script class is not recommended.
(scrbook) I'd suggest to use the package only
(scrbook) if you really need it, because it breaks several
(scrbook) KOMA-Script features, i.e., option `headings' and
(scrbook) the extended optional argument of the section
(scrbook) commands .
(scrbook) Nevertheless, using requested
(scrbook) package `titlesec' on input line 373.
scrbook
这里也不开心:
Class scrbook Warning: \float@addtolists detected!
(scrbook) Implementation of \float@addtolist became
(scrbook) deprecated in KOMA-Script v3.01 2008/11/14 and
(scrbook) has been replaced by more several more flexible
(scrbook) features of package `tocbasic`.
(scrbook) Since Version 3.12 support for deprecated
(scrbook) \float@addtolist interface has been
(scrbook) restricted to only some of the KOMA-Script
(scrbook) features and been removed from others.
(scrbook) Loading of package `scrhack' may help to
(scrbook) avoid this warning, if you are using a
(scrbook) a package that still implements the
(scrbook) deprecated \float@addtolist interface .
如果您更喜欢继续使用scrbook
,您可以使用xpatch
修补\part
命令来控制缩略图选项卡的显示。我还包括了一些配置字体等的命令示例。请参阅类文档以了解您想要模拟的相关方面的选项classicthesis
:
\documentclass[openright,titlepage,numbers=enddot,fontsize=10pt,paper=b5]{scrbook}
\usepackage{lipsum}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz,everypage,xpatch}
\usetikzlibrary{calc}
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\newcounter{chapNum}
\newcommand*\MyOddChapFrame{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=black!80,inner sep=0pt,rectangle,text width=1.3cm,
text height=1.4cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0.0cm,-2*\thechapshift cm) $)
{{\parbox[c][1.0cm][t]{0.2cm}{%
\Huge\textcolor{white}{\scshape\thechapNum}}}};
\end{tikzpicture}%
}
\newcommand*\MyEvenChapFrame{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=black!80,inner sep=0pt,rectangle,text width=1.3cm,
text height=1.4cm,align=center,anchor=north west]
at ($ (current page.north west) + (+0.0cm,-2*\thechapshift cm) $)
{{\parbox[c][1.0cm][t]{0.2cm}{%
\Huge\textcolor{white}{\scshape\thechapNum}}}};
\end{tikzpicture}%
}
\makeatletter
\newcommand\ChapFrame{%
\let\MyOddFrame\MyOddChapFrame
\let\MyEvenFrame\MyEvenChapFrame
\AddEverypageHook{%
\ifthispageodd
{\MyOddFrame}
{\MyEvenFrame}
}%
\stepcounter{chapshift}
\stepcounter{chapNum}
}
\xpatchcmd{\part}{\thispagestyle{\partpagestyle}}{\thispagestyle{\partpagestyle}\global\let\MyOddFrame\relax\global\let\MyEvenFrame\relax}{\typeout{Successfully patched part code.}}{\typeout{Oh, dear! Failed to patch part code.}}
\makeatother
\pagestyle{headings}
\renewcommand*\partpagestyle{empty}
\renewcommand*\chapterpagestyle{plain}
\setkomafont{part}{\normalfont\large\color{Maroon}}
\setkomafont{partnumber}{\normalfont\large}
\setkomafont{chapter}{\normalfont\normalsize\bfseries}
\begin{document}
\part{Pluto}
\chapter{Topolino}
\ChapFrame
\lipsum
\chapter{Minnie}
\ChapFrame
\lipsum
\part{Pippo}
\chapter{Gambadilegno}
\ChapFrame
\lipsum
\end{document}