Customize TOC part formatting, callout block colors and font size

Added "Part" label before part number in TOC with custom spacing and color.
Also updated styles of custom callout blocks to visually distinguish them from Quarto defaults.
This commit is contained in:
Zeljko Hrcek
2025-06-28 13:25:00 +02:00
parent bd54a6a8f4
commit e67b575290
19 changed files with 135 additions and 114 deletions

View File

@@ -3,7 +3,7 @@ details.fbx-default,
details.fbx-answer,
details.fbx-question {
--text-color: #3c3c3c;
--font-size: 0.85rem;
--font-size: 1rem;
--font-family: var(--bs-body-font-family, system-ui, sans-serif);
--border-radius: 0.3rem;
--border-left-width: 4px;

View File

@@ -11,7 +11,7 @@
\begin{tcolorbox}[
enhanced,
breakable,
fontupper=\fontsize{8pt}{10}\selectfont,
%fontupper=\fontsize{8pt}{10}\selectfont,
before skip=6pt, % space avove box
after skip=6pt, % space below box
attach boxed title to top*={xshift=0pt},
@@ -52,17 +52,17 @@
\newenvironment{fbxSimple}[3]{\begin{tcolorbox}[
enhanced,
breakable,
fontupper=\fontsize{8pt}{10}\selectfont,
%fontupper=\fontsize{8pt}{10}\selectfont,
before skip=6pt, % space avove box
after skip=6pt, % space below box
attach boxed title to top*={xshift=0pt},
boxed title style={
%fuzzy shadow={1pt}{-1pt}{0mm}{0.1mm}{gray},
arc=4.5pt,
arc=1.5pt,
rounded corners=north,
sharp corners=south,
top=8pt,
bottom=7pt,
top=5pt,
bottom=4pt,
overlay={
\node [left,outer sep=0em, black,draw=none,anchor=west,
rectangle,fill=none,inner sep=0pt]
@@ -74,17 +74,16 @@
colback=white,
coltitle=black,
titlerule=0mm,
toprule=1.2pt,
bottomrule=1.2pt,
leftrule=3pt,
rightrule=1.2pt,
outer arc=4.5pt,
arc=4.5pt,
toprule=0.5pt,
bottomrule=0.5pt,
leftrule=2.2pt,
rightrule=0.5pt,
outer arc=1.5pt,
arc=1.5pt,
left=0.3em,
bottomtitle=1mm,
toptitle=1mm,
title=\hspace{2.3
em}\textbf{#2}\hspace{0.1em}{#3},
title=\hspace{2.3em}\textbf{#2}\hspace{0.1em}{#3},
extras middle and last={top=3pt}
]}
{\end{tcolorbox}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -115,7 +115,7 @@ book:
# - contents/core/ml_systems/ml_systems.qmd
# - contents/core/dl_primer/dl_primer.qmd
# - contents/core/dnn_architectures/dnn_architectures.qmd
# - part: contents/parts/design_principles.qmd
- part: contents/parts/design_principles.qmd
# - contents/core/workflow/workflow.qmd
# - contents/core/data_engineering/data_engineering.qmd
# - contents/core/frameworks/frameworks.qmd
@@ -124,14 +124,14 @@ book:
# - contents/core/optimizations/optimizations.qmd
# - contents/core/hw_acceleration/hw_acceleration.qmd
# - contents/core/benchmarking/benchmarking.qmd
# - part: contents/parts/best_practices.qmd
- part: contents/parts/best_practices.qmd
# - contents/core/ops/ops.qmd
# - contents/core/ondevice_learning/ondevice_learning.qmd
# - contents/core/privacy_security/privacy_security.qmd
# - contents/core/responsible_ai/responsible_ai.qmd
# - contents/core/sustainable_ai/sustainable_ai.qmd
# - contents/core/robust_ai/robust_ai.qmd
# - part: contents/parts/impact_outlook.qmd
- part: contents/parts/impact_outlook.qmd
# - contents/core/ai_for_good/ai_for_good.qmd
# - contents/core/conclusion/conclusion.qmd
# - text: "---"
@@ -168,13 +168,13 @@ book:
# chapters:
# - contents/labs/shared/kws_feature_eng/kws_feature_eng.qmd
# - contents/labs/shared/dsp_spectral_features_block/dsp_spectral_features_block.qmd
# - text: "---"
# - part: "RESOURCES"
# chapters:
# - contents/backmatter/resources/phd_survival_guide.qmd
# - text: "---"
# - part: "REFERENCES"
# - contents/backmatter/appendix/references.qmd
- text: "---"
- part: "RESOURCES"
chapters:
- contents/backmatter/resources/phd_survival_guide.qmd
- text: "---"
- part: "REFERENCES"
- contents/backmatter/references.qmd
bibliography:
- contents/core/introduction/introduction.bib
@@ -220,7 +220,7 @@ filters:
- lua/sidenote.lua
- diagram
- custom-numbered-blocks
- diagram
- inject-partsummary.lua
diagram:
engine:
@@ -455,26 +455,26 @@ format:
custom-numbered-blocks:
groups:
quiz-question:
colors: ["e6f0fa", "5b8cbf"]
colors: ["E1F3F8", "119EC7"]
collapse: false
quiz-answer:
colors: ["fceeee", "b54b4b"]
colors: ["FAEAF1", "980e5a"]
collapse: true
resource-slides:
colors: ["e6f3ec", "5ba874"]
colors: ["E9F3E3", "55984D"]
collapse: false
numbered: false
resource-videos:
colors: ["fff4e6", "e67e22"]
colors: ["f9f5f0", "8b5e3c"]
collapse: false
numbered: false
resource-exercises:
colors: ["f7f0fa", "a95cb4"]
colors: ["f7f0fa", "815AA4"]
collapse: false
numbered: false
numbered: false
classes:
callout-quiz-question:
callout-quiz-question:
label: "Self-Check: Question"
group: quiz-question
callout-quiz-answer:
@@ -489,6 +489,5 @@ custom-numbered-blocks:
callout-resource-exercises:
label: "Exercises"
group: resource-exercises
resources:
- CNAME

View File

@@ -1038,7 +1038,6 @@ These patterns will evolve as technological capabilities advance and deployment
The systematic application of these design patterns, informed by rigorous analysis of deployment contexts and constraints, enables the development of ML systems that function effectively across the computing spectrum while delivering sustainable social impact.
## Resources {#sec-ai-good-resources-09a3}
:::{.callout-note collapse="false" title="Slides"}

View File

@@ -7,24 +7,83 @@ quiz: introduction_quizzes.json
![_DALL·E 3 Prompt: A detailed, rectangular, flat 2D illustration depicting a roadmap of a book's chapters on machine learning systems, set on a crisp, clean white background. The image features a winding road traveling through various symbolic landmarks. Each landmark represents a chapter topic: Introduction, ML Systems, Deep Learning, AI Workflow, Data Engineering, AI Frameworks, AI Training, Efficient AI, Model Optimizations, AI Acceleration, Benchmarking AI, On-Device Learning, Embedded AIOps, Security & Privacy, Responsible AI, Sustainable AI, AI for Good, Robust AI, Generative AI. The style is clean, modern, and flat, suitable for a technical book, with each landmark clearly labeled with its chapter title._](images/png/cover_introduction.png)
<!-- This is where the inserted part of all callout blocks start - as an example-->
::: {.callout-note}
Note that there are five types of callouts, including:
`note`, `warning`, `important`, `tip`, and `caution`.
:::
This is an example
::: {.callout-warning}
This is an warning of a callout with a title.
:::
This is an example
::: {.callout-important}
Note that there are five types of callouts, including:
`note`, `warning`, `important`, `tip`, and `caution`.
:::
This is an example
::: {.callout-tip}
This is an example of a callout with a title.
:::
::: {.content-visible when-format="html"}
::: {.callout-caution collapse="true"}
This is an example of a 'folded' caution callout that can be expanded by the user. You can use `collapse="true"` to collapse it by default or `collapse="false"` to make a collapsible callout that is expanded by default.
:::
:::
This is an example of a 'folded' caution callout that can be expanded by the user.
::: {.callout-resource-slides #resource-slides-basics-1}
As concerns about computational costs and environmental impact grow, there's an increasing focus on making ML systems more efficient.
:::
This is an example
::: {.callout-resource-videos #resource-videos-basics-1}
One of the most significant trends is the democratization of AI technology. Just as personal computers transformed computing from specialized mainframes to everyday tools,
:::
This is an example
::: {.callout-resource-exercises #resource-exercises-basics-1}
This democratization is enabling new applications across industries, from small businesses using AI for customer service to researchers applying ML to previously intractable problems.
:::
::: {.callout-quiz-question #quiz-question-sec-introduction-ai-ml-basics-041a}
1. What is the primary distinction between Artificial Intelligence (AI) and Machine Learning (ML)?
A) AI focuses on creating intelligent behavior, while ML is about implementing intelligence through predetermined rules.
See Answer \ref{quiz-answer-sec-introduction-ai-ml-basics-041a}.
:::
::: {.callout-quiz-answer #quiz-answer-sec-introduction-ai-ml-basics-041a}
1. **What is the primary distinction between Artificial Intelligence (AI) and Machine Learning (ML)?**
A) AI focuses on creating intelligent behavior, while ML is about implementing intelligence through predetermined rules.
:::
<!-- This is where the inserted part of all callout blocks ends - as an example-->
## AI Pervasiveness {#sec-introduction-ai-pervasiveness-43b2}
Artificial Intelligence (AI) has emerged as one of the most transformative forces in human history. From the moment we wake up to when we go to sleep, AI systems invisibly shape our world. They manage traffic flows in our cities, optimize power distribution across electrical grids, and enable billions of wireless devices to communicate seamlessly. In hospitals, AI analyzes medical images and helps doctors diagnose diseases. In research laboratories, it accelerates scientific discovery by simulating molecular interactions and processing vast datasets from particle accelerators. In space exploration, it helps rovers navigate distant planets and telescopes detect new celestial phenomena.
::: {.callout-resource-slides #resource-slides-basics-1}
As concerns about computational costs and environmental impact grow, there's an increasing focus on making ML systems more efficient. Researchers are developing new techniques for training models with less data and computing power. Innovation in specialized hardware, from improved GPUs to custom AI chips, is making ML systems faster and more energy-efficient. These advances could make sophisticated AI capabilities available on more devices, from smartphones to IoT sensors.
:::
::: {.callout-resource-videos #resource-videos-basics-1}
One of the most significant trends is the democratization of AI technology. Just as personal computers transformed computing from specialized mainframes to everyday tools, ML systems are becoming more accessible to developers and organizations of all sizes. Cloud providers now offer pre-trained models and automated ML platforms that reduce the expertise needed to deploy AI solutions. This democratization is enabling new applications across industries, from small businesses using AI for customer service to researchers applying ML to previously intractable problems.
:::
Throughout history, certain technologies have fundamentally transformed human civilization, defining their eras. The 18th and 19th centuries were shaped by the Industrial Revolution, where steam power and mechanization transformed how humans could harness physical energy. The 20th century was defined by the Digital Revolution, where the computer and internet transformed how we process and share information. Now, the 21st century appears to be the era of Artificial Intelligence, a shift noted by leading thinkers in technological evolution [@brynjolfsson2014second; @domingos2015master].
::: {.callout-resource-exercises #resource-exercises-basics-1}
One of the most significant trends is the democratization of AI technology. Just as personal computers transformed computing from specialized mainframes to everyday tools, ML systems are becoming more accessible to developers and organizations of all sizes. Cloud providers now offer pre-trained models and automated ML platforms that reduce the expertise needed to deploy AI solutions. This democratization is enabling new applications across industries, from small businesses using AI for customer service to researchers applying ML to previously intractable problems.
:::
The vision driving AI development extends far beyond the practical applications we see today. We aspire to create systems that can work alongside humanity, enhancing our problem-solving capabilities and accelerating scientific progress. Imagine AI systems that could help us understand consciousness, decode the complexities of biological systems, or unravel the mysteries of dark matter. Consider the potential of AI to help address global challenges like climate change, disease, or sustainable energy production. This is not just about automation or efficiency—it's about expanding the boundaries of human knowledge and capability.
The impact of this revolution operates at multiple scales, each with profound implications. At the individual level, AI personalizes our experiences and augments our daily decision-making capabilities. At the organizational level, it transforms how businesses operate and how research institutions make discoveries. At the societal level, it reshapes everything from transportation systems to healthcare delivery. At the global level, it offers new approaches to addressing humanity's greatest challenges, from climate change to drug discovery.
@@ -715,9 +774,6 @@ Each pillar represents a critical phase in the lifecycle of ML systems and is co
For more detailed information about the book's overview, contents, learning outcomes, target audience, prerequisites, and navigation guide, please refer to the [About the Book](../../frontmatter/about/about.qmd) section. There, you'll also find valuable details about our learning community and how to maximize your experience with this resource.
## Quiz Answers
:::{.callout-quiz-answer #quiz-answer-sec-introduction-ai-ml-basics-86ee}

View File

@@ -1284,11 +1284,6 @@ To reinforce the concepts covered in this chapter, we have curated a set of exer
- *Coming soon.*
:::
## Quiz Answers
:::{.callout-quiz-answer #quiz-answer-sec-ml-systems-cloudbased-machine-learning-9ee3}

View File

@@ -499,7 +499,6 @@ libcamera-hello --list-cameras
\noindent
![](images/jpeg/list_cams_raspi-zero.jpg)
\noindent
![](images/png/list_cams_raspi-5.png)

View File

@@ -0,0 +1,20 @@
import sys
for filepath in sys.argv[1:]:
with open(filepath, encoding="utf-8") as f:
lines = f.readlines()
new_lines = []
blank = False
for line in lines:
if line.strip() == "":
if not blank:
new_lines.append(line)
blank = True
else:
new_lines.append(line)
blank = False
with open(filepath, "w", encoding="utf-8") as f:
f.writelines(new_lines)

View File

@@ -28,7 +28,7 @@
\usepackage{sidenotes}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage[explicit]{titlesec}
\usepackage[explicit,newparttoc]{titlesec}%
\usepackage{tocloft}
\usepackage[dvipsnames]{xcolor}
\usepackage{changepage}
@@ -191,27 +191,6 @@ aboveskip=0pt
pdfstartview=Fit % This sets the initial zoom to fit the page
}
%\renewcommand{\part}[1]{%
% \chapter*{#1} % Render the part title without a number
% \addcontentsline{toc}{part}{#1} % Add to TOC without numbering
%}
% % Redefine \part to do nothing
% \renewcommand{\part}[1]{%
% \typeout{Skipping \detokenize{#1}}% Print message in the log file
% }
% % Ensure \partname is defined, just in case it's referenced elsewhere
% \renewcommand{\partname}{}
% % Redefine \part (if you want to apply the Crimson color here)
% \titleformat{\part}[display]
% {\normalfont\Huge\bfseries\color{crimson}} % Set the color to crimson
% {\partname~\thepart}
% {0pt}
% {\Huge}
% [\vspace{20pt}]
% --- Summary text that will be written below \part
\newcommand{\partsummary}{} % empty by default
\newif\ifhaspartsummary%
@@ -225,39 +204,6 @@ aboveskip=0pt
\definecolor{BrownLL}{RGB}{233,222,220}
\definecolor{BlueDD}{RGB}{62,100,125}
\colorlet{BlueDD}{magenta}
\titleformat{\part}[display]
{\thispagestyle{empty}}{}{20pt}{
\begin{tikzpicture}[remember picture,overlay]
%%%
\coordinate(S1)at([yshift=-200mm]current page.north west);
\draw[draw=none,fill=BlueDD!7](S1)--++(45:16)coordinate(S2)-
|(S2|-current page.north west)--(current page.north west)coordinate(S3)--(S1);
%
\coordinate(E1)at([yshift=-98mm]current page.north west);
\draw[draw=none,fill=BlueDD!15](E1)--(current page.north west)coordinate(E2)
--++(0:98mm)coordinate(E3)--(E1);
%
\coordinate(D1)at([yshift=15mm]current page.south west);
\draw[draw=none,fill=BlueDD!40,opacity=0.5](D1)--++(45:5.5)coordinate(D2)
-|(D2|-current page.north west)--(current page.north west)coordinate(D3)--(D1);
%%%%
\path[red](S2)-|(S2-|current page.east)coordinate(SS2);
%PART
\node[crimson,align=flush right,inner sep=0,outer sep=0mm,draw=none,anchor=south,
font={\fontsize{48pt}{48}\selectfont\bfseries}] (BG) at ($(S2)!0.5!(SS2)$){\thepart};%\hphantom{Part}};
%%%
\path[green]([yshift=15mm]D2)-|coordinate(TPD)(BG.south east);
\node[inner sep=0mm,draw=none,anchor=south east,text width=1\textwidth,
align=flush right,font={\fontsize{40pt}{40}\selectfont}]
(BGG) at (TPD) {\color{crimson}\MakeUppercase {#1}};%\MakeUppercase {}
%
\ifhaspartsummary
\node[inner sep=4pt,text width=0.9\textwidth,draw=none,fill=BrownLL!40,
align=justify,font={\fontsize{9pt}{12}\selectfont},below=of TPD,anchor=north east]
(PS) {\partsummary};
\fi
\end{tikzpicture}
}
\titleformat{\part}[display]
{\thispagestyle{empty}}{}{20pt}{
@@ -326,7 +272,6 @@ align=right,font={\fontsize{40pt}{40}\selectfont}]
\end{tikzpicture}
}
% Redefine \section
\titleformat{\section}
{\normalfont\Large\bfseries\color{crimson}\raggedright} % Set the color to crimson
@@ -400,12 +345,21 @@ align=right,font={\fontsize{40pt}{40}\selectfont}]
\renewcommand{\cftchappresnum}{\color{crimson}Chapter~} % Adds "Chapter" in crimson
% Customize TOC part format
\renewcommand{\cftpartpresnum}{Part}
\newlength{\xpartspace}
\settowidth{\xpartspace}{\cftpartpresnum}
\addtolength{\cftpartnumwidth}{\xpartspace}
\cftpagenumbersoff{part}
\setlength{\cftpartnumwidth}{0pt}
\makeatletter
\renewcommand{\cftpartfont}{\hfil\bfseries\color{crimson}}
\renewcommand{\cftpartpresnum}{\begin{lrbox}{\@tempboxa}}
\renewcommand{\cftpartaftersnum}{\end{lrbox}\hfil}
\renewcommand{\cftpartpresnum}{%
\begin{lrbox}{\@tempboxa}%
\bfseries\color{crimson}Part~~\thepart%
\end{lrbox}%
\usebox{\@tempboxa}%
}
\renewcommand{\cftpartaftersnum}{\hfil}
\makeatother
% Ensure correct spacing for TOC numbering