Update box styling

This commit is contained in:
2026-09-10 18:00:39 +02:00
parent f52052f5f0
commit 095d7f3d10
2 changed files with 76 additions and 39 deletions
+3 -12
View File
@@ -21,7 +21,7 @@ This is a formula: \( \sum\limits_{f=1}^{\infty}\frac{o}{r}\cdot m_{u} + l^{a} \
This is \textbf{bold text that is slightly bold}, so underwhelming.
In contrast, \sansbf{this text is very strong}, very cool\footnote{very cool}.
\begin{codeblock}[label=lst:examplelisting]{This is a listing}{C++}
\begin{codeblock}[label=lst:examplelisting]{This is a listing.}{C++}
\inputminted{cpp}{\subfix{listings/example.cpp}}
\end{codeblock}
@@ -33,24 +33,15 @@ In contrast, \sansbf{this text is very strong}, very cool\footnote{very cool}.
\caption{This is a figure.}\label{fig:examplefigure}
\end{figure}
\begin{figure}[H]
\centering
\begin{subfigure}[b]{\textwidth}
\includesvg[width=1.0\linewidth]{\subfix{figures/heatmap2.svg}}
\end{subfigure}
\caption{This is another figure.}\label{fig:exampleheatmap}
\end{figure}
\begin{table}[H]
\centering
\begin{tabularx}{\textwidth}{lX}
Column A & Column B \\
\toprule
\midrule
This is & a table where the right column does automatic line breaking, so long cell contents don't exceed the page boundary. Cool. \\
This is & an second row. \\
\bottomrule
\end{tabularx}
\caption{This is a table}\label{tab:exampletable}
\caption{This is a table.}\label{tab:exampletable}
\end{table}
\lipsum%
+73 -27
View File
@@ -275,7 +275,7 @@
nobeforeafter,
boxrule=0pt,
colback=languagebg,
arc=2pt,
arc=3pt,
boxsep=0pt,
left=3pt,
right=3pt,
@@ -300,11 +300,11 @@
top color=codebg,
bottom color=codebg
},
boxrule=0.5pt, % Border width
arc=2pt, % Rounded corners
boxrule=1pt, % Border width
arc=4pt, % Rounded corners
width=\linewidth,
fonttitle=\normalsize,
adjusted title=\textbf{\texttt{\thetcbcounter}\hspace{0.75em}\texttt{#2}},
adjusted title=\textbf{\texttt{Listing \thetcbcounter.}\hspace{0.75em}\texttt{#2}},
list entry=\thetcbcounter\quad\texttt{#2}, % List of listings
list text={\hspace*{1ex}#2}, % Chapter - Caption spacing in list of listings
after title={% Display used language
@@ -319,7 +319,8 @@
top=1mm,
bottom=1mm,
right=0mm,
left=5mm,
left=4.3mm,
drop shadow=titlebg!50!white,
#1 % Extra args, e.g. a label
}
@@ -341,32 +342,77 @@
}
% A box surrounding inline code-type text
\newtcbox{\codehighlight}{nobeforeafter,boxrule=.5pt,colback=black!5,colframe=black!35,
arc=2pt,boxsep=0pt,left=2pt,right=2pt,top=2pt,bottom=2pt, tcbox raise base}
\newtcbox{\codehighlight}{
nobeforeafter,
boxrule=.5pt,
colback=black!5,
colframe=black!35,
arc=2pt,
boxsep=0pt,
left=2pt,
right=2pt,
top=2pt,
bottom=2pt,
tcbox raise base
}
% Quickly place inline codehighlight boxes
\newcommand{\code}[1]{\codehighlight{\texttt{\small{#1}}}}
% A box surrounding figures
\tcolorboxenvironment{figure}{
enhanced,
float=htb,
arc=2pt,
boxrule=0.5pt,
colframe=black,
colback=white,
before skip=\intextsep,
after skip=\intextsep,
% Boxes for figures and tables use the same title bar as code listings.
% Existing \caption and \label commands still work.
\tcbset{captionbox/.style={
enhanced,
arc=4pt,
boxrule=1pt,
boxsep=1mm,
left=4mm, right=4mm,
lefttitle=4mm, righttitle=4mm,
colbacktitle=titlebg,
coltitle=titlecolor,
colframe=titlebg,
colback=white,
fonttitle=\normalsize\bfseries\ttfamily,
drop shadow=titlebg!50!white,
}}
% Captions
\captionsetup[captionbox]{
font={normalsize,bf,tt,color=titlecolor},
labelfont={bf,tt},
labelsep=quad,
margin=0pt,
justification=raggedright,
singlelinecheck=false,
skip=0pt,
}
% A box surrounding tables
\tcolorboxenvironment{table}{
enhanced,
float=htb,
arc=2pt,
boxrule=0.5pt,
colframe=black,
colback=white,
before skip=\intextsep,
after skip=\intextsep,
% Subcaptions
\captionsetup[sub]{
font={normalfont,small,color=black},
labelfont={normalfont,bf},
}
\makeatletter
\newcommand{\fs@captionbox}{%
\fs@plain%
\def\@fs@pre{%
\begin{tcolorbox}[captionbox,title={\unvbox\@floatcapt}]
}
\def\@fs@post{\end{tcolorbox}}
\def\@fs@mid{}
\let\@fs@iftopcapt\iffalse%
}
\makeatother
% Reserve padding
\newcommand{\captionboxwidth}{%
\hsize=\dimexpr\linewidth-10mm-1pt\relax
\linewidth=\hsize
\textwidth=\hsize
}
\floatstyle{captionbox}
\restylefloat{figure}
\restylefloat{table}
\floatevery{figure}{\captionboxwidth}
\floatevery{table}{\captionboxwidth}
\floatstyle{plain}