von vinc14 » Fr 18. Jul 2025, 11:31
Hier wäre der Code mit meinen Wünschen, der nun alles erfüllt!
Es wird nun im Inhaltsverzeichnis und im Index eingetragen
und die Numerirung der Subsection funktioniert auch mit normalem \subsection befehlt.
Danke Herr Sturm für sein feedback
% !TeX document-id = {19f1156d-bdd7-4481-b341-b9423b5f38e5}
% !BIB TS-program = biber
% !TEX lualatex
\documentclass[12pt,a4paper,oneside]{scrbook}
\usepackage[ngerman]{babel}
\usepackage{geometry}
\geometry{
% papersize={130mm,190mm},
% textwidth=120mm,
% textheight=170mm,
marginparwidth=75pt,
left=15mm,
right=20mm,
top=25mm,
bottom=25mm,
foot=10mm,
}
\usepackage[x11names,table]{xcolor} % Packet muss sehr früh geladen werden
\usepackage[many]{tcolorbox}
\usepackage{varwidth}
\usepackage{url}
\newtcolorbox[use counter*=subsection,number within=section]{myboxTable}[2][]{enhanced,
before skip=2mm,after skip=2mm,
colback=DarkSeaGreen1!5,colframe=black!50,boxrule=0.2mm,
attach boxed title to top left={xshift=1cm,yshift*=1mm-\tcboxedtitleheight},
varwidth boxed title*=-3cm,
boxed title style={frame code={
\path[fill=tcbcolback!30!black]
([yshift=-1mm,xshift=-1mm]frame.north west)
arc[start angle=0,end angle=180,radius=1mm]
([yshift=-1mm,xshift=1mm]frame.north east)
arc[start angle=180,end angle=0,radius=1mm];
\path[left color=tcbcolback!60!black,right color=tcbcolback!60!black,
middle color=tcbcolback!80!black]
([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east)
[rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east)
-- (frame.south east) -- (frame.south west)
-- ([xshift=-1mm,yshift=-1mm]frame.north west)
[sharp corners]-- cycle;
},interior engine=empty,
},
fonttitle=\bfseries,
title=~\thetcbcounter { #2},#1,
phantom={\addcontentsline{toc}{subsection}{\arabic{chapter}.\arabic{section}.\arabic{subsection} #2}}
\index{#2}
}
\newtcolorbox[use counter*=subsection,number within=section]{pabox}[2][]{%
colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,
title=Examp.~\thetcbcounter: #2,#1}
\begin{document}
% \tableofcontents
\renewcommand*\chapterheadstartvskip{\vspace*{-\topskip}}
\chapter{Kapitel 1}
\section{section 1}
mein MWE (= minimal, working example)
\section{section 2}
\begin{myboxTable}[colbacktitle=green]{hier ist der Titel}
Titel der Tabelle\\
mein Wunsch wäre das vor dem Titel eine Nummer hinkommt und zwar ein subsection nummer welche dann auch im Index auftauchen sollte\\
Das Beispiel ist auf der Seite 188 vom The tcolorbox package Manual for version 6.7.1 (2025/07/08)\\ \url{https://www.ctan.org/pkg/tcolorbox}
\end{myboxTable}
\section{hier ein beispiel wo die die Nummer eingefügt wird}
für mich müsst das Examp. vorne weg
\subsection{subsection 1}
\begin{pabox}[colback=yellow]{Hello there}
This is my own box with a mandatory
numbered title and options.
\end{pabox}
Diese Box müsste auch im Inhaltsverzeichnis erscheinen
\subsection{Subsection 2 müsste aber 3 sein}
\end{document}
Hier wäre der Code mit meinen Wünschen, der nun alles erfüllt!
Es wird nun im Inhaltsverzeichnis und im Index eingetragen
und die Numerirung der Subsection funktioniert auch mit normalem \subsection befehlt.
Danke Herr Sturm für sein feedback ;-)
[code]
% !TeX document-id = {19f1156d-bdd7-4481-b341-b9423b5f38e5}
% !BIB TS-program = biber
% !TEX lualatex
\documentclass[12pt,a4paper,oneside]{scrbook}
\usepackage[ngerman]{babel}
\usepackage{geometry}
\geometry{
% papersize={130mm,190mm},
% textwidth=120mm,
% textheight=170mm,
marginparwidth=75pt,
left=15mm,
right=20mm,
top=25mm,
bottom=25mm,
foot=10mm,
}
\usepackage[x11names,table]{xcolor} % Packet muss sehr früh geladen werden
\usepackage[many]{tcolorbox}
\usepackage{varwidth}
\usepackage{url}
\newtcolorbox[use counter*=subsection,number within=section]{myboxTable}[2][]{enhanced,
before skip=2mm,after skip=2mm,
colback=DarkSeaGreen1!5,colframe=black!50,boxrule=0.2mm,
attach boxed title to top left={xshift=1cm,yshift*=1mm-\tcboxedtitleheight},
varwidth boxed title*=-3cm,
boxed title style={frame code={
\path[fill=tcbcolback!30!black]
([yshift=-1mm,xshift=-1mm]frame.north west)
arc[start angle=0,end angle=180,radius=1mm]
([yshift=-1mm,xshift=1mm]frame.north east)
arc[start angle=180,end angle=0,radius=1mm];
\path[left color=tcbcolback!60!black,right color=tcbcolback!60!black,
middle color=tcbcolback!80!black]
([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east)
[rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east)
-- (frame.south east) -- (frame.south west)
-- ([xshift=-1mm,yshift=-1mm]frame.north west)
[sharp corners]-- cycle;
},interior engine=empty,
},
fonttitle=\bfseries,
title=~\thetcbcounter { #2},#1,
phantom={\addcontentsline{toc}{subsection}{\arabic{chapter}.\arabic{section}.\arabic{subsection} #2}}
\index{#2}
}
\newtcolorbox[use counter*=subsection,number within=section]{pabox}[2][]{%
colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,
title=Examp.~\thetcbcounter: #2,#1}
\begin{document}
% \tableofcontents
\renewcommand*\chapterheadstartvskip{\vspace*{-\topskip}}
\chapter{Kapitel 1}
\section{section 1}
mein MWE (= minimal, working example)
\section{section 2}
\begin{myboxTable}[colbacktitle=green]{hier ist der Titel}
Titel der Tabelle\\
mein Wunsch wäre das vor dem Titel eine Nummer hinkommt und zwar ein subsection nummer welche dann auch im Index auftauchen sollte\\
Das Beispiel ist auf der Seite 188 vom The tcolorbox package Manual for version 6.7.1 (2025/07/08)\\ \url{https://www.ctan.org/pkg/tcolorbox}
\end{myboxTable}
\section{hier ein beispiel wo die die Nummer eingefügt wird}
für mich müsst das Examp. vorne weg
\subsection{subsection 1}
\begin{pabox}[colback=yellow]{Hello there}
This is my own box with a mandatory
numbered title and options.
\end{pabox}
Diese Box müsste auch im Inhaltsverzeichnis erscheinen
\subsection{Subsection 2 müsste aber 3 sein}
\end{document}
[/code]