
在下面的程式碼中,我嘗試按包發送包含兩列的目錄etoc
。我把這個目錄放入 a 中tcolorbox
是因為 tcolorbox 有可分頁的能力。然而真正的排版卻超出了我的意願。我不知道這是 etoc 或 tcolorbox 的問題還是我對它們的錯誤使用。任何人都可以幫忙嗎?
代碼:
\documentclass{article}
\usepackage{geometry,etoc}
\usepackage[most]{tcolorbox}
\geometry{showframe}
\begin{document}
\begin{tcolorbox}[breakable,width=5in]
\etocmulticolstyle[2]{My Content}
\tableofcontents
\end{tcolorbox}
\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}\section{sss}
\end{document}
答案1
這可以用作MWE。
您希望 (2) 中的 tcolorbox 像 (1) 中的 tcolorbox 一樣進行分頁。
那是對的嗎?
(1).多顏色內的 tcolorbox
(2)。 tcolorbox 內的多顏色
微量元素
\documentclass{article}
\usepackage{geometry,etoc}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\geometry{showframe}
\begin{document}
%\newpage
%tcb:toc
%``Unbreakable tcolorboxes can be used without
%special care inside a multicols environment
%from the multicol package.
%Since version 3.10, a breakable tcolorbox
%detects, if it is used inside a multicols
%environment. But choosing break points
%for a breakable box cannot be done by the
%balancing routine of multicols. By default,
%boxes will break at maximum column
%height. To get pleasant results, use ...''
%Code adapted from:
%https://tex.stackexchange.com/questions/639275/breakable-local-table-of-contents-with-indented-page-numbers-using-etoc
\newcommand{\chaptertoc}{%
\etocsettocstyle{%
\subsection*{Heading of local toc\\\vspace{-0.75em} \rule{\textwidth}{0.4pt}\vspace{-.5em}}
}{\vspace{-0.5em}\noindent \rule{\textwidth}{0.4pt}}%
(1). tcolorbox inside multicols
\begin{multicols}{2}
\begin{tcolorbox}[
breakable,
colback=brown!5!white,
colframe=red!75!black,
fonttitle=\bfseries,
title=My breakable box,
]
\localtableofcontents
\end{tcolorbox}
\end{multicols}
}
\newpage
code
\chaptertoc
\newcommand{\revchaptertoc}{%
\etocsettocstyle{%
\subsection*{Heading of local toc\\\vspace{-0.75em} \rule{\textwidth}{0.4pt}\vspace{-.5em}}
}{\vspace{-0.5em}\noindent \rule{\textwidth}{0.4pt}}%
\begin{tcolorbox}[
breakable,
colback=brown!5!white,
colframe=red!75!black,
fonttitle=\bfseries,
title=My breakable box,
%break at=0.7\textheight,
%height fixed for=all,
]
\begin{multicols}{2}
%\begin{tcolorbox}[
%breakable,
%]
\localtableofcontents
%\end{tcolorbox}
\end{multicols}
\end{tcolorbox}
}
\newpage
(2). multicols inside tcolorbox
\revchaptertoc
\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx
\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx\section{sss} xxx xxx xxx
\end{document}