我正在努力为包中的目录添加背景tcolorbox
。不幸的是,有两页或一页(取决于选项twoside
)带有小空白框。
如果您能弄清楚如何在不生成这些空白框的情况下开始目录,我会在这里为您提供一个虚拟代码。
先感谢您!
\documentclass[12pt,twoside,a4paper]{book}
\title{Debugging}
\author{Its me...}
\usepackage{xcolor}
\definecolor{Color2}{RGB}{204, 225, 218} %light green
\usepackage[most]{tcolorbox}
\tcbset{
% frame code={}
%center title,
%left=10pt,
%right=10pt,
top=10pt,
%bottom=10pt,
colback=Color2!30,
colframe=white,
width=\dimexpr\textwidth\relax,
boxsep=10pt,
arc=8pt,
%outer arc=0pt,
breakable,
}
\begin{document}
\maketitle
%% PROBLEM APPEARS HERE
\newpage
\begin{tcolorbox}
\tableofcontents
\end{tcolorbox}
\newpage
% DUMMY SECTIONS FOR GENERATING TOC GREATER THAN ONE PAGE
\section{Section}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\section{Section}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\section{Section}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\section{Section}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\end{document}
答案1
由于\tableofcontents
使用\chapter*{\contentsname}
,涉及\clearpage
到\tableofcontents. Breakable
tcolorbox` 环境,无法真正应对这个问题。
一个可能的解决方案是说before upper=\let\clearpage\relax
,只要没有浮点数出现在ToC
(浮点数不太可能出现在的位置)。
\documentclass[12pt,twoside,a4paper]{book}
\title{Debugging}
\author{Its me...}
\usepackage{xcolor}
\definecolor{Color2}{RGB}{204, 225, 218} %light green
\usepackage[most]{tcolorbox}
\tcbset{
% frame code={}
%center title,
%left=10pt,
%right=10pt,
top=10pt,
%bottom=10pt,
colback=Color2!30,
colframe=white,
% width=\dimexpr\textwidth\relax,
boxsep=10pt,
arc=8pt,
%outer arc=0pt,
breakable,
}
\begin{document}
\maketitle
%% PROBLEM APPEARS HERE
\newpage
\begin{tcolorbox}[before upper={\let\clearpage\relax}]
\tableofcontents
\end{tcolorbox}
\newpage
% DUMMY SECTIONS FOR GENERATING TOC GREATER THAN ONE PAGE
\section{Section}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\section{Section}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\section{Section}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\section{Section}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\subsection{Subsection}
\end{document}