Initial commit
This commit is contained in:
721
skills/ppt/references/beamer.md
Executable file
721
skills/ppt/references/beamer.md
Executable file
@@ -0,0 +1,721 @@
|
||||
# Route: LaTeX Beamer → PDF (via Tectonic)
|
||||
|
||||
Write LaTeX Beamer source, then compile to PDF:
|
||||
|
||||
```bash
|
||||
python3 scripts/pdf.py convert.latex main.tex
|
||||
python3 scripts/pdf.py convert.latex main.tex --runs 2 # for ToC / refs
|
||||
```
|
||||
|
||||
Tectonic compiles the full Beamer document — all features work: overlays,
|
||||
TikZ, custom themes, math, transitions, fragile frames, appendix.
|
||||
|
||||
---
|
||||
|
||||
## 1. Compilation
|
||||
|
||||
```bash
|
||||
# Standard build
|
||||
python3 scripts/pdf.py convert.latex main.tex
|
||||
|
||||
# Two passes (resolves ToC, \ref, section counters in overlays)
|
||||
python3 scripts/pdf.py convert.latex main.tex --runs 2
|
||||
|
||||
# Verbose log (see all Tectonic output)
|
||||
python3 scripts/pdf.py convert.latex main.tex --keep-logs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Beamer Document Structure
|
||||
|
||||
### Minimal Working Example
|
||||
|
||||
```latex
|
||||
\documentclass[aspectratio=169, 11pt]{beamer}
|
||||
\usepackage[fontset=fandol]{ctex} % CJK support (Tectonic auto-downloads)
|
||||
\usetheme{Madrid}
|
||||
|
||||
\title{Introduction to Quantum Computing}
|
||||
\author{Prof. Zhang}
|
||||
\institute{Tsinghua University}
|
||||
\date{\today}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\begin{frame}
|
||||
\titlepage
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Table of Contents}
|
||||
\tableofcontents
|
||||
\end{frame}
|
||||
|
||||
\section{Quantum Bits}
|
||||
|
||||
\begin{frame}{Quantum States}
|
||||
\[ |\psi\rangle = \alpha|0\rangle + \beta|1\rangle, \quad |\alpha|^2+|\beta|^2=1 \]
|
||||
\end{frame}
|
||||
|
||||
\end{document}
|
||||
```
|
||||
|
||||
**Core elements:**
|
||||
- `\documentclass{beamer}` — Presentation document class
|
||||
- Preamble — Theme, colors, fonts, global settings
|
||||
- `\begin{frame}...\end{frame}` — Each frame = one slide
|
||||
|
||||
---
|
||||
|
||||
## 3. Theme System (Complete Reference)
|
||||
|
||||
Beamer themes consist of five independent layers that can be freely combined:
|
||||
|
||||
### 3.1 Presentation Themes (control overall layout)
|
||||
|
||||
| Theme | Features | Suitable For |
|
||||
|---|---|---|
|
||||
| `default` | Minimal, no decoration | Formal academic, minimalist |
|
||||
| `Madrid` | Bottom info bar + section navigation | University courses, academic talks |
|
||||
| `Berlin` | Top mini-frames + side color blocks | Long technical presentations |
|
||||
| `Warsaw` | Top circular navigation + gradient title | Structured content |
|
||||
| `CambridgeUS` | Two-tone minimalist | Math-heavy presentations |
|
||||
| `Boadilla` | Clean footer | Business, concise style |
|
||||
| `Singapore` | Top dot navigation | Modern feel, multi-section |
|
||||
| `AnnArbor` | Yellow-blue dual tone | Michigan style |
|
||||
| `Antibes` | Blue sidebar tree | Multi-subsection structure |
|
||||
| `Bergen` | Blue title bar | Formal academic |
|
||||
| `Copenhagen` | Top bar + navigation | Classic blue scheme |
|
||||
| `Darmstadt` | Top progress dots | Multi-section structure |
|
||||
| `Dresden` | Top mini-frames | Similar to Berlin |
|
||||
| `Frankfurt` | Top dots | Clear section structure |
|
||||
| `Goettingen` | Right sidebar | Navigation-focused |
|
||||
| `Luebeck` | Top blue bar | Clean modern |
|
||||
| `Malmoe` | Minimal title | Content-first |
|
||||
| `Montpellier` | Top tree navigation | Hierarchical content |
|
||||
| `Pittsburgh` | No color blocks, minimal | White scheme |
|
||||
| `Rochester` | Dark title | Dark scheme |
|
||||
| `Szeged` | Blue title bar | Hungarian style |
|
||||
|
||||
```latex
|
||||
\usetheme{Madrid}
|
||||
```
|
||||
|
||||
### 3.2 Color Themes
|
||||
|
||||
| Color Theme | Dominant Color |
|
||||
|---|---|
|
||||
| `default` | Dark blue |
|
||||
| `albatross` | Yellow tones |
|
||||
| `beaver` | Dark red / maroon |
|
||||
| `beetle` | Gray-blue |
|
||||
| `crane` | Orange-yellow |
|
||||
| `dolphin` | Blue-white |
|
||||
| `dove` | Gray-white (near monochrome) |
|
||||
| `fly` | Gray tones |
|
||||
| `lily` | Red-blue |
|
||||
| `orchid` | Purple tones |
|
||||
| `rose` | Pink |
|
||||
| `seagull` | Gray |
|
||||
| `seahorse` | Blue-purple |
|
||||
| `whale` | Deep sea blue |
|
||||
| `wolverine` | Yellow-blue contrast |
|
||||
|
||||
```latex
|
||||
\usecolortheme{dolphin}
|
||||
```
|
||||
|
||||
### 3.3 Font Themes
|
||||
|
||||
```latex
|
||||
\usefonttheme{default} % Sans-serif (Beamer default)
|
||||
\usefonttheme{serif} % Serif font (academic feel)
|
||||
\usefonttheme{structurebold} % Bold structural elements
|
||||
\usefonttheme{structureitalic} % Italic structural elements
|
||||
\usefonttheme{structuresmallcapsserif} % Small caps serif
|
||||
\usefonttheme{professionalfonts} % Keep math fonts unchanged
|
||||
```
|
||||
|
||||
### 3.4 Inner Themes (control list, block, and title styles)
|
||||
|
||||
```latex
|
||||
\useinnertheme{default} % Triangle bullet points
|
||||
\useinnertheme{circles} % Circle bullet points
|
||||
\useinnertheme{rectangles} % Square bullet points
|
||||
\useinnertheme{rounded} % Rounded blocks
|
||||
\useinnertheme{inmargin} % Margin numbers
|
||||
```
|
||||
|
||||
### 3.5 Outer Themes (control header, footer, and sidebar)
|
||||
|
||||
```latex
|
||||
\useoutertheme{default} % No decoration
|
||||
\useoutertheme{infolines} % Bottom three-column info
|
||||
\useoutertheme{miniframes} % Top mini-frame navigation
|
||||
\useoutertheme{shadow} % Shadow title
|
||||
\useoutertheme{sidebar} % Sidebar
|
||||
\useoutertheme{smoothbars} % Gradient top bar
|
||||
\useoutertheme{smoothtree} % Gradient tree
|
||||
\useoutertheme{split} % Top-bottom split
|
||||
\useoutertheme{tree} % Tree navigation
|
||||
```
|
||||
|
||||
### 3.6 Custom Colors
|
||||
|
||||
```latex
|
||||
\definecolor{myblue}{HTML}{2B5EA7}
|
||||
\definecolor{mygray}{HTML}{F0F0F0}
|
||||
|
||||
\setbeamercolor{frametitle}{bg=myblue, fg=white}
|
||||
\setbeamercolor{structure}{fg=myblue}
|
||||
\setbeamercolor{block title}{bg=myblue!85, fg=white}
|
||||
\setbeamercolor{block body}{bg=myblue!8}
|
||||
\setbeamercolor{alerted text}{fg=red!70!black}
|
||||
\setbeamercolor{title}{fg=white}
|
||||
\setbeamercolor{subtitle}{fg=white!80}
|
||||
```
|
||||
|
||||
### 3.7 Common Template Customizations
|
||||
|
||||
```latex
|
||||
% Remove navigation symbols (almost always needed)
|
||||
\setbeamertemplate{navigation symbols}{}
|
||||
|
||||
% Custom footer (frame number)
|
||||
\setbeamertemplate{footline}{%
|
||||
\hfill\insertframenumber/\inserttotalframenumber\hspace{1em}\vspace{0.5em}
|
||||
}
|
||||
|
||||
% Custom bullet points
|
||||
\setbeamertemplate{itemize item}{\textbullet}
|
||||
\setbeamertemplate{itemize subitem}{--}
|
||||
|
||||
% Logo (bottom-right corner)
|
||||
\logo{\includegraphics[height=0.7cm]{logo.png}}
|
||||
|
||||
% Rounded blocks
|
||||
\setbeamertemplate{blocks}[rounded][shadow=true]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Overlays & Stepwise Reveal
|
||||
|
||||
Tectonic fully supports all overlay syntax — rendered as separate pages in the PDF.
|
||||
|
||||
### 4.1 Basic Overlay Specifications
|
||||
|
||||
```latex
|
||||
\item<1-> % Show from layer 1, persist
|
||||
\item<2-> % Show from layer 2
|
||||
\item<1-3> % Show on layers 1 to 3 only
|
||||
\item<2> % Show on layer 2 only
|
||||
\item<-3> % Show before layer 3
|
||||
```
|
||||
|
||||
### 4.2 \pause — Simplest Stepwise Reveal
|
||||
|
||||
```latex
|
||||
\begin{frame}{Research Workflow}
|
||||
Data collection phase
|
||||
\pause
|
||||
Feature engineering phase
|
||||
\pause
|
||||
Model training phase
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 4.3 List Stepwise Reveal
|
||||
|
||||
```latex
|
||||
\begin{frame}{Research Contributions}
|
||||
\begin{itemize}
|
||||
\item<1-> Propose a novel loss function
|
||||
\item<2-> Prove theoretical convergence
|
||||
\item<3-> Outperform SOTA on five benchmarks
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 4.4 \only vs \uncover vs \visible
|
||||
|
||||
```latex
|
||||
% \only: no space reserved (causes layout jump)
|
||||
\only<1>{Step one explanation}
|
||||
\only<2>{Step two explanation}
|
||||
|
||||
% \uncover: reserves space but transparent (recommended, stable layout)
|
||||
\uncover<2->{Follow-up steps explanation}
|
||||
|
||||
% \visible: reserves space but not rendered
|
||||
\visible<3->{Step three}
|
||||
```
|
||||
|
||||
### 4.5 \alert — Highlight Specific Layers
|
||||
|
||||
```latex
|
||||
\begin{frame}{Key Findings}
|
||||
\begin{itemize}
|
||||
\item \alert<1>{Accuracy improved by 13\%}
|
||||
\item \alert<2>{Inference speed improved 2.4x}
|
||||
\item \alert<3>{Memory reduced by 40\%}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 4.6 \textcolor & Conditional Content
|
||||
|
||||
```latex
|
||||
\begin{frame}{Comparison}
|
||||
Baseline method: \textcolor{red}{82\%}\\
|
||||
\only<2->{Our method: \textcolor{green!60!black}{\textbf{93\%}}}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 4.7 Block Overlays
|
||||
|
||||
```latex
|
||||
\begin{frame}{Analysis}
|
||||
\begin{block}<1-2>{Problem Definition}
|
||||
Formal description ...
|
||||
\end{block}
|
||||
\begin{block}<2->{Solution}
|
||||
Core approach ...
|
||||
\end{block}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Content Layout Templates
|
||||
|
||||
### 5.1 Block Series (Three Styles)
|
||||
|
||||
```latex
|
||||
\begin{frame}{Core Findings}
|
||||
\begin{block}{Main Conclusion}
|
||||
The new method outperforms baselines in both accuracy and speed.
|
||||
\end{block}
|
||||
|
||||
\begin{alertblock}{Caveats}
|
||||
Results are validated on specific datasets; generalization needs further study.
|
||||
\end{alertblock}
|
||||
|
||||
\begin{exampleblock}{Example}
|
||||
Achieved 99.1\% accuracy on the MNIST dataset.
|
||||
\end{exampleblock}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 5.2 Column Layout
|
||||
|
||||
```latex
|
||||
\begin{frame}{Experimental Comparison}
|
||||
\begin{columns}[T] % [T] top-aligned
|
||||
\column{0.48\textwidth}
|
||||
\begin{block}{Baseline Method}
|
||||
Accuracy: 82\% \\
|
||||
Time: 3.2 hours
|
||||
\end{block}
|
||||
|
||||
\column{0.48\textwidth}
|
||||
\begin{block}{Our Method}
|
||||
Accuracy: \textbf{91\%} \\
|
||||
Time: \textbf{1.7 hours}
|
||||
\end{block}
|
||||
\end{columns}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
Column alignment options: `[T]` top-aligned · `[c]` centered · `[b]` bottom-aligned
|
||||
|
||||
### 5.3 Math Formula Frame
|
||||
|
||||
```latex
|
||||
\begin{frame}{Loss Function}
|
||||
\begin{equation*}
|
||||
\mathcal{L} = -\sum_{i=1}^{N} y_i \log \hat{y}_i + \lambda \|\theta\|_2^2
|
||||
\end{equation*}
|
||||
\begin{itemize}
|
||||
\item $y_i$: Ground truth label
|
||||
\item $\hat{y}_i$: Predicted probability
|
||||
\item $\lambda$: Regularization coefficient
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 5.4 Theorem Environment
|
||||
|
||||
```latex
|
||||
\begin{frame}{Convergence Theorem}
|
||||
\begin{theorem}[Convergence Rate]
|
||||
Under Lipschitz conditions, gradient descent converges at $O(1/\sqrt{T})$.
|
||||
\end{theorem}
|
||||
|
||||
\begin{proof}
|
||||
Follows from Lipschitz continuity and step size $\eta = 1/L$.\qed
|
||||
\end{proof}
|
||||
|
||||
\begin{corollary}
|
||||
The stochastic gradient variant converges in expectation at $O(1/\sqrt{T})$.
|
||||
\end{corollary}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 5.5 Table Frame
|
||||
|
||||
```latex
|
||||
\begin{frame}{Performance Comparison}
|
||||
\centering
|
||||
\begin{tabular}{lcc}
|
||||
\toprule
|
||||
Method & Accuracy & Time(s) \\
|
||||
\midrule
|
||||
SVM & 0.85 & 120 \\
|
||||
Random Forest & 0.89 & 65 \\
|
||||
\textbf{Ours} & \textbf{0.93} & \textbf{42} \\
|
||||
\bottomrule
|
||||
\end{tabular}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 5.6 TikZ Flowchart
|
||||
|
||||
TikZ is fully supported in Tectonic — no pre-rendering needed:
|
||||
|
||||
```latex
|
||||
\begin{frame}{Algorithm Pipeline}
|
||||
\centering
|
||||
\begin{tikzpicture}[
|
||||
node distance=2cm,
|
||||
box/.style={rectangle, rounded corners=4pt, draw=myblue, thick,
|
||||
fill=myblue!10, minimum width=2.2cm, minimum height=0.9cm, font=\small},
|
||||
arr/.style={-Stealth, thick, myblue}
|
||||
]
|
||||
\node[box] (A) {Input Data};
|
||||
\node[box, right of=A] (B) {Feature Extraction};
|
||||
\node[box, right of=B] (C) {Model Inference};
|
||||
\node[box, right of=C] (D) {Output Results};
|
||||
\draw[arr] (A) -- (B);
|
||||
\draw[arr] (B) -- (C);
|
||||
\draw[arr] (C) -- (D);
|
||||
\end{tikzpicture}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 5.7 Code Display Frame
|
||||
|
||||
```latex
|
||||
\begin{frame}[fragile]{Training Loop} % [fragile] is required
|
||||
\begin{verbatim}
|
||||
for epoch in range(epochs):
|
||||
for batch in dataloader:
|
||||
optimizer.zero_grad()
|
||||
loss = model(batch)
|
||||
loss.backward()
|
||||
optimizer.step()
|
||||
\end{verbatim}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
Or use `listings` for syntax highlighting (more polished):
|
||||
|
||||
```latex
|
||||
\usepackage{listings}
|
||||
\lstset{
|
||||
basicstyle=\ttfamily\small,
|
||||
keywordstyle=\color{blue}\bfseries,
|
||||
commentstyle=\color{gray},
|
||||
backgroundcolor=\color{gray!5},
|
||||
numbers=left, numberstyle=\tiny\color{gray},
|
||||
frame=single, framerule=0.5pt
|
||||
}
|
||||
|
||||
\begin{frame}[fragile]{Python Code}
|
||||
\begin{lstlisting}[language=Python]
|
||||
def train(model, dataloader):
|
||||
for batch in dataloader:
|
||||
loss = model(batch)
|
||||
loss.backward()
|
||||
\end{lstlisting}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 5.8 Image Frame
|
||||
|
||||
```latex
|
||||
\begin{frame}{System Architecture}
|
||||
\centering
|
||||
\includegraphics[width=0.85\textwidth]{figures/architecture.png}
|
||||
\captionof{figure}{End-to-end training pipeline}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 5.9 Custom Checklist Frame
|
||||
|
||||
```latex
|
||||
\begin{frame}{Summary of Contributions}
|
||||
\begin{itemize}
|
||||
\item[\checkmark] New method proposed: ...
|
||||
\item[\checkmark] Theoretical proof: ...
|
||||
\item[\checkmark] Experimental validation: ...
|
||||
\item[$\square$] Future work: ...
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Advanced Features
|
||||
|
||||
### 6.1 Progress Bar (Manual Implementation)
|
||||
|
||||
```latex
|
||||
% Define in preamble
|
||||
\definecolor{progressbar}{HTML}{2B5EA7}
|
||||
\setbeamertemplate{footline}{
|
||||
\begin{beamercolorbox}[wd=\paperwidth,ht=2pt]{progressbar}
|
||||
\rule{\dimexpr\paperwidth*\insertframenumber/\inserttotalframenumber}{2pt}
|
||||
\end{beamercolorbox}
|
||||
\vspace{2pt}
|
||||
\hfill\tiny\insertframenumber/\inserttotalframenumber\hspace{1em}\vspace{3pt}
|
||||
}
|
||||
```
|
||||
|
||||
### 6.2 Section Title Pages (Automatic)
|
||||
|
||||
```latex
|
||||
% Add in preamble — auto-inserts a section title page before each \section
|
||||
\AtBeginSection[]{
|
||||
\begin{frame}
|
||||
\vfill
|
||||
\centering
|
||||
\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
|
||||
\usebeamerfont{title}\insertsectionhead\par
|
||||
\end{beamercolorbox}
|
||||
\vfill
|
||||
\end{frame}
|
||||
}
|
||||
```
|
||||
|
||||
### 6.3 Handout Mode
|
||||
|
||||
```latex
|
||||
% Generate overlay-free handout version (only final state of each frame)
|
||||
\documentclass[handout, aspectratio=169]{beamer}
|
||||
```
|
||||
|
||||
Combine with `pgfpages` to compress multiple frames onto one page:
|
||||
|
||||
```latex
|
||||
\usepackage{pgfpages}
|
||||
\pgfpagesuselayout{4 on 1}[a4paper, border shrink=5mm]
|
||||
```
|
||||
|
||||
### 6.4 Frame Reuse (\againframe)
|
||||
|
||||
```latex
|
||||
\begin{frame}[label=keyresult]{Key Result}
|
||||
Accuracy improved by 13\%.
|
||||
\end{frame}
|
||||
|
||||
% Show again at any later point
|
||||
\againframe{keyresult}
|
||||
```
|
||||
|
||||
### 6.5 Appendix (Excluded from Total Page Count)
|
||||
|
||||
```latex
|
||||
\appendix
|
||||
|
||||
\begin{frame}{Appendix: Detailed Derivation}
|
||||
% Backup slides for Q&A
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
### 6.6 Speaker Notes
|
||||
|
||||
```latex
|
||||
\begin{frame}{Main Conclusions}
|
||||
\begin{itemize}
|
||||
\item Conclusion one
|
||||
\item Conclusion two
|
||||
\end{itemize}
|
||||
\note{
|
||||
Emphasize the data supporting conclusion one.\\
|
||||
Anticipate questions about dataset size.
|
||||
}
|
||||
\end{frame}
|
||||
```
|
||||
|
||||
Output PDF with notes: add in preamble:
|
||||
```latex
|
||||
\setbeameroption{show notes on second screen=right}
|
||||
```
|
||||
|
||||
### 6.7 Widescreen Aspect Ratios
|
||||
|
||||
```latex
|
||||
\documentclass[aspectratio=169]{beamer} % 16:9 (recommended)
|
||||
\documentclass[aspectratio=1610]{beamer} % 16:10
|
||||
\documentclass[aspectratio=43]{beamer} % 4:3 (traditional)
|
||||
\documentclass[aspectratio=141]{beamer} % 1.41:1 (A4)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. Complete Template (Academic Presentation, 16:9, with CJK Support)
|
||||
|
||||
```latex
|
||||
\documentclass[aspectratio=169, 11pt]{beamer}
|
||||
\usepackage[fontset=fandol]{ctex}
|
||||
\usepackage{amsmath, amssymb, mathtools}
|
||||
\usepackage{booktabs}
|
||||
\usepackage{graphicx}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{arrows.meta, positioning, shapes.geometric}
|
||||
|
||||
% -- Theme ---------------------------------------------------------------
|
||||
\usetheme{Madrid}
|
||||
\usecolortheme{dolphin}
|
||||
\usefonttheme{professionalfonts}
|
||||
\setbeamertemplate{navigation symbols}{}
|
||||
|
||||
% -- Colors --------------------------------------------------------------
|
||||
\definecolor{myblue}{HTML}{2B5EA7}
|
||||
\setbeamercolor{frametitle}{bg=myblue, fg=white}
|
||||
\setbeamercolor{structure}{fg=myblue}
|
||||
\setbeamercolor{block title}{bg=myblue!85, fg=white}
|
||||
\setbeamercolor{block body}{bg=myblue!8}
|
||||
|
||||
% -- Auto section title page ---------------------------------------------
|
||||
\AtBeginSection[]{
|
||||
\begin{frame}
|
||||
\vfill\centering
|
||||
\begin{beamercolorbox}[sep=8pt,center,rounded=true]{title}
|
||||
\usebeamerfont{title}\insertsectionhead\par
|
||||
\end{beamercolorbox}
|
||||
\vfill
|
||||
\end{frame}
|
||||
}
|
||||
|
||||
% -- Metadata ------------------------------------------------------------
|
||||
\title{Paper Title}
|
||||
\subtitle{Subtitle}
|
||||
\author{Author Name}
|
||||
\institute{Affiliation}
|
||||
\date{\today}
|
||||
|
||||
% ========================================================================
|
||||
\begin{document}
|
||||
|
||||
\begin{frame}
|
||||
\titlepage
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Table of Contents}
|
||||
\tableofcontents
|
||||
\end{frame}
|
||||
|
||||
\section{Introduction}
|
||||
|
||||
\begin{frame}{Research Background}
|
||||
\begin{itemize}
|
||||
\item<1-> Importance of the problem
|
||||
\item<2-> Limitations of existing methods
|
||||
\item<3-> Contributions of this work
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\section{Method}
|
||||
|
||||
\begin{frame}{Core Formula}
|
||||
\begin{equation*}
|
||||
\mathcal{L} = -\sum_{i=1}^{N} y_i \log \hat{y}_i + \lambda \|\theta\|_2^2
|
||||
\end{equation*}
|
||||
\begin{itemize}
|
||||
\item $y_i$: Ground truth label
|
||||
\item $\hat{y}_i$: Predicted probability
|
||||
\item $\lambda$: Regularization coefficient
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}{Method Comparison}
|
||||
\begin{columns}[T]
|
||||
\column{0.48\textwidth}
|
||||
\begin{block}{Baseline Method}
|
||||
Accuracy: 82\% \\
|
||||
Time: 3.2 hours
|
||||
\end{block}
|
||||
\column{0.48\textwidth}
|
||||
\begin{block}{Our Method}
|
||||
Accuracy: \textbf{91\%} \\
|
||||
Time: \textbf{1.7 hours}
|
||||
\end{block}
|
||||
\end{columns}
|
||||
\end{frame}
|
||||
|
||||
\section{Experiments}
|
||||
|
||||
\begin{frame}{Performance Comparison}
|
||||
\centering
|
||||
\begin{tabular}{lcc}
|
||||
\toprule
|
||||
Method & Accuracy & Time(s) \\
|
||||
\midrule
|
||||
SVM & 0.85 & 120 \\
|
||||
Random Forest & 0.89 & 65 \\
|
||||
\textbf{Ours} & \textbf{0.93} & \textbf{42} \\
|
||||
\bottomrule
|
||||
\end{tabular}
|
||||
\end{frame}
|
||||
|
||||
\section{Conclusion}
|
||||
|
||||
\begin{frame}{Summary}
|
||||
\begin{itemize}
|
||||
\item[\checkmark] Contribution 1: Proposed new method
|
||||
\item[\checkmark] Contribution 2: Theoretical proof
|
||||
\item[\checkmark] Contribution 3: Experimental validation
|
||||
\end{itemize}
|
||||
\begin{block}{Future Work}
|
||||
Extend to larger-scale datasets and explore cross-domain generalization.
|
||||
\end{block}
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\centering\Large Thank You!\\[0.8em]
|
||||
\normalsize Questions Welcome
|
||||
\end{frame}
|
||||
|
||||
\end{document}
|
||||
```
|
||||
|
||||
Compile:
|
||||
```bash
|
||||
python3 scripts/pdf.py convert.latex main.tex --runs 2
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. Common Issues & Fixes
|
||||
|
||||
| Issue | Cause | Fix |
|
||||
|---|---|---|
|
||||
| CJK characters display as boxes | Missing CJK font package | Add `\usepackage[fontset=fandol]{ctex}` |
|
||||
| `??` appears in ToC or references | Only compiled once | Add `--runs 2` |
|
||||
| `[fragile]` missing error | verbatim/lstlisting frame | Add `[fragile]` after `\begin{frame}` |
|
||||
| Overlay not working | Forgot `\pause` or `<n->` in frame | Check overlay specification syntax |
|
||||
| TikZ compilation failure | Missing tikzlibrary | Add `\usetikzlibrary{...}` |
|
||||
| Math font distortion | Missing professionalfonts | Add `\usefonttheme{professionalfonts}` |
|
||||
| Frame exceeds one page (content overflow) | Too much content | Add `[allowframebreaks]` or split frame |
|
||||
|
||||
---
|
||||
|
||||
## 9. Dependencies
|
||||
|
||||
| Tool | Purpose |
|
||||
|---|---|
|
||||
| `scripts/tectonic` | LaTeX compilation engine (local binary) |
|
||||
| `scripts/pdf.py convert.latex` | Tectonic wrapper with log filtering + PDF stats |
|
||||
342
skills/ppt/references/latex.md
Executable file
342
skills/ppt/references/latex.md
Executable file
@@ -0,0 +1,342 @@
|
||||
# Route 3: Academic & Scientific PDF via LaTeX
|
||||
|
||||
Produce publication-grade PDFs from `.tex` source files compiled with Tectonic. Suited for academic papers, theses, mathematical manuscripts, IEEE/ACM-format submissions, and any document where the user explicitly requests LaTeX.
|
||||
|
||||
**Guiding principle**: when someone asks for "a LaTeX PDF," they expect a polished, professional result — not a bare-minimum compilation.
|
||||
|
||||
---
|
||||
|
||||
## Environment Preparation
|
||||
|
||||
|
||||
The binary of Tectonic lands at `scripts/tectonic`.
|
||||
|
||||
### Compilation — Always Use the Wrapper Script
|
||||
|
||||
All compilations **must** go through `scripts/pdf.py convert.latex`. It handles:
|
||||
- Stripping noisy package-download logs
|
||||
- Filtering progress chatter
|
||||
- Surfacing genuine errors and warnings
|
||||
- Reporting PDF statistics (file size, page count, word estimate, image tally)
|
||||
|
||||
**Do not invoke Tectonic directly.**
|
||||
|
||||
```bash
|
||||
# One-pass build
|
||||
python3 scripts/pdf.py convert.latex main.tex
|
||||
|
||||
# Two passes (resolves cross-references)
|
||||
python3 scripts/pdf.py convert.latex main.tex --runs 2
|
||||
|
||||
# Verbose mode (retains full log output)
|
||||
python3 scripts/pdf.py convert.latex main.tex --keep-logs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pre-Writing Planning
|
||||
|
||||
Before touching `.tex` code, determine the document's category and let that shape your approach.
|
||||
|
||||
### Recognising the Document Type
|
||||
|
||||
| Type | Typical outputs | Key concern |
|
||||
|------|----------------|-------------|
|
||||
| **Scholarly** | Journal articles, conference proceedings, regulatory specs | Rigorous adherence to academic conventions; bibliography accuracy |
|
||||
| **Utilitarian** | Technical reports, reference manuals, product specs | Pack maximum information while preserving scannability |
|
||||
| **Persuasive** | Funding proposals, pitch documents, project roadmaps | Clean professionalism throughout, with one or two visual high-points (title page, KPI dashboards) |
|
||||
| **Expressive** | Design portfolios, brand guidebooks, showcases | Bold typographic and chromatic choices; deliberate rule-breaking that amplifies impact |
|
||||
|
||||
### Fallback Aesthetic (No Style Specified)
|
||||
|
||||
When the user gives no visual direction, apply a **measured, high-craft** system:
|
||||
|
||||
1. **Contrast** — clear figure-ground separation; headings visually distinct from running text
|
||||
2. **Hierarchy** — establish reading order through deliberate variation in size, weight, and hue
|
||||
3. **White space** — ample margins and leading to let the page breathe
|
||||
4. **Coherence** — one typeface family, one accent colour, one spacing rhythm
|
||||
|
||||
#### Enrichment Elements (Add Proactively When Appropriate)
|
||||
|
||||
- **Decorative**: shaded callout boxes, sidebars, comparison panels → `tcolorbox`
|
||||
- **Scholarly**: theorem / definition / proof environments → `amsthm` + `tcolorbox`; process diagrams → TikZ
|
||||
- **Page furniture**: running headers and footers → `fancyhdr`; chapter openers → `titlesec`
|
||||
|
||||
Introduce these components on your own initiative whenever the content benefits — don't wait to be told.
|
||||
|
||||
---
|
||||
|
||||
## Mandatory Rules
|
||||
|
||||
### Rule 1 — Every Build Diagnostic Demands Attention
|
||||
|
||||
The wrapper classifies compiler output into three tiers:
|
||||
|
||||
| Tier | Impact | Required response |
|
||||
|------|--------|-------------------|
|
||||
| **Errors** | Build aborts | Resolve before anything else |
|
||||
| **Layout defects** | Overfull / underfull boxes, unavailable font shapes, missing glyphs | Repair prior to delivery |
|
||||
| **Advisories** | Remaining warnings | Assess individually; fix whenever feasible |
|
||||
|
||||
**Never acceptable**: shrugging off warnings with "they don't affect the final PDF." Every diagnostic merits investigation.
|
||||
|
||||
### Rule 2 — Modular Files for Larger Works
|
||||
|
||||
A single generation turn can comfortably handle roughly **500 lines** of TeX.
|
||||
|
||||
**When to split**:
|
||||
- Anticipated output exceeds 5 pages, **or**
|
||||
- Three or more heavyweight elements are present (wide tables, block equations, TikZ graphics)
|
||||
|
||||
Stitch modules together with `\input{chapter1}`, `\input{chapter2}`, etc.
|
||||
|
||||
### Rule 3 — Foundation Preamble
|
||||
|
||||
```latex
|
||||
\documentclass{article}
|
||||
|
||||
% Essentials
|
||||
\usepackage{graphicx}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{geometry}
|
||||
\usepackage{amsmath} % Load before hyperref
|
||||
|
||||
% hyperref — ALWAYS last among content packages
|
||||
\usepackage[
|
||||
colorlinks=true,
|
||||
linkcolor=blue,
|
||||
citecolor=darkgray,
|
||||
urlcolor=blue,
|
||||
bookmarks=true,
|
||||
bookmarksnumbered=true,
|
||||
unicode=true
|
||||
]{hyperref}
|
||||
|
||||
% Page dimensions
|
||||
\geometry{a4paper, top=2.5cm, bottom=2.5cm, left=3cm, right=2.5cm}
|
||||
% CV variant: \geometry{a4paper, margin=1.5cm}
|
||||
|
||||
% Superscript citation numbers (scholarly convention)
|
||||
\usepackage[numbers,super,sort&compress]{natbib}
|
||||
\bibliographystyle{unsrtnat}
|
||||
|
||||
% Commonly needed extras
|
||||
\usepackage{tcolorbox}
|
||||
\usepackage{colortbl}
|
||||
\usepackage{booktabs}
|
||||
\usepackage{enumitem}
|
||||
```
|
||||
|
||||
**hyperref positioning**: it must load after virtually every other package to avoid option clashes.
|
||||
|
||||
### Rule 4 — TeX Source Hygiene
|
||||
|
||||
**Prohibited patterns**:
|
||||
- Emoji glyphs (no native LaTeX engine supports them)
|
||||
- Markdown `*asterisk*` formatting (generates compile-time errors)
|
||||
|
||||
**Use instead**:
|
||||
```latex
|
||||
\textbf{bold text}
|
||||
\emph{emphasised text}
|
||||
```
|
||||
|
||||
These are frequent model-generation slips — catch them proactively.
|
||||
|
||||
### Rule 5 — Multi-Language & Font Handling
|
||||
|
||||
- `babel` and `polyglossia` are incompatible — load only one
|
||||
- When using `polyglossia`, ensure `amsmath` appears earlier in the preamble
|
||||
- Tectonic downloads standard LaTeX typefaces automatically (Latin Modern, etc.)
|
||||
- To reference system-installed fonts via `\setmainfont{}`, first probe with `fc-list :lang=ar`
|
||||
- Broadly available choices: DejaVu, Noto typeface families
|
||||
|
||||
### Rule 6 — Clickable Navigation Is Non-Negotiable
|
||||
|
||||
Interactive navigation is a baseline professional expectation.
|
||||
|
||||
#### 6.1 Table of Contents
|
||||
```latex
|
||||
\tableofcontents % Entries are auto-linked courtesy of hyperref
|
||||
\listoffigures
|
||||
\listoftables
|
||||
```
|
||||
|
||||
#### 6.2 Internal Cross-References
|
||||
|
||||
**Attach labels** right after each numbered element:
|
||||
```latex
|
||||
\section{Background}\label{sec:bg}
|
||||
|
||||
\begin{figure}[htbp]
|
||||
\includegraphics{...}
|
||||
\caption{Overview diagram}\label{fig:overview}
|
||||
\end{figure}
|
||||
|
||||
\begin{table}[htbp]
|
||||
\caption{Benchmark results}\label{tab:bench}
|
||||
...
|
||||
\end{table}
|
||||
|
||||
\begin{equation}\label{eq:energy}
|
||||
E = mc^2
|
||||
\end{equation}
|
||||
```
|
||||
|
||||
**Cite these labels** (each produces a live hyperlink):
|
||||
```latex
|
||||
As noted in Section~\ref{sec:bg}...
|
||||
Figure~\ref{fig:overview} illustrates...
|
||||
Table~\ref{tab:bench} summarises...
|
||||
Equation~\eqref{eq:energy} yields... % \eqref auto-wraps in parentheses
|
||||
See page~\pageref{sec:bg}...
|
||||
```
|
||||
|
||||
**Good habits**:
|
||||
- Place a non-breaking space `~` before `\ref` to avoid orphaned line breaks
|
||||
- Prefer `\eqref{}` for equations (auto-wraps the number in parentheses)
|
||||
- Adopt a consistent label-prefix convention: `sec:`, `fig:`, `tab:`, `eq:`, `lst:`
|
||||
|
||||
#### 6.3 Bibliography
|
||||
|
||||
**Superscript numerals (preferred academic style)**:
|
||||
```latex
|
||||
\usepackage[numbers,super,sort&compress]{natbib}
|
||||
\bibliographystyle{unsrtnat}
|
||||
|
||||
Prior work\cite{smith2023} shows... % → shows^[1]
|
||||
Several studies\cite{a,b,c} agree... % → agree^[1–3]
|
||||
|
||||
\bibliography{refs}
|
||||
```
|
||||
|
||||
**Numeric bracket alternative**:
|
||||
```latex
|
||||
\usepackage[numbers]{natbib}
|
||||
\bibliographystyle{plainnat}
|
||||
|
||||
\cite{smith2023} % [1]
|
||||
\citep{smith2023} % (Smith, 2023)
|
||||
\citet{smith2023} % Smith (2023)
|
||||
```
|
||||
|
||||
**biblatex pathway**:
|
||||
```latex
|
||||
\usepackage[backend=biber,style=numeric-comp]{biblatex}
|
||||
\addbibresource{refs.bib}
|
||||
|
||||
Per~\cite{smith2023}...
|
||||
\printbibliography
|
||||
```
|
||||
|
||||
#### 6.4 External Links
|
||||
```latex
|
||||
\url{https://example.com}
|
||||
\href{https://example.com}{Visible label}
|
||||
\href{mailto:a@b.com}{a@b.com}
|
||||
```
|
||||
|
||||
#### 6.5 PDF Metadata & Outline
|
||||
```latex
|
||||
\hypersetup{
|
||||
pdftitle={Document Title},
|
||||
pdfauthor={Author Name},
|
||||
pdfsubject={Topic},
|
||||
pdfkeywords={keyword1, keyword2}
|
||||
}
|
||||
```
|
||||
Bookmark trees are auto-generated from `\section` / `\chapter` hierarchy.
|
||||
|
||||
#### 6.6 Why Multiple Passes Matter
|
||||
|
||||
Label resolution requires at least two compilation passes:
|
||||
```bash
|
||||
# Resolve section / figure / table labels
|
||||
python3 scripts/pdf.py convert.latex main.tex --runs 2
|
||||
|
||||
# Also resolves bibliography back-references
|
||||
python3 scripts/pdf.py convert.latex main.tex --runs 3
|
||||
```
|
||||
|
||||
If `??` placeholders persist after two passes, verify that every `\label` string has an exact `\ref` match.
|
||||
|
||||
#### 6.7 Navigation Troubleshooting
|
||||
|
||||
| Observation | Root cause | Resolution |
|
||||
|-------------|-----------|------------|
|
||||
| `??` in place of numbers | Only a single pass was run | Recompile with `--runs 2` |
|
||||
| All links render in black | hyperref colour options omitted | Enable `colorlinks=true` |
|
||||
| TOC items are not clickable | hyperref package missing | Load the package |
|
||||
| `[?]` beside citations | `.bib` path incorrect or biber step skipped | Confirm path; rebuild |
|
||||
| Bookmark pane empty | `bookmarks` option set to false | Switch to `bookmarks=true` |
|
||||
|
||||
---
|
||||
|
||||
## Package Catalogue
|
||||
|
||||
### Foundational
|
||||
- `hyperref` (Rule 3)
|
||||
- `geometry` (Rule 3)
|
||||
- `listings` — `\lstset{basicstyle=\ttfamily\small, numbers=left, backgroundcolor=\color{gray!5}}`
|
||||
- `enumitem` — `\setlist[itemize]{itemsep=0.3em, leftmargin=1.5em}`
|
||||
|
||||
### Tabular
|
||||
`booktabs` · `longtable` · `multirow` · `array` · `colortbl`
|
||||
|
||||
### Visual & Charting
|
||||
`tikz` · `pgfplots` · `float` · `wrapfig` · `subfig` / `subcaption`
|
||||
|
||||
### International & Typography
|
||||
`fontspec` (XeLaTeX / LuaLaTeX) · `ctex`
|
||||
|
||||
### Mathematical
|
||||
`amsmath` · `amssymb` · `amsthm` · `natbib` · `biblatex` · `siunitx`
|
||||
|
||||
### Algorithmic & Domain-Specific
|
||||
`algorithm` + `algpseudocode` · `chemfig`
|
||||
|
||||
### Page Design
|
||||
`tcolorbox` · `fancyhdr` · `titlesec` · `tocloft` · `multicol` · `setspace` · `microtype` · `parskip` · `adjustbox` · `marginnote`
|
||||
|
||||
### Code Listings
|
||||
`listings` · `minted` (depends on Pygments)
|
||||
|
||||
---
|
||||
|
||||
## Scripts & Backends
|
||||
|
||||
| Script | Purpose |
|
||||
|--------|---------|
|
||||
| `pdf.py convert.latex` | Tectonic wrapper — log sanitisation, error highlighting, PDF metrics |
|
||||
|
||||
| Engine | Notes |
|
||||
|--------|-------|
|
||||
| Tectonic | Stand-alone LaTeX engine; packages are fetched transparently on demand |
|
||||
|
||||
---
|
||||
|
||||
## Operational Notes
|
||||
|
||||
### CJK Without Manual Font Setup
|
||||
Tectonic resolves CJK font bundles on the fly — zero manual installation:
|
||||
|
||||
```latex
|
||||
\usepackage{ctex} % Tectonic pulls the font files automatically
|
||||
```
|
||||
|
||||
### Cold-Start Latency
|
||||
The very first compilation of a new document triggers package downloads:
|
||||
- Initial build: 1–5 min (depends on network speed)
|
||||
- Repeat builds with warm cache: 10–30 s
|
||||
|
||||
### Working Without Internet
|
||||
Previously fetched packages are stored under `~/.cache/Tectonic/`. When offline, only cached packages are available; attempting to use a new one will fail.
|
||||
|
||||
### Tectonic vs a Full TeX Live Installation
|
||||
|
||||
| Dimension | Tectonic | Traditional pdflatex |
|
||||
|-----------|----------|---------------------|
|
||||
| Package acquisition | On-demand, transparent | Manual via `tlmgr` |
|
||||
| Multi-pass compilation | Handled by the engine | Explicit re-invocations required |
|
||||
| Reference resolution | Automatic | Requires bibtex/biber cycles |
|
||||
| Disk footprint | Single binary | Full TeX Live ≈ 4 GB |
|
||||
73
skills/ppt/references/paper-navbar.tex
Executable file
73
skills/ppt/references/paper-navbar.tex
Executable file
@@ -0,0 +1,73 @@
|
||||
% ========================================================================
|
||||
% Paper Presentation Navigation for Beamer
|
||||
% ========================================================================
|
||||
% Usage: \input{paper-navbar.tex} in the preamble (after \usetheme and color definitions)
|
||||
%
|
||||
% Provides:
|
||||
% - Top navigation bar: section names + miniframe dots (no subsection row)
|
||||
% - Bottom footer: Author | Paper Title | Journal, Year | Page number
|
||||
% - All colors follow myblue (adapts to any Preset Color Palette)
|
||||
%
|
||||
% Prerequisites (must be defined before \input):
|
||||
% - \definecolor{myblue}{HTML}{...} (from chosen Preset Color Palette)
|
||||
% - \useoutertheme{miniframes} (required for top navigation)
|
||||
%
|
||||
% Paper metadata setup (in preamble, after \input):
|
||||
% \title[Short Title]{Full Title}
|
||||
% \author[Author (Affiliation)]{Full Author List}
|
||||
% \date[Journal Name, Year]{} % leave empty if no journal: \date[]{}
|
||||
% ========================================================================
|
||||
|
||||
% ── Unify header and footer colors (follow myblue) ─────────────────────
|
||||
% Top navbar: light tint of theme color
|
||||
\setbeamercolor{section in head/foot}{bg=myblue!15, fg=myblue!80!black}
|
||||
\setbeamercolor{subsection in head/foot}{bg=myblue!15, fg=myblue!80!black}
|
||||
% Bottom footer: author/journal/page use light tint, title uses mid tint
|
||||
\setbeamercolor{author in head/foot}{bg=myblue!15, fg=myblue!80!black}
|
||||
\setbeamercolor{title in head/foot}{bg=myblue!30, fg=white}
|
||||
\setbeamercolor{date in head/foot}{bg=myblue!15, fg=myblue!80!black}
|
||||
|
||||
% ── Remove navigation symbols ─────────────────────────────────────────
|
||||
\setbeamertemplate{navigation symbols}{}
|
||||
|
||||
% ── Compress miniframes + remove subsection empty row ─────────────────
|
||||
\makeatletter
|
||||
\let\beamer@writeslidentry@miniframeson=\beamer@writeslidentry
|
||||
\def\beamer@writeslidentry@miniframesoff{%
|
||||
\expandafter\beamer@ifempty\expandafter{\beamer@framestartpage}{}%
|
||||
{\addtocontents{nav}{\protect\headcommand{%
|
||||
\protect\beamer@partpages{\the\c@page}{\the\c@page}}}}}
|
||||
\newcommand*{\miniframeson}{\let\beamer@writeslidentry=\beamer@writeslidentry@miniframeson}
|
||||
\newcommand*{\miniframesoff}{\let\beamer@writeslidentry=\beamer@writeslidentry@miniframesoff}
|
||||
\beamer@compresstrue
|
||||
\makeatother
|
||||
|
||||
% ── Top navigation: section names + miniframe dots, no subsection row ──
|
||||
\setbeamertemplate{headline}{%
|
||||
\begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
|
||||
\end{beamercolorbox}
|
||||
\begin{beamercolorbox}{section in head/foot}
|
||||
\vskip2pt\insertnavigation{\paperwidth}\vskip2pt
|
||||
\end{beamercolorbox}%
|
||||
}
|
||||
|
||||
% ── Bottom footer: Author | Paper Title | Journal | Page ──────────────
|
||||
\makeatletter
|
||||
\setbeamertemplate{footline}{%
|
||||
\leavevmode%
|
||||
\hbox{%
|
||||
\begin{beamercolorbox}[wd=.25\paperwidth,ht=2.5ex,dp=1ex,center]{author in head/foot}%
|
||||
\usebeamerfont{author in head/foot}\insertshortauthor
|
||||
\end{beamercolorbox}%
|
||||
\begin{beamercolorbox}[wd=.42\paperwidth,ht=2.5ex,dp=1ex,center]{title in head/foot}%
|
||||
\usebeamerfont{title in head/foot}\insertshorttitle
|
||||
\end{beamercolorbox}%
|
||||
\begin{beamercolorbox}[wd=.22\paperwidth,ht=2.5ex,dp=1ex,center]{date in head/foot}%
|
||||
\usebeamerfont{date in head/foot}\insertshortdate
|
||||
\end{beamercolorbox}%
|
||||
\begin{beamercolorbox}[wd=.11\paperwidth,ht=2.5ex,dp=1ex,right]{date in head/foot}%
|
||||
\usebeamerfont{date in head/foot}\insertframenumber{}/\inserttotalframenumber\kern2em
|
||||
\end{beamercolorbox}%
|
||||
}%
|
||||
}
|
||||
\makeatother
|
||||
151
skills/ppt/references/progress-navbar.tex
Executable file
151
skills/ppt/references/progress-navbar.tex
Executable file
@@ -0,0 +1,151 @@
|
||||
% ========================================================================
|
||||
% Progress Navigation Bar for Beamer
|
||||
% ========================================================================
|
||||
% Usage: \input{progress-navbar.tex} in the preamble (after \usetheme)
|
||||
%
|
||||
% Features:
|
||||
% - Dynamic equal-width boxes: each box = (paperwidth - 50pt) / total frames
|
||||
% - Three-level symbols: ≡ (home), 1/2/3 (section), ◆ (subsection), - (slide)
|
||||
% - Teal progress coloring: visited = teal!60 fill, unvisited = hollow
|
||||
% - Clickable hyperlinks on every box
|
||||
% - Automatic section/subsection title pages
|
||||
% - Requires --runs 2 for correct width calculation
|
||||
%
|
||||
% Customization:
|
||||
% - Change "teal!60" to any color (e.g. myblue!60) for different themes
|
||||
% - Change "teal" in \color{teal}\hrule for the top separator line
|
||||
% ========================================================================
|
||||
|
||||
\makeatletter
|
||||
|
||||
% ── Auto section/subsection title pages ─────────────────────────────────
|
||||
\AtBeginSection[]{\frame{\sectionpage}}
|
||||
\AtBeginSubsection[]{\frame{\subsectionpage}}
|
||||
|
||||
% ── Lengths and counters ────────────────────────────────────────────────
|
||||
\newlength{\my@unitwidth}
|
||||
\newlength{\my@tempsize}
|
||||
\newcounter{my@sectnum}
|
||||
|
||||
% ── Helper: extract last digit of section number ────────────────────────
|
||||
\newcommand{\my@lastdigit}[1]{%
|
||||
\loop\ifnum\value{#1}>9\addtocounter{#1}{-10}\repeat
|
||||
{\normalfont\arabic{#1}}%
|
||||
}
|
||||
|
||||
% ── Box primitives ──────────────────────────────────────────────────────
|
||||
\newcommand\my@fixedbox[2]{%
|
||||
\makebox[#1]{\rule[-1ex]{0pt}{3.25ex}#2}%
|
||||
}
|
||||
|
||||
\newcommand\my@colorbox[3]{%
|
||||
{\setlength{\fboxsep}{0pt}\colorbox{#1}{\my@fixedbox{#2}{#3}}}%
|
||||
}
|
||||
|
||||
% ── Level marker: b=section, m=subsection, s=slide ─────────────────────
|
||||
\def\my@temptext{}
|
||||
\def\my@level{s}
|
||||
|
||||
\newcommand{\my@navbox}[1][]{%
|
||||
\if\relax\detokenize{#1}\relax
|
||||
\def\my@tempbox{\my@fixedbox}%
|
||||
\else
|
||||
\def\my@tempbox{\my@colorbox{#1}}%
|
||||
\fi
|
||||
\if b\my@level
|
||||
\def\my@temptext{\my@lastdigit{my@sectnum}}%
|
||||
\fi
|
||||
\if m\my@level
|
||||
\def\my@temptext{$\diamond$}%
|
||||
\fi
|
||||
\if s\my@level
|
||||
\def\my@temptext{$-$}%
|
||||
\fi
|
||||
\my@tempbox{\my@unitwidth}{\my@temptext}%
|
||||
}
|
||||
|
||||
% ── Navigation box templates (home / done / todo) ──────────────────────
|
||||
\defbeamertemplate{navigation box}{home}{%
|
||||
\my@colorbox{teal!60}{\my@unitwidth}{$\equiv$}%
|
||||
}
|
||||
|
||||
\defbeamertemplate{navigation box}{done}{%
|
||||
\my@navbox[teal!60]%
|
||||
}
|
||||
|
||||
\defbeamertemplate{navigation box}{todo}{%
|
||||
\my@navbox
|
||||
}
|
||||
|
||||
% ── Box dispatch commands ──────────────────────────────────────────────
|
||||
\newcommand{\my@bigbox}{\gdef\my@level{b}\usebeamertemplate{navigation box}}
|
||||
\newcommand{\my@medbox}{\gdef\my@level{m}\usebeamertemplate{navigation box}}
|
||||
\newcommand{\my@smallbox}{\gdef\my@level{s}\usebeamertemplate{navigation box}}
|
||||
|
||||
% ── Hook into Beamer's navigation infrastructure ──────────────────────
|
||||
\renewcommand{\sectionentry}[5]{\gdef\my@currentbox{big}\setcounter{my@sectnum}{#1}}
|
||||
\renewcommand{\beamer@subsectionentry}[5]{\gdef\my@currentbox{med}}
|
||||
|
||||
\renewcommand{\slideentry}[6]{%
|
||||
\def\my@temp@i{1/1}%
|
||||
\def\my@temp@ii{#4}%
|
||||
% Default: assume done
|
||||
\ifx\my@temp@i\my@temp@ii
|
||||
\setbeamertemplate{navigation box}[home]%
|
||||
\else
|
||||
\setbeamertemplate{navigation box}[done]%
|
||||
\fi
|
||||
% Override to todo if this slide is ahead of current position
|
||||
\ifnum\c@section<#1%
|
||||
\setbeamertemplate{navigation box}[todo]%
|
||||
\else
|
||||
\ifnum\c@section=#1\ifnum\c@subsection<#2%
|
||||
\setbeamertemplate{navigation box}[todo]%
|
||||
\else
|
||||
\ifnum\c@subsection=#2\ifnum\c@subsectionslide<#3%
|
||||
\setbeamertemplate{navigation box}[todo]%
|
||||
\fi\fi
|
||||
\fi\fi
|
||||
\fi
|
||||
% Dispatch to correct level box
|
||||
\def\my@test@big{big}%
|
||||
\def\my@test@med{med}%
|
||||
\ifx\my@temp@i\my@temp@ii
|
||||
\beamer@link(#4){\my@bigbox}%
|
||||
\else
|
||||
\ifx\my@currentbox\my@test@big
|
||||
\beamer@link(#4){\my@bigbox}%
|
||||
\else\ifx\my@currentbox\my@test@med
|
||||
\beamer@link(#4){\my@medbox}%
|
||||
\else
|
||||
\beamer@link(#4){\my@smallbox}%
|
||||
\fi\fi
|
||||
\fi
|
||||
\gdef\my@currentbox{small}%
|
||||
}
|
||||
|
||||
% ── Footline template ─────────────────────────────────────────────────
|
||||
\defbeamertemplate{footline}{progress}
|
||||
{%
|
||||
% Dynamic width: divide available space equally among all frames
|
||||
\ifnum\inserttotalframenumber>0
|
||||
\setlength{\my@unitwidth}{\dimexpr(\paperwidth - 50pt)/\inserttotalframenumber\relax}%
|
||||
\else
|
||||
\setlength{\my@unitwidth}{20pt}%
|
||||
\fi
|
||||
{\color{teal}\hrule}%
|
||||
\hbox to \paperwidth{%
|
||||
\hbox to \dimexpr\paperwidth - 50pt\relax{%
|
||||
\kern2pt{\normalfont\dohead}\hfill
|
||||
}%
|
||||
\hbox to 50pt{%
|
||||
\hfill{\normalfont\insertframenumber{}/\inserttotalframenumber}\kern4pt
|
||||
}%
|
||||
}%
|
||||
}
|
||||
|
||||
% ── Activate ──────────────────────────────────────────────────────────
|
||||
\setbeamertemplate{navigation symbols}{}
|
||||
\setbeamertemplate{footline}[progress]
|
||||
|
||||
\makeatother
|
||||
Reference in New Issue
Block a user