问题
tcolorbox
我正在尝试根据标题将所有 es 添加到目录中。到目前为止,在查看了tcolorbox
包装文档,通过使用 anauto counter
和 thenumber within
和list inside
选项,效果非常好。
但是,添加到目录条目前的自动编号已关闭,因为部分编号不会因添加其他tcolorbox
条目而更新。我附上了一个不太简单的工作示例来演示这一点(抱歉,我没有时间将其缩短)和一张图片。
任何解决方案都将不胜感激!
示威游行
代码
\documentclass[12pt, a4paper, titlepage]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\DeclareMathOperator{\dom}{dom}
\usepackage[dvipsnames, cmyk]{xcolor}
\usepackage{varwidth}
\usepackage{tcolorbox}
\tcbuselibrary{skins, theorems}
\usepackage{enumitem}
\setitemize{noitemsep,topsep=10pt,parsep=4pt,partopsep=0pt}
\setlist[itemize,1]{label={\scriptsize\raisebox{0.35ex}{$\blacksquare$}}}
\setlist[itemize,2]{label=$\bullet$}
\usepackage{tocloft}
\addtolength{\cftsecnumwidth}{10pt}
\addtolength{\cftsecindent}{10pt}
\addtolength{\cftsubsecnumwidth}{10pt}
\addtolength{\cftsubsecindent}{10pt}
\makeatletter
\@addtoreset{section}{part}
\makeatother
\usepackage[pdfborder={0 0 0}, colorlinks=false, linkcolor=black, pdfencoding=auto, pdfpagemode=UseNone]{hyperref}
\usepackage[margin=1.5cm]{geometry}
\newlength{\tcolorboxtitleYshift}
\setlength{\tcolorboxtitleYshift}{0.5mm}
\newlength{\tcolorboxtitleXshift}
\setlength{\tcolorboxtitleXshift}{4mm}
\newlength{\tcolorboxtitleDepth}
\setlength{\tcolorboxtitleDepth}{1.5mm}
\colorlet{SummaryBoxTitleColour}{red!50!yellow}
\colorlet{SummaryBoxTitleColourShadow}{SummaryBoxTitleColour!30!black}
\colorlet{SummaryBoxBackColour}{red!10!white}
\colorlet{SummaryBoxRuleColour}{SummaryBoxTitleColour!80!black}
\colorlet{highmathColour}{NavyBlue!75!black}
\tcbsetforeverylayer{%
enhanced,
colback=SummaryBoxBackColour,
colframe=SummaryBoxRuleColour,
colbacktitle=SummaryBoxTitleColour,
fonttitle=\Large\bfseries,
arc=3.5mm,
boxsep=0pt,
left=5mm, % 1 + 4 mm
right=5mm, % 1 + 4 mm
top=3mm, % 1 + 2 mm
bottom=3mm, % 1 + 2 mm
middle=3mm, % 1 + 2 mm
toptitle=1mm, % 1 + 0 mm
bottomtitle=1mm, % 1 + 0 mm
titlerule=1pt,
titlerule style=red!50!black,
varwidth boxed title={0.7\linewidth},
}
\newtcolorbox[auto counter, number within=section, list inside=summaryboxes]{SummaryBox}[1][]{%
sharp corners,
rounded corners={southeast},
frame hidden,
boxrule=0pt,
attach boxed title to top left={xshift=-\tcolorboxtitleXshift, yshift=-\tcolorboxtitleYshift},
varwidth boxed title={0.7\linewidth},
add to list={toc}{subsection},
#1
}
\newtcolorbox[auto counter, number within=subsection, list inside=summaryboxes]{SummaryExtensionBox}[1][]{%
sharp corners,
boxrule=1pt,
attach boxed title to top center={yshift*={-\tcboxedtitleheight/2}},
boxed title style={arc=0pt, outer arc=0pt, boxrule=0.5mm,
frame code={ \fill[SummaryBoxRuleColour] ([xshift=-4mm]frame.west)
-- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)
-- (frame.south east) -- (frame.south west) -- cycle; },
interior code={ \fill[SummaryBoxTitleColour] ([xshift=-2mm]interior.west)
-- (interior.north west) -- (interior.north east)
-- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west)
-- cycle;} },
add to list={toc}{subsubsection},
#1
}
\title{\textbf{Test} --- \texttt{tcolorbox} and ToC}
\author{BrightBulb123}
\date{October 2023}
\begin{document}
\maketitle
\tableofcontents
\part{Test first part}
\section{Functions and relations}
\begin{SummaryBox}[title=Functions VS relations]
\begin{itemize}[leftmargin=*]
\item A \textbf{function} is a relation such that for each $x$-value there is only one corresponding $y$-value. This means that, if $(a,b)$ and $(a,c)$ are ordered pairs of a function, then $b=c$.
\item In other words, a function cannot contain two different ordered pairs with the same first coordinate.
\end{itemize}
\begin{SummaryExtensionBox}[title=Types of functions (many/one-to-one)]
\begin{itemize}[leftmargin=*]
\item If $\forall a,b \in \dom(f): f(a) = f(b) \iff a = b$, or, to put it another way, $\forall a,b \in \dom(f): f(a) \neq f(b) \iff a \neq b$, then a function is a \textbf{one-to-one} function.
\item A function that does not satisfy the above condition(s) is a \textbf{many-to-one} function.
\end{itemize}
\end{SummaryExtensionBox}
\end{SummaryBox}
\section{Still functions and relations}
\begin{SummaryBox}[title=Functions VS relations (second one)]
\begin{itemize}[leftmargin=*]
\item A \textbf{function} is a relation such that for each $x$-value there is only one corresponding $y$-value. This means that, if $(a,b)$ and $(a,c)$ are ordered pairs of a function, then $b=c$.
\item In other words, a function cannot contain two different ordered pairs with the same first coordinate.
\end{itemize}
\begin{SummaryExtensionBox}[title=Types of functions (many/one-to-one) (also second one)]
\begin{itemize}[leftmargin=*]
\item If $\forall a,b \in \dom(f): f(a) = f(b) \iff a = b$, or, to put it another way, $\forall a,b \in \dom(f): f(a) \neq f(b) \iff a \neq b$, then a function is a \textbf{one-to-one} function.
\item A function that does not satisfy the above condition(s) is a \textbf{many-to-one} function.
\end{itemize}
\end{SummaryExtensionBox}
\end{SummaryBox}
\end{document}