使用 Gonzalo Medina 的代码尝试包含一张 A3 页时,我无法使用 \thispagestyle{empty} 或 cleardoublepage=plain 来隐藏页面样式。请给我提示。
代码:
\documentclass[DIV=calc,pagesize]{scrreprt}
\usepackage[a5paper,vmargin=2cm]{geometry}
\usepackage{background}
\usepackage{etoolbox}
\usepackage{graphicx,xcolor}
\usepackage{totcount}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{afterpage}
% to have access to the total number of sections
\regtotcounter{section}
% every section starts on a new page
\pretocmd{\section}{\clearpage}{}{}
% auxiliary lengths for the height of the frame and the width of each tab
\newlength\mylen
\newlength\mylena
% style for the section tabs
\tikzset{
tab/.style={
text width=\mylena,
draw=gray,
thick,
rectangle,
rounded corners=12pt,
align=center,
text width=53pt,
inner sep=0pt,
fill=gray!20,
font=\sffamily\LARGE
}
}
% style for the current section tab
\tikzset{selectedtab/.style={tab,color=white,fill=gray!90}}
% the page number is showed in the background material
\pagestyle{empty}
\AtBeginDocument{
% calculation of the width for each tab
\setlength\mylen{\dimexpr\textheight+2cm\relax}
\ifnum\totvalue{section}>0
\setlength\mylena{\dimexpr\mylen/\totvalue{section}\relax}
\fi
% the main part; as background material we place the border,
% the section (current and other) tabs and the page number
\backgroundsetup{
scale=1,
color=black,
angle=0,
opacity=1,
contents= {
\begin{tikzpicture}[remember picture, overlay]
\node[
inner sep=0pt,
text width=\the\dimexpr\textwidth+1.5cm\relax
]
at (current page.center) (border) {\rule{0pt} {\dimexpr\textheight+2cm\relax}};
\foreach \valsection in {0,...,\numexpr\totvalue{section}-1\relax}
{
\node[
\ifnum\thesection<\numexpr\valsection+1\relax
tab%
\else
\ifnum\thesection>\numexpr\valsection+1\relax
tab%
\else selectedtab%
\fi\fi,
minimum height=\mylena
]
at ([yshift=-(0.5+\valsection)*\mylena]border.north east)
(tab-\valsection)
{\hspace*{25pt}\rotatebox{-90}{%
\hyperlink{sec:\valsection}{Section \the\numexpr\valsection+1\relax}%
}
};
}
\node[
draw=gray,
line width=2pt,
rectangle,
rounded corners=10pt,
inner sep=0pt,
text width=\the\dimexpr\textwidth+1.5cm\relax,
fill=white
]
at (current page.center)
{\rule{0pt}{\dimexpr\textheight+2cm\relax}};
\node[font=\LARGE\sffamily,fill=white]
at (border.south)
{\makebox[3em][c]{\thepage}};
\end{tikzpicture}}
}
}
\begin{document}
\section{Section One}
\hypertarget{sec:0}{}
\lipsum[1-3]
\section{Test Section Two}
\hypertarget{sec:1}{}
\lipsum[1-2]
\clearpage
\afterpage{%
\KOMAoptions{paper=a3,paper=landscape}%,cleardoublepage=plain}
\recalctypearea
%\thispagestyle{empty}
\areaset{\dimexpr \textwidth+.5\paperwidth}{\textheight}
\noindent\begin{minipage}{\textwidth}
\rule{\textwidth}{\dimexpr\textheight-3\baselineskip\relax}
\captionof{figure}{Some notes...}
\end{minipage}
\clearpage
\KOMAoptions{paper=a4,paper=portrait}
\areaset{\dimexpr \textwidth-\paperwidth}{\textheight}
\recalctypearea\clearpage
}
\section{Test Section Three}
\hypertarget{sec:2}{}
\lipsum[1-2]
\section{Test Section Four}
\hypertarget{sec:3}{}
\lipsum[3]
\end{document}
结果是:
答案1
您没有为边框使用页面样式。因此\thispagestyle{empty}
不会抑制边框。
您可以加载包scrlayer
并定义一个图层页面样式。使用类,scrreprt
我会为章节执行此操作。
\documentclass[DIV=calc,pagesize]{scrreprt}
\usepackage[a5paper,vmargin=2cm]{geometry}
\usepackage{tikz}% loads also xcolor and graphicx
\usepackage{totcount}
\usepackage{lipsum}
\usepackage{afterpage}
\usepackage{hyperref}
% to have access to the total number of sections
\regtotcounter{chapter}
% auxiliary length for the width of each tab
\newlength\mylena
\tikzset{
tab/.style={% style for the section tabs
text width=\mylena,
draw=gray,
thick,
rectangle,
rounded corners=12pt,
align=center,
text width=53pt,
inner sep=0pt,
fill=gray!20,
font=\sffamily\LARGE,
overlay
},
selectedtab/.style={% style for the current section tab
tab,
color=gray!90,
text=white
},
pagenumber/.style={% style for the page number
font=\LARGE\sffamily,
fill=white,
text width=3em,
align=center
}
}
\usepackage{scrlayer}
\DeclarePageStyleByLayers{border}{border.odd}
\pagestyle{border}
\renewcommand\chapterpagestyle{border}
\DeclareNewLayer[
background,
oddpage,
textarea,
addvoffset=-1cm,
addhoffset=-.75cm,
addheight=2cm,
addwidth=1.5cm,
contents={%
\ifnum\totvalue{chapter}>0
\setlength\mylena{\dimexpr\layerheight/\totvalue{chapter}\relax}%
\fi
\begin{tikzpicture}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\node[
draw=gray,
fill=white,
inner sep=0pt,
minimum width=\layerwidth-\pgflinewidth,
minimum height=\layerheight-\pgflinewidth,
rounded corners=10pt,
line width=2pt
](border){};
\node[pagenumber]at (border.south){\thepage};
\begin{pgfonlayer}{background}
\foreach \valchapter in {0,...,\numexpr\totvalue{chapter}-1\relax}{%
\node[
\ifnum\value{chapter}<\numexpr\valchapter+1\relax
tab%
\else
\ifnum\value{chapter}>\numexpr\valchapter+1\relax
tab%
\else
selectedtab%
\fi
\fi,
minimum height=\mylena-\pgflinewidth
] at ([yshift=-(0.5+\valchapter)*\mylena]border.north east)
{\hspace*{25pt}\rotatebox{-90}{%
\hyperlink{chap:\valchapter}{\chaptername\ \the\numexpr\valchapter+1\relax}%
}
};
}
\end{pgfonlayer}
\end{tikzpicture}%
}
]{border.odd}
\begin{document}
\tableofcontents
\chapter{Chapter One}
\hypertarget{chap:0}{}
\lipsum[1-3]
\chapter{Test Chapter Two}
\hypertarget{chap:1}{}
\lipsum[1-2]
\clearpage
\afterpage{%
\KOMAoptions{paper=a3,paper=landscape,DIV=10}
\thispagestyle{empty}
\noindent\begin{minipage}{\textwidth}
\rule{\textwidth}{\dimexpr\textheight-3\baselineskip\relax}
\captionof{figure}{Some notes \ldots}
\end{minipage}
\clearpage
}
\chapter{Test Chapter Three}
\hypertarget{chap:2}{}
\lipsum[1-2]
\chapter{Test Chapter Four}
\hypertarget{chap:3}{}
\lipsum[3]
\end{document}
请注意,我已经更改了参数里面的代码\afterpage
。
如果删除\thispagestyle{empty}
A3 页面,您将得到:
答案2
您的“MWE”不是很小,并且也无法工作,因为它会生成错误消息。
但要去除 A3 页面上的背景,您必须添加
\NoBgThispage
正如文档所述,在该页面上background
。