mirror of
https://github.com/Kaffesky/kaffesky-markdown-templates.git
synced 2026-04-18 12:37:30 +02:00
Update tex conversion
This commit is contained in:
parent
6df06a39a1
commit
db70d3f46d
2 changed files with 323 additions and 0 deletions
|
|
@ -0,0 +1,163 @@
|
|||
# template_first-skyfritt-example.tex
|
||||
|
||||
Pandoc template for generating PDFs via XeLaTeX. Produces a document with a title page, table of contents, Roboto font, A4 format, 2.5 cm margins, and page numbering.
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Pandoc](https://pandoc.org)
|
||||
- A TeX Live installation with XeLaTeX
|
||||
- Homebrew (for installing fontconfig)
|
||||
- Roboto and Roboto Mono fonts
|
||||
|
||||
---
|
||||
|
||||
## macOS Installation
|
||||
|
||||
### 1. Install Homebrew (if not already installed)
|
||||
|
||||
```bash
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
```
|
||||
|
||||
### 2. Install Pandoc
|
||||
|
||||
```bash
|
||||
brew install pandoc
|
||||
```
|
||||
|
||||
### 3. Install MacTeX / TeX Live
|
||||
|
||||
Download and install [MacTeX](https://tug.org/mactex/) from `https://tug.org/mactex/`, or install the lighter BasicTeX:
|
||||
|
||||
```bash
|
||||
brew install --cask basictex
|
||||
```
|
||||
|
||||
After installation, open a new terminal session so that `/Library/TeX/texbin` is on your PATH.
|
||||
|
||||
### 4. Update tlmgr and install LaTeX packages
|
||||
|
||||
```bash
|
||||
sudo tlmgr update --self
|
||||
|
||||
sudo tlmgr install \
|
||||
titlesec \
|
||||
tocloft \
|
||||
booktabs \
|
||||
tools \
|
||||
fancyhdr \
|
||||
parskip \
|
||||
float \
|
||||
listings \
|
||||
fancyvrb \
|
||||
caption \
|
||||
hyperref \
|
||||
xcolor \
|
||||
fontspec \
|
||||
geometry \
|
||||
babel
|
||||
```
|
||||
|
||||
### 5. Install fontconfig
|
||||
|
||||
`fc-list` and `fc-cache` are needed for font verification and are not included on macOS by default:
|
||||
|
||||
```bash
|
||||
brew install fontconfig
|
||||
```
|
||||
|
||||
### 6. Install fonts
|
||||
|
||||
Download Roboto and Roboto Mono from Google Fonts and install them into `~/Library/Fonts/`:
|
||||
|
||||
```bash
|
||||
curl -L "https://fonts.google.com/download?family=Roboto" -o roboto.zip && \
|
||||
curl -L "https://fonts.google.com/download?family=Roboto+Mono" -o roboto-mono.zip && \
|
||||
unzip roboto.zip -d ~/roboto && \
|
||||
unzip roboto-mono.zip -d ~/roboto-mono && \
|
||||
cp ~/roboto/static/*.ttf ~/Library/Fonts/ && \
|
||||
cp ~/roboto-mono/static/*.ttf ~/Library/Fonts/ && \
|
||||
fc-cache -f -v
|
||||
```
|
||||
|
||||
Clean up:
|
||||
|
||||
```bash
|
||||
rm -rf roboto.zip roboto-mono.zip ~/roboto ~/roboto-mono
|
||||
```
|
||||
|
||||
### 7. Verify fonts are available to XeLaTeX
|
||||
|
||||
```bash
|
||||
fc-list | grep -i roboto
|
||||
```
|
||||
|
||||
You should see several lines listing the Roboto and Roboto Mono font files. If nothing appears, double-check that the `.ttf` files are present in `~/Library/Fonts/`.
|
||||
|
||||
### 8. Verify LaTeX packages are installed
|
||||
|
||||
```bash
|
||||
kpsewhich titlesec.sty tocloft.sty fancyhdr.sty caption.sty
|
||||
```
|
||||
|
||||
Each line should return a file path. If any are blank, install the missing package individually:
|
||||
|
||||
```bash
|
||||
sudo tlmgr install <packagename>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
Add a YAML front matter block to the top of your Markdown file:
|
||||
|
||||
```yaml
|
||||
---
|
||||
title: "My Document"
|
||||
subtitle: "An optional subtitle"
|
||||
author: "Jane Doe"
|
||||
date: "March 2026"
|
||||
description: "An optional blurb shown at the bottom of the title page."
|
||||
---
|
||||
```
|
||||
|
||||
Then compile with:
|
||||
|
||||
```bash
|
||||
pandoc input.md -o output.pdf \
|
||||
--pdf-engine=xelatex \
|
||||
--template=template_first-skyfritt-example.tex
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Fonts used
|
||||
|
||||
| Role | Font | Source |
|
||||
|------------|--------------|-------------------------------------------------|
|
||||
| Main text | Roboto | https://fonts.google.com/specimen/Roboto |
|
||||
| Monospace | Roboto Mono | https://fonts.google.com/specimen/Roboto+Mono |
|
||||
|
||||
Both fonts are open source and licensed under the Apache License 2.0.
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**`xelatex: createProcess: find_executable: failed`**
|
||||
XeLaTeX is not installed or not on your PATH. Install MacTeX or BasicTeX and open a new terminal session.
|
||||
|
||||
**`The font "Roboto" cannot be found`**
|
||||
The font is not installed. Follow step 6 above.
|
||||
|
||||
**`File 'titlesec.sty' not found`**
|
||||
A required LaTeX package is missing. Run the `tlmgr install` command in step 4.
|
||||
|
||||
**`No counter 'none' defined`**
|
||||
A known pandoc + longtable bug. The template includes a fix for this — make sure you are using the latest version of `template_first-skyfritt-example.tex`.
|
||||
|
||||
**`fc-list: command not found`**
|
||||
fontconfig is not installed. Run `brew install fontconfig`.
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
%% Pandoc LaTeX Template
|
||||
%% Usage: pandoc input.md -o output.pdf --template=template_first-skyfritt-example.tex
|
||||
|
||||
\documentclass[12pt, a4paper]{article}
|
||||
|
||||
%% ── Encoding & language ───────────────────────────────────────────────────────
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[english]{babel}
|
||||
|
||||
%% ── Page geometry ─────────────────────────────────────────────────────────────
|
||||
\usepackage[
|
||||
a4paper,
|
||||
top=2.5cm,
|
||||
bottom=2.5cm,
|
||||
left=2.5cm,
|
||||
right=2.5cm
|
||||
]{geometry}
|
||||
|
||||
%% ── Font: Roboto (requires XeLaTeX or LuaLaTeX) ──────────────────────────────
|
||||
\usepackage{fontspec}
|
||||
\setmainfont{Roboto}[
|
||||
UprightFont = *-Regular,
|
||||
BoldFont = *-Bold,
|
||||
ItalicFont = *-Italic,
|
||||
BoldItalicFont = *-BoldItalic
|
||||
]
|
||||
\setsansfont{Roboto}
|
||||
\setmonofont{Menlo}[Scale=0.9]
|
||||
|
||||
%% ── Colours ───────────────────────────────────────────────────────────────────
|
||||
\usepackage{xcolor}
|
||||
\definecolor{accent}{HTML}{2C3E50}
|
||||
\definecolor{muted}{HTML}{7F8C8D}
|
||||
|
||||
%% ── Hyperlinks ────────────────────────────────────────────────────────────────
|
||||
\usepackage[
|
||||
colorlinks = true,
|
||||
linkcolor = accent,
|
||||
urlcolor = accent,
|
||||
citecolor = accent
|
||||
]{hyperref}
|
||||
|
||||
%% ── Headers & footers ─────────────────────────────────────────────────────────
|
||||
\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}
|
||||
\renewcommand{\footrulewidth}{0pt}
|
||||
|
||||
%% ── Section styling ───────────────────────────────────────────────────────────
|
||||
\usepackage{titlesec}
|
||||
\titleformat{\section}
|
||||
{\large\bfseries\color{accent}}{\thesection}{1em}{}[\titlerule]
|
||||
\titleformat{\subsection}
|
||||
{\normalsize\bfseries\color{accent}}{\thesubsection}{1em}{}
|
||||
\titleformat{\subsubsection}
|
||||
{\normalsize\itshape}{\thesubsubsection}{1em}{}
|
||||
|
||||
%% ── Table of contents styling ─────────────────────────────────────────────────
|
||||
\usepackage{tocloft}
|
||||
\renewcommand{\cftsecfont}{\bfseries}
|
||||
\renewcommand{\cftsecpagefont}{\bfseries}
|
||||
\setlength{\cftbeforesecskip}{4pt}
|
||||
|
||||
%% ── Tables ────────────────────────────────────────────────────────────────────
|
||||
\usepackage{booktabs}
|
||||
\usepackage{longtable}
|
||||
\usepackage{array}
|
||||
\usepackage{caption}
|
||||
|
||||
%% Fix pandoc longtable empty-placement bug ("No counter 'none' defined")
|
||||
\makeatletter
|
||||
\newcounter{none}
|
||||
\makeatother
|
||||
|
||||
%% ── Graphics & figures ────────────────────────────────────────────────────────
|
||||
\usepackage{graphicx}
|
||||
\usepackage{float}
|
||||
\makeatletter
|
||||
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
|
||||
\makeatother
|
||||
\setkeys{Gin}{width=\maxwidth, keepaspectratio}
|
||||
|
||||
%% ── Code listings ─────────────────────────────────────────────────────────────
|
||||
\usepackage{fancyvrb}
|
||||
\usepackage{listings}
|
||||
\lstset{
|
||||
basicstyle = \small\ttfamily,
|
||||
breaklines = true,
|
||||
frame = single,
|
||||
rulecolor = \color{muted},
|
||||
commentstyle = \color{muted},
|
||||
keywordstyle = \color{accent}\bfseries
|
||||
}
|
||||
|
||||
%% ── Pandoc shims ──────────────────────────────────────────────────────────────
|
||||
\providecommand{\tightlist}{%
|
||||
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
|
||||
|
||||
$if(highlighting-macros)$
|
||||
$highlighting-macros$
|
||||
$endif$
|
||||
|
||||
%% ── Spacing ───────────────────────────────────────────────────────────────────
|
||||
\usepackage{parskip}
|
||||
\setlength{\parskip}{6pt}
|
||||
|
||||
%% ══════════════════════════════════════════════════════════════════════════════
|
||||
%% DOCUMENT
|
||||
%% ══════════════════════════════════════════════════════════════════════════════
|
||||
\begin{document}
|
||||
|
||||
%% ── Title page ────────────────────────────────────────────────────────────────
|
||||
\begin{titlepage}
|
||||
\thispagestyle{empty}
|
||||
\centering
|
||||
\vspace*{4cm}
|
||||
|
||||
{\Huge\bfseries\color{accent} $title$ \par}
|
||||
\vspace{0.5cm}
|
||||
\textcolor{muted}{\rule{0.4\textwidth}{0.4pt}}
|
||||
\vspace{1cm}
|
||||
|
||||
$if(subtitle)$
|
||||
{\large\itshape $subtitle$ \par}
|
||||
\vspace{1cm}
|
||||
$endif$
|
||||
|
||||
$if(author)$
|
||||
{\large $for(author)$$author$$sep$ \\ $endfor$ \par}
|
||||
\vspace{0.5cm}
|
||||
$endif$
|
||||
|
||||
$if(date)$
|
||||
{\normalsize\textcolor{muted}{$date$} \par}
|
||||
$endif$
|
||||
|
||||
\vfill
|
||||
|
||||
$if(description)$
|
||||
\begin{minipage}{0.7\textwidth}
|
||||
\centering\small\textcolor{muted}{$description$}
|
||||
\end{minipage}
|
||||
$endif$
|
||||
|
||||
\end{titlepage}
|
||||
|
||||
%% ── Table of contents ─────────────────────────────────────────────────────────
|
||||
\clearpage
|
||||
\tableofcontents
|
||||
\clearpage
|
||||
|
||||
%% ── Main content ──────────────────────────────────────────────────────────────
|
||||
$body$
|
||||
|
||||
\end{document}
|
||||
Loading…
Add table
Add a link
Reference in a new issue