Compare commits

...

2 Commits

Author SHA1 Message Date
4a98d7d3af [Code] Add better code snippets 2025-09-28 20:05:58 +02:00
14210ca1da [Counters] Completely redo numbering logic 2025-09-28 17:51:57 +02:00
4 changed files with 122 additions and 49 deletions

Binary file not shown.

View File

@@ -20,7 +20,7 @@
\item \verb|\renewcommand{\city}|\{\textit{string}\} Change the city (for letters) for this document only
\item \verb|\renewcommand{\countrycode}|\{\textit{string}\} Change the country-code (for letters) for this document only
\item \verb|\renewcommand{\theoremde}|\{\textit{string}\} Change the translation for theorem in German (usually either ``Satz'' or ``Theorem'')
\item \verb|\setcounter{numberingConfig}|\{\textit{number}\} Change the numbering of definitions, lemmas, etc for this document. 1 = Separately, 2 = Combined (except for definition), 3 = Combined, 4 = Off
\item \verb|\setcounter{numberingConfig}|\{\textit{number}\} Change the numbering of definitions, lemmas, etc for this document. 0 = off, 1 = Separately, 2 = Combined (except for definition), 3 = Combined
\item \verb|\setcounter{numberSubsections}|\{\textit{number}\} Change the format of the numbering of definition, lemma, etc.
0 = $<$section$>$.$<$number$>$,\\
1 = $<$section$>$.$<$subsection$>$.$<$number$>$,\\
@@ -432,6 +432,7 @@ This outputs as
\end{fullTable}
\subsection{Index}
\textit{Included in \texttt{most} and up}
@@ -439,6 +440,8 @@ If you want to use index, add \verb|\prepareIndex| to the preamble. Using \verb|
Using \verb|\addIndex|\{\textit{string}\}, you can do the same, but the text remains normal and using \verb|\addIndexItalic|\{\textit{string}\}, it is printed in italics
\newpage
\subsection{Extras}
\subsubsection{BibTeX}
\textit{Included in \texttt{recommended} and up}
@@ -454,3 +457,20 @@ Use \verb|\setupGlossary| in the preamble to prepare, then use the normal glossa
\textit{Included in \texttt{full}}
No extra configs or commands provided by this one, simply an import for minted. Be sure to enable \texttt{shell-escape} for your compiler!
When \texttt{minted} is available via these helpers, you will also have access to the \texttt{codesnippet} macro:
\begin{minted}{latex}
\begin{code}{language}
//Code goes here
\end{code}
\end{minted}
This is nothing different than a wrapper for a minted environment with a box drawn around it.
Example (in python):
\begin{code}{python}
def hello_world():
print("hello world!")
\end{code}

View File

@@ -1 +1,15 @@
\usepackage{minted}
\usepackage{fancyvrb}
\newenvironment{code}[1]{
\VerbatimEnvironment
\begin{minted}[
autogobble,
breaklines,
breakindentnchars=2,
frame=lines,
framesep=2mm,
baselinestretch=1.1,
linenos]{#1}}
{\end{minted}}

View File

@@ -19,16 +19,41 @@
\newcounter{remarks}
\newcounter{all}
\newcommand{\definitions}{definitions}
\newcommand{\useSubsection}{\ifnum\value{numberSubsections}>0{\arabic{subsection}.}\else{}\fi}
\newcommand{\useSubsubsection}{\ifnum\value{numberSubsections}>1{\arabic{subsubsection}.}\else{}\fi}
\newcommand{\usenumberArabic}[1]{\ifnum\value{numberingConfig}<4{\arabic{section}.\useSubsection\useSubsubsection\ifnum\value{numberingConfig}<3{\ifnum\value{numberingConfig}<2{\arabic{#1}\stepcounter{#1}}\else{
\ifx#1\definitions
\arabic{#1}\stepcounter{#1}
% ┌ ┐
% │ Numbering of sections │
% └
\newcommand{\subsectionRendering}{
\ifnum\value{numberSubsections}=1%
\arabic{section}.\arabic{subsection}%
\else
\arabic{all}\stepcounter{all}
\fi}\fi}\else{\arabic{all}\stepcounter{all}}\fi}\else{}\fi}
\ifnum\value{numberSubsections}=2%
\arabic{section}.\arabic{subsection}.\arabic{subsubsection}%
\else
\arabic{section}%
\fi
\fi}
\newcommand{\usenumberArabic}[1]{%
\ifnum\value{numberingConfig}=1
\subsectionRendering.\arabic{#1}\stepcounter{#1}%
\else
\ifnum\value{numberingConfig}=2
\ifthenelse{\equal{#1}{definitions}}{%
\subsectionRendering.\arabic{definitions}\stepcounter{definitions}%
}{%
\subsectionRendering.\arabic{all}\stepcounter{all}%
}%
\else
\ifnum\value{numberingConfig}=3
\subsectionRendering.\arabic{all}\stepcounter{all}%
\else
\relax%
\fi
\fi
\fi}
% ────────────────────────────────────────────────────────────────────
% Reset definition, lemma, etc counters, add a new page
@@ -54,6 +79,12 @@
\newsectionNoPB
% ────────────────────────────────────────────────────────────────────
% ╭────────────────────────────────────────────────╮
% │ Tcolorboxes │
% ╰────────────────────────────────────────────────╯
% ────────────────────────────────────────────────────────────────────
% Definitions
\newtcolorbox{definition}[2][]{mainboxstyle,colback=blue!5!white,colframe=blue!75!black,colbacktitle=blue!75!black,title={\large #2},overlay={\node[overlaystyle,draw=blue!75!black,fill=blue!75!black] at (frame.north east) {\large Definition\usenumberArabic{definitions}};},#1}
@@ -93,6 +124,14 @@
\newtcolorbox{remark}[2][]{mainboxstyle,colback=green!5!white,colframe=green!75!black,colbacktitle=green!75!black,title={\large #2},
overlay={\node[overlaystyle,draw=green!75!black,fill=green!75!black] at (frame.north east) {\large \translate{Remark}{Bemerkung} \usenumberArabic{remarks}};},#1}
% ────────────────────────────────────────────────────────────────────
% ╭────────────────────────────────────────────────╮
% │ Inline environments │
% ╰────────────────────────────────────────────────╯
% ────────────────────────────────────────────────────────────────────
% Inline environments (inline)
\newcommand{\inlineex}{\bg{gray}{\translate{Example}{Beispiel}\usenumberArabic{examples}:}}
\newcommand{\inlinedef}{\bg{blue}{Definition\usenumberArabic{definitions}:}}