我想知道是否有办法在添加部分时自动获取正确的部分标记\addcontentsline
(包装成\newtcolorbox
)。
我尝试添加\chead{#2}
标题\newtcolorbox
以及使用 tcolorbox 选项添加它before=\chead{#2}
。
如果我\chead{title}
在它之前添加\newtcolorbox
看起来我想这样做但我不想输入每个标题两次。
\documentclass[
fontsize=8pt
, a5paper
, ngerman
, twocolumn
, parskip=half
, titlepage=firstiscover
, fleqn
]{scrartcl}
%
\renewcommand{\coverpagetopmargin}{10mm}
\renewcommand{\coverpageleftmargin}{9mm}
\renewcommand{\coverpagerightmargin}{9mm}
\renewcommand{\coverpagebottommargin}{10mm}
%
% Preamble
\usepackage{fourier}
\usepackage[scaled]{helvet}
\usepackage{courier}
\usepackage{babel}
\addto{\captionsngerman}{\renewcommand{\tablename}{Tab.}}
\addto{\captionsngerman}{\renewcommand{\figurename}{Abb.}}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[automark]{scrlayer-scrpage}
\usepackage[many]{tcolorbox}
\usetikzlibrary{arrows.meta}
\tcbset{%
enhanced
, sharp corners
, colback=white
, colframe=black
, boxrule=1pt}
\usepackage{pdfpages}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[%
locale=DE
, display-per-mode=fraction
, inline-per-mode=symbol
]{siunitx}
\usepackage[hidelinks, breaklinks=true]{hyperref}
\usepackage[]{geometry}
\geometry{left=9mm, right=9mm}
%
% Titelseite
\title{Formelsammlung}
\author{Ich}
\date{\today}
%
\begin{document}
%
\maketitle
%
\clearpage
\twocolumn
\tableofcontents
%
\clearpage
\onecolumn
%
\newtcolorbox[use counter*=section]{secbox}[2][]{adjusted title={\makebox[2em][l]{\thetcbcounter}#2}\addcontentsline{toc}{section}{\protect\numberline{\thesection}#2}, fonttitle=\sffamily, #1}
\newtcolorbox[]{secbox*}[2][]{adjusted title={#2}\phantomsection\addcontentsline{toc}{section}{#2}, fonttitle=\sffamily, #1}
%
% \chead{Mathematische Grundlagen}
\begin{secbox}[]{Mathematische Grundlagen}
$\boxed{a^2+b^2=c^2}
\qquad c=\sqrt{a^2+b^2}
\qquad a=\sqrt{c^2-b^2}
\qquad b=\sqrt{c^2-a^2}
\qquad \text{Satz des Pythagoras}$
\end{secbox}
\begin{secbox*}[height fill]{Mathematische Grundlagen}
$\boxed{a^2+b^2=c^2}
\qquad c=\sqrt{a^2+b^2}
\qquad a=\sqrt{c^2-b^2}
\qquad b=\sqrt{c^2-a^2}
\qquad \text{Satz des Pythagoras}$
\end{secbox*}
%
\end{document}
答案1
也许不是最好的解决方案,但它似乎有效:
\documentclass[
fontsize=8pt
, a5paper
, ngerman
, twocolumn
, parskip=half
, titlepage=firstiscover
, fleqn
]{scrartcl}
%
\renewcommand{\coverpagetopmargin}{10mm}
\renewcommand{\coverpageleftmargin}{9mm}
\renewcommand{\coverpagerightmargin}{9mm}
\renewcommand{\coverpagebottommargin}{10mm}
%
% Preamble
\usepackage{fourier}
\usepackage[scaled]{helvet}
\usepackage{courier}
\usepackage{babel}
\addto{\captionsngerman}{\renewcommand{\tablename}{Tab.}}
\addto{\captionsngerman}{\renewcommand{\figurename}{Abb.}}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[automark]{scrlayer-scrpage}
\usepackage[many]{tcolorbox}
\usetikzlibrary{arrows.meta}
\tcbset{%
enhanced
, sharp corners
, colback=white
, colframe=black
, boxrule=1pt}
\usepackage{pdfpages}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[%
locale=DE
, display-per-mode=fraction
, inline-per-mode=symbol
]{siunitx}
\usepackage[hidelinks, breaklinks=true]{hyperref}
\usepackage[]{geometry}
\geometry{left=9mm, right=9mm}
\newtcolorbox[use counter*=section,list inside={toc},list type={section}]{secbox}[2][]{code=\stepcounter{section}\sectionmark{#2}\addtocounter{section}{-1},adjusted title={\makebox[2em][l]{\thetcbcounter}#2},fonttitle=\sffamily,list text={#2},#1}
\newtcolorbox[list inside={toc},list type={section}]{secbox*}[2][]{code=\addsecmark{#2},adjusted title={#2},list entry={\nonumberline #2},fonttitle=\sffamily, #1}
% Titelseite
\title{Formelsammlung}
\author{Ich}
\date{\today}
%
\begin{document}
%
\maketitle
%
\clearpage
\twocolumn
\tableofcontents
%
\clearpage
\onecolumn
%
\begin{secbox}[]{Mathematische Grundlagen}
$\boxed{a^2+b^2=c^2}
\qquad c=\sqrt{a^2+b^2}
\qquad a=\sqrt{c^2-b^2}
\qquad b=\sqrt{c^2-a^2}
\qquad \text{Satz des Pythagoras}$
\end{secbox}
\clearpage
\begin{secbox*}[height fill]{Mathematische Grundlagen}
$\boxed{a^2+b^2=c^2}
\qquad c=\sqrt{a^2+b^2}
\qquad a=\sqrt{c^2-b^2}
\qquad b=\sqrt{c^2-a^2}
\qquad \text{Satz des Pythagoras}$
\end{secbox*}
\end{document}
请注意,我使用的是 的列表功能tcolorbox
以及code
选项。code
选项在 使用的框外执行,因此或tcolorbox
生成的标记在结束相应环境后仍然有效。\sectionmark
\addsecmark
secbox
secbox*