我怎样才能摆脱空白页或章节首页侧面的这些垂直蓝色框?

我怎样才能摆脱空白页或章节首页侧面的这些垂直蓝色框?

我一直在寻找一种在奇数/偶数页上有不同设计的方法,从我在 Google 上找到的内容来看,background似乎有一个软件包可以做到这一点;但在使用它时,它会不加区分地将我的设计放在每一页上,甚至是我指定为空白的页面。

我怎样才能使完全空白的页面不具有这种设计,章节的开头也不具有这种设计?

\documentclass{book}
\let\cleardoublepage\clearpage

\RequirePackage[
  left=2.25in,
  right=0.75in,
  top=1.25in,
  bottom=1.25in,
  marginparwidth=1.75in,
  marginparsep=.25in]{geometry} 
\RequirePackage{graphicx}
\RequirePackage[hidelinks]{hyperref}
\RequirePackage{amsthm, amsfonts, amsmath}
\RequirePackage{thmtools}
\RequirePackage{paralist}
\RequirePackage{tikz}
\RequirePackage[explicit]{titlesec}
\RequirePackage{blindtext, xcolor}
\RequirePackage[T1]{fontenc}
\RequirePackage{mdframed}
\RequirePackage{DejaVuSansCondensed}
\RequirePackage[normalem]{ulem}
\RequirePackage{environ}
\RequirePackage[strict]{changepage}
\RequirePackage{fancyhdr}
\RequirePackage{calc}
\RequirePackage{titletoc}
\RequirePackage{ifthen}
\RequirePackage[contents={}]{background}
\RequirePackage{lipsum}

\setlength{\oddsidemargin}{1in}
\setlength{\evensidemargin}{1.25in}

\renewcommand*\familydefault{\sfdefault} % Set default font

%%% Table of Contents ----------------------------------------------------------
\setcounter{tocdepth}{1} % Show only Chapters and Sections
\makeatletter
\g@addto@macro{\appendix}{%
  \addtocontents{toc}{\protect\renewcommand*{\protect\@chapapp}{\protect\appendixname}}%
}  

%%% Change font/color/layout of TOC

% START OF MODIFIED CODE

\contentsmargin{1.5cm} % global right margin, perhaps also global left

\titlecontents{part}[3cm]
  {\color{cyan}\bfseries\Huge\addvspace{3mm}}
  {\makebox[0cm][r]{\hspace{.5em}\thecontentslabel\hspace{.75cm}}}
  {} %     ^^^ pretendously zero width box puts its contents in the left margin
  {\hfill\makebox[-3cm]{\thecontentspage}}  % 3cm = twice 1.5cm
  [\titleline{\color{cyan}\titlerule[1pt]}]

\titlecontents{chapter}[3cm] % <-- seems to set some specific left margin
  {\color{cyan}\bfseries\LARGE\addvspace{3mm}}
  {\makebox[0cm][r]{\@chapapp\hspace{.5em}\thecontentslabel\hspace{.75cm}}}
  {} %     ^^^ pretendously zero width box puts its contents in the left margin
  {\hfill\makebox[-3cm]{\thecontentspage}}  % 3cm = twice 1.5cm

\titlecontents{section}[3cm] % <-- again this left (additional?) margin
  {\color{cyan}\large\itshape\addvspace{3mm}}
  {\makebox[0cm][r]{\thecontentslabel\hspace{.75cm}}} % box pushed to the left
  {}
  {\hfill\makebox[-3cm]{\thecontentspage}}  % 3cm = twice 1.5cm
  [\addvspace{0mm}]

% END OF MODIFICATIONS

\makeatother

\AddEverypageHook{%
  \ifthenelse{\isodd{\thepage}}%
  {
    \begin{tikzpicture}[remember picture, overlay]
      \fill [cyan!50] (18.25,3) rectangle (19,-26);
    \end{tikzpicture}
  }%
  {
    \begin{tikzpicture}[remember picture, overlay]
      \fill [cyan!50] (-3,3) rectangle (-1.85,-26);
    \end{tikzpicture}
  }%
\BgMaterial}

\titlecontents{section}[5.3em]
{\color{cyan}\large\itshape\addvspace{3mm}}
{\contentslabel{0em}\hspace{3.2em}}
{}
{\hspace{3em}\contentspage}
[\addvspace{0mm}]

%%% Chapter Header ----------------------------------------------------------
\makeatletter
\titleformat{\chapter}
  {\normalfont\sffamily\Huge\scshape}
  {}{0pt}
  {\thispagestyle{empty}    % Remove page number on new chapters
  %\setcounter{definition}{0}
  \begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=cyan!50] (0,-1) rectangle
          (25cm,3cm);
        \draw[fill=cyan!50] (0,-24) rectangle
          (25cm,-25cm);
        \ifttl@label% <---------------------- Added condition on \ifttl@label
          \node[anchor=west,xshift=.21\paperwidth,yshift=-.01\paperheight,rectangle]
              {\color{white}\LARGE \MakeUppercase{\@chapapp} \Huge\thechapter};
        \fi% <------------------------------- end condition on \ifttl@label
       \end{tikzpicture}
      };
   \end{tikzpicture}\endgraf
  \vskip-.7cm
  \color{cyan}\Huge\raggedright\leftskip-1cm
   \noindent\MakeUppercase{#1}\endgraf
  }
\makeatother

\titlespacing*{\chapter}{0pt}{10pt}{0pt}{}

\titleformat{\section}{\color{cyan}\itshape\LARGE}{\llap{\thesection} #1}{1em}{}[\titleline{\color{cyan}\titlerule[1pt]}]
\titleformat{\subsection}{\color{cyan}\normalfont\large}{\; #1}{1em}{}

\begin{document}
  \tableofcontents
  \newpage\mbox{\thispagestyle{empty}}\clearpage
  \chapter{One}
    \lipsum[1-10]
  \chapter{Two}
    \lipsum[2-20]
\end{document}

答案1

也可以致电

\usepackage{etoolbox}

并添加代码

\newif\ifbluemargin\bluemargintrue
\newcommand{\makeemptypage}{%
  \clearpage\null\thispagestyle{empty}%
  \global\bluemarginfalse\clearpage\global\bluemargintrue}
\preto{\chapter}{\clearpage\global\bluemarginfalse}

在序言的末尾(至少在定义章节格式之后)。然后将蓝色条的代码更改为

\AddEverypageHook{%
  \ifbluemargin
    \ifthenelse{\isodd{\thepage}}%
    {
      \begin{tikzpicture}[remember picture, overlay]
        \fill [cyan!50] (18.25,3) rectangle (19,-26);
      \end{tikzpicture}
    }%
    {
      \begin{tikzpicture}[remember picture, overlay]
        \fill [cyan!50] (-3,3) rectangle (-1.85,-26);
      \end{tikzpicture}
    }%
  \BgMaterial
\else
  \global\bluemargintrue
\fi}

为了制作空白页,请使用\makeemptypage

但是,请不要这样做。这种布局太伤眼了。

相关内容