
In den folgenden Codes versuche ich, ein Inhaltsverzeichnis mit zwei Spalten per etoc
Paket zu versenden. Ich habe dieses Inhaltsverzeichnis in ein gepackt, tcolorbox
weil tcolorbox die Fähigkeit zum Seitenumbruch hat. Der tatsächliche Schriftsatz entspricht jedoch nicht meinen Wünschen. Ich weiß nicht, ob dies ein Problem von etoc oder tcolorbox ist oder ob ich sie falsch verwende. Kann mir jemand helfen?
Codes:
\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}
Antwort1
Dies kann als MWE dienen.
Sie möchten, dass die Tcolorbox aus (2) den gleichen Seitenumbruch aufweist wie die Tcolorbox aus (1).
Ist das korrekt?
(1). tcolorbox innerhalb von Multicols
(2). Multicols innerhalb der Farbbox
MWE
\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}