答案1
以下代码结合了答案https://tex.stackexchange.com/a/96295/36296来自问题的文件:
\documentclass{book}
\let\cleardoublepage\clearpage
\RequirePackage{titletoc}
\RequirePackage{tikz}
\RequirePackage[explicit]{titlesec}
\RequirePackage{DejaVuSansCondensed}
\RequirePackage[normalem]{ulem}
\RequirePackage[
left=2.25in,
right=0.75in,
top=1.25in,
bottom=1.25in,
marginparwidth=1.75in,
marginparsep=.25in,
asymmetric]{geometry}
\renewcommand*\familydefault{\sfdefault} % Set default font
%%% Table of Contents ----------------------------------------------------------
\setcounter{tocdepth}{1} % Show only Chapters and Sections
%%% Change font/color/layout of TOC (with package etoc.)
% \RequirePackage{titletoc}
\usepackage{etoc}
% these margins will used additionally to the page margins
% set-up by package geometry
\newlength{\tocleftmargin}
\setlength{\tocleftmargin}{3.5cm}
\newlength{\tocrightmargin}
\setlength{\tocrightmargin}{1cm}
\makeatletter % for using \@chapapp of class book
\etocsetstyle{chapter}
{\parindent0pt
\leftskip\tocleftmargin
\rightskip\the\tocrightmargin plus 1fil
\parfillskip0pt
\color{cyan}}
{\addvspace{3mm}\leavevmode\bfseries\LARGE\upshape}
{\llap{\@chapapp\hspace{.5em}\etocnumber\hspace{.75cm}}\etocname
\hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}
\etocsetstyle{section}
{}
{\addvspace{3mm}\leavevmode\mdseries\large\itshape}
{\llap{\etocnumber\hspace{.75cm}}\etocname
\hfill\makebox[-\tocrightmargin][l]{\makebox[0pt]{\etocpage}}\par}
{}
\makeatother
\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] (0,-1) rectangle
(25cm,3cm);
\draw[fill=cyan] (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
\chapter{Turing Machines}
\section{The Turing Machine}
\section{Variations of the Turing Machine}
%\subsection{Non-deterministic Turing Machines}
\section{The Church-Turing Thesis}
\chapter{Decidability}
\section{The Universal Turing Machine}
\appendix
\chapter{ON COMPUTABLE NUMBERS, WITH AN APPLICATION TO THE ENTSCHEIDUNGSPROBLEM}
\end{document}