mirror of
https://github.com/Kaffesky/kaffesky-markdown-templates.git
synced 2026-04-18 10:37:30 +02:00
updates
This commit is contained in:
parent
db70d3f46d
commit
9cee929317
2 changed files with 110 additions and 12 deletions
|
|
@ -129,7 +129,45 @@ Then compile with:
|
|||
```bash
|
||||
pandoc input.md -o output.pdf \
|
||||
--pdf-engine=xelatex \
|
||||
--template=template_first-skyfritt-example.tex
|
||||
--template=template_first-skyfritt-example.tex \
|
||||
--shift-heading-level-by=-1
|
||||
```
|
||||
|
||||
### Why `--shift-heading-level-by=-1`?
|
||||
|
||||
Pandoc's `article` class maps `#` → `\section`, `##` → `\subsection`, and so on. If your Markdown has a single `# Document Title` at the top followed by `## 1. Introduction`, `## 2. …`, etc., the title ends up as "Section 1" in the TOC and all real sections become subsections 1.1, 1.2, …
|
||||
|
||||
Passing `--shift-heading-level-by=-1` shifts every heading up one level before rendering:
|
||||
|
||||
| Markdown | Without flag | With flag |
|
||||
|----------|-------------|-----------|
|
||||
| `#` | `\section` (appears in TOC) | promotes to document title — invisible in body |
|
||||
| `##` | `\subsection` | `\section` |
|
||||
| `###` | `\subsubsection` | `\subsection` |
|
||||
|
||||
The `#` heading is absorbed as the top-level title and removed from the body, so your real sections (`##`) become proper `\section` entries.
|
||||
|
||||
### Section numbering
|
||||
|
||||
By default the template **suppresses LaTeX auto-numbering** (`secnumdepth = 0`), because headings written as `## 1. Introduction` already carry their own numbers. Letting LaTeX add its own would produce double-numbering like `1 1. Introduction`.
|
||||
|
||||
If you prefer LaTeX to number sections automatically (and write headings without embedded numbers, e.g. `## Introduction`), pass `--number-sections`:
|
||||
|
||||
```bash
|
||||
pandoc input.md -o output.pdf \
|
||||
--pdf-engine=xelatex \
|
||||
--template=template_first-skyfritt-example.tex \
|
||||
--shift-heading-level-by=-1 \
|
||||
--number-sections
|
||||
```
|
||||
|
||||
You can also control the depth of numbering with the `secnumdepth` metadata variable:
|
||||
|
||||
```yaml
|
||||
---
|
||||
title: "My Document"
|
||||
secnumdepth: 2 # number sections and subsections only
|
||||
---
|
||||
```
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -9,12 +9,16 @@
|
|||
\usepackage[english]{babel}
|
||||
|
||||
%% ── Page geometry ─────────────────────────────────────────────────────────────
|
||||
%% A4 at 12pt Roboto. Text width ~155mm → ~68 chars/line, within the
|
||||
%% 45–75 char optimal range (Bringhurst). Bottom is slightly deeper than
|
||||
%% top to give the page number visual breathing room and anchor the page.
|
||||
\usepackage[
|
||||
a4paper,
|
||||
top=2.5cm,
|
||||
bottom=2.5cm,
|
||||
left=2.5cm,
|
||||
right=2.5cm
|
||||
top = 27mm,
|
||||
bottom = 32mm,
|
||||
left = 28mm,
|
||||
right = 28mm,
|
||||
footskip = 14mm
|
||||
]{geometry}
|
||||
|
||||
%% ── Font: Roboto (requires XeLaTeX or LuaLaTeX) ──────────────────────────────
|
||||
|
|
@ -41,20 +45,21 @@
|
|||
citecolor = accent
|
||||
]{hyperref}
|
||||
|
||||
%% ── Headers & footers ─────────────────────────────────────────────────────────
|
||||
%% ── Page footer only ──────────────────────────────────────────────────────────
|
||||
%% No header. Page number centred in the footer at footnotesize so it
|
||||
%% sits quietly without competing with the text.
|
||||
\usepackage{fancyhdr}
|
||||
\pagestyle{fancy}
|
||||
\fancyhf{}
|
||||
\fancyhead[L]{\small\textcolor{muted}{$title$}}
|
||||
\fancyhead[R]{\small\textcolor{muted}{$date$}}
|
||||
\fancyfoot[C]{\small\textcolor{muted}{\thepage}}
|
||||
\renewcommand{\headrulewidth}{0.4pt}
|
||||
\fancyfoot[C]{\footnotesize\textcolor{muted}{\thepage}}
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\renewcommand{\footrulewidth}{0pt}
|
||||
|
||||
%% ── Section styling ───────────────────────────────────────────────────────────
|
||||
\usepackage{titlesec}
|
||||
\titleformat{\section}
|
||||
{\large\bfseries\color{accent}}{\thesection}{1em}{}[\titlerule]
|
||||
{\large\bfseries\color{accent}}{\thesection}{1em}{\MakeUppercase}[\titlerule]
|
||||
\newcommand{\sectionbreak}{\clearpage}
|
||||
\titleformat{\subsection}
|
||||
{\normalsize\bfseries\color{accent}}{\thesubsection}{1em}{}
|
||||
\titleformat{\subsubsection}
|
||||
|
|
@ -66,13 +71,61 @@
|
|||
\renewcommand{\cftsecpagefont}{\bfseries}
|
||||
\setlength{\cftbeforesecskip}{4pt}
|
||||
|
||||
%% ── Section numbering ─────────────────────────────────────────────────────────
|
||||
%% By default sections are NOT auto-numbered, because Markdown headings already
|
||||
%% carry their own numbers (e.g. "## 1. Introduction").
|
||||
%% Pass --number-sections to pandoc to enable LaTeX auto-numbering instead.
|
||||
$if(numbersections)$
|
||||
\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$3$endif$}
|
||||
$else$
|
||||
\setcounter{secnumdepth}{0}
|
||||
$endif$
|
||||
|
||||
%% ── Tables ────────────────────────────────────────────────────────────────────
|
||||
\usepackage{booktabs}
|
||||
\usepackage{longtable}
|
||||
\usepackage{array}
|
||||
\usepackage{caption}
|
||||
\usepackage{colortbl}
|
||||
|
||||
%% Fix pandoc longtable empty-placement bug ("No counter 'none' defined")
|
||||
%% Table colours
|
||||
\definecolor{tableheadbg}{HTML}{2C3E50} %% same as accent — dark header
|
||||
\definecolor{tablerowA}{HTML}{FFFFFF} %% white rows
|
||||
\definecolor{tablerowB}{HTML}{F0F3F4} %% very light grey alternate rows
|
||||
\definecolor{tablerule}{HTML}{BDC3C7} %% light rule colour
|
||||
|
||||
%% Caption styling
|
||||
\captionsetup[table]{
|
||||
font = {small, color=muted},
|
||||
labelfont = bf,
|
||||
position = above,
|
||||
skip = 4pt
|
||||
}
|
||||
|
||||
%% Tighten row height slightly and add a hint of left/right cell padding
|
||||
\setlength{\tabcolsep}{10pt}
|
||||
\renewcommand{\arraystretch}{1.35}
|
||||
|
||||
%% Wrap every longtable in alternating-row colours.
|
||||
%% Row 1 (the header) gets the dark accent background; from row 2 onward
|
||||
%% rows alternate tablerowA / tablerowB.
|
||||
\AtBeginEnvironment{longtable}{%
|
||||
\rowcolors{2}{tablerowB}{tablerowA}%
|
||||
\arrayrulecolor{tablerule}%
|
||||
}
|
||||
|
||||
%% Style the header row: white bold text on dark accent background.
|
||||
%% \rowcolor in row 1 overrides the \rowcolors cycling for that row only.
|
||||
\newcommand{\tableheader}{%
|
||||
\rowcolor{tableheadbg}%
|
||||
\color{white}\bfseries%
|
||||
}
|
||||
|
||||
%% Pandoc emits \toprule / \midrule / \bottomrule from booktabs.
|
||||
%% Override rule weights to match the softer palette.
|
||||
\setlength{\heavyrulewidth}{0.8pt}
|
||||
\setlength{\lightrulewidth}{0.4pt}
|
||||
\setlength{\cmidrulewidth}{0.4pt}
|
||||
\makeatletter
|
||||
\newcounter{none}
|
||||
\makeatother
|
||||
|
|
@ -85,6 +138,8 @@
|
|||
\makeatother
|
||||
\setkeys{Gin}{width=\maxwidth, keepaspectratio}
|
||||
|
||||
\usepackage{etoolbox}
|
||||
|
||||
%% ── Code listings ─────────────────────────────────────────────────────────────
|
||||
\usepackage{fancyvrb}
|
||||
\usepackage{listings}
|
||||
|
|
@ -105,9 +160,14 @@ $if(highlighting-macros)$
|
|||
$highlighting-macros$
|
||||
$endif$
|
||||
|
||||
%% ── Blockquotes ───────────────────────────────────────────────────────────────
|
||||
\AtBeginEnvironment{quote}{\fontsize{11pt}{13.2pt}\selectfont}
|
||||
|
||||
%% ── Spacing ───────────────────────────────────────────────────────────────────
|
||||
\usepackage{parskip}
|
||||
\setlength{\parskip}{6pt}
|
||||
\usepackage{setspace}
|
||||
\onehalfspacing
|
||||
|
||||
%% ══════════════════════════════════════════════════════════════════════════════
|
||||
%% DOCUMENT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue