Skip to content

Custom LaTeX templates

Swap the default Eisvogel template for your own .tex via nope-template: "[[my-template]]". Start from nope_minimal.tex (command Create custom LaTeX template), keep the marked NOPE-IMPORTS block verbatim and define your own environments. You can also restyle NOPE defaults like callouts and tables by overriding their nope* names. The demo below flips a box from red to green depending on whether an extra package is installed.

Open PDF

Source notes

---
author: Wanja Zemke
title: The Power of LaTeX
subtitle: Demonstrating the custom template
date: 2026-06-24
nope-template: "[[nope_minimal.tex]]"
---
# Chapter

The custom template is a powerful and dangerous tool. It opens up endless export possibilities and just as many ways for things to go wrong.

# Extra LaTeX packages

Custom templates may need packages that are not part of the base Docker image — here `cancel`. A document declares them in its frontmatter via `nope-tlmgr:`; the export installs missing ones into the Docker image automatically. The demo template loads `cancel` only if it is available, so the box below tells you whether the package made it into the image:

\begin{demobox}
The template checks for the package with \texttt{\textbackslash IfFileExists} and switches this box between red and green.
\end{demobox}

To test it yourself:

1. Export this note once — the box is red: `cancel` is **not** installed.
2. Add `nope-tlmgr: [cancel]` to this note's frontmatter.
3. Export again — the package is installed during the export and the box turns green.

The `IfFileExists` dance is only for this red/green demo. A real template just declares `nope-tlmgr:` in the document (or branding note) and uses plain `\usepackage{...}` — if a package is missing anyway, the export fails and the reason lands in the LaTeX log (keep intermediates via settings to inspect it).
% nope_minimal.tex — minimal NOPE custom-template starter. No overhead.
%
% Use it: copy this file into your vault (command "Create custom LaTeX template"),
% then point a document (or branding note) at it via frontmatter:
%   nope-template: "[[nope_minimal.tex]]"
% The wikilink must include the .tex extension — without it the template is not found.
%
% This is the recommended starting point for a custom template: it carries the
% Pandoc baseline (image scaling, code highlighting, table width macros, float
% placement) PLUS the marked NOPE-IMPORTS block below. A template written fully
% from scratch must keep both. Keep the NOPE-IMPORTS block verbatim.

\documentclass[11pt]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage[english]{babel} % change to ngerman for German documents
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{calc}   % \real{} factors in table column widths
\usepackage{fancyvrb}
\usepackage{fvextra}
\usepackage{hyperref}

% --- Extra LaTeX packages demo -----------------------------------------------
\usepackage{tcolorbox}
\IfFileExists{cancel.sty}{%
  \usepackage{cancel}%
  \newenvironment{demobox}%
    {\begin{tcolorbox}[colback=green!5,colframe=green!50!black,title=cancel is installed — extra LaTeX packages work]%
     \(\frac{\cancel{6}\cdot 5}{\cancel{6}} = 5\)\quad(rendered by the \texttt{cancel} package)\par\smallskip}%
    {\end{tcolorbox}}%
}{%
  \newenvironment{demobox}%
    {\begin{tcolorbox}[colback=red!5,colframe=red!60!black,title=cancel is NOT installed — declare it via nope-tlmgr: [cancel] in the frontmatter]}%
    {\end{tcolorbox}}%
}
% ------------------------------------------------------------------------------

% Pandoc helper macros that its default template provides.
\newcommand{\passthrough}[1]{#1}
\providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
% KOMA classes define \nonumberline; article does not. Provide a no-op so
% unnumbered headings (and a stale KOMA .toc from a previous template) don't crash.
\providecommand{\nonumberline}{}
\setlength{\emergencystretch}{3em}
% Scale an image to fit text width/height (Pandoc wraps images in \pandocbounded).
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{%
  \sbox\pandoc@box{#1}%
  \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
  \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
  \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi%
  \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
  \else\usebox{\pandoc@box}%
  \fi%
}
\makeatother

% Syntax highlighting for fenced code blocks (Shaded/Highlighting environments).
$if(highlighting-macros)$
$highlighting-macros$
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,fontsize=\small,commandchars=\\\{\}}
$endif$

% Citeproc citations + bibliography (CSLReferences environment).
$if(csl-refs)$
\NewDocumentCommand\citeproctext{}{}
\NewDocumentCommand\citeproc{mm}{%
  \begingroup\def\citeproctext{#2}\cite{#1}\endgroup}
\makeatletter
 \let\@cite@ofmt\@firstofone
 \def\@biblabel#1{}
 \def\@cite#1#2{{#1\if@tempswa , #2\fi}}
\makeatother
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newenvironment{CSLReferences}[2]
  {\begin{list}{}{%
   \setlength{\itemindent}{0pt}
   \setlength{\leftmargin}{0pt}
   \setlength{\parsep}{0pt}
   \ifodd #1
    \setlength{\leftmargin}{\cslhangindent}
    \setlength{\itemindent}{-1\cslhangindent}
   \fi
   \setlength{\itemsep}{#2\baselineskip}}}
  {\end{list}}
\newcommand{\CSLBlock}[1]{\hfill\break\parbox[t]{\linewidth}{\strut\ignorespaces#1\strut}}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
$endif$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% NOPE-IMPORTS — DO NOT CHANGE unless you know what you are doing.        %%%
%%% Everything NOPE's pipeline needs: tables, callouts, theorems, glossary, %%%
%%% cross-reference names. Keep this block verbatim in any custom template. %%%
%%% Must sit after hyperref and BEFORE header-includes.                     %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx}
\usepackage{longtable,booktabs,array}
\usepackage{amsmath,amssymb} % math + task-list checkboxes (\square/\boxtimes)
\usepackage{float}  % [H] placement: fit-tables (filter emits table[H]) + figures
\floatplacement{figure}{$if(float-placement-figure)$$float-placement-figure$$else$H$endif$}

% Unicode fallbacks
\DeclareUnicodeCharacter{2212}{\ensuremath{-}}        % minus sign
\DeclareUnicodeCharacter{2213}{\ensuremath{\mp}}
\DeclareUnicodeCharacter{22C5}{\ensuremath{\cdot}}
\DeclareUnicodeCharacter{2264}{\ensuremath{\leq}}
\DeclareUnicodeCharacter{2265}{\ensuremath{\geq}}
\DeclareUnicodeCharacter{2260}{\ensuremath{\neq}}
\DeclareUnicodeCharacter{2248}{\ensuremath{\approx}}
\DeclareUnicodeCharacter{2261}{\ensuremath{\equiv}}
\DeclareUnicodeCharacter{221D}{\ensuremath{\propto}}
\DeclareUnicodeCharacter{221E}{\ensuremath{\infty}}
\DeclareUnicodeCharacter{2202}{\ensuremath{\partial}}
\DeclareUnicodeCharacter{2207}{\ensuremath{\nabla}}
\DeclareUnicodeCharacter{2211}{\ensuremath{\sum}}
\DeclareUnicodeCharacter{220F}{\ensuremath{\prod}}
\DeclareUnicodeCharacter{222B}{\ensuremath{\int}}
\DeclareUnicodeCharacter{221A}{\ensuremath{\surd}}
\DeclareUnicodeCharacter{2200}{\ensuremath{\forall}}
\DeclareUnicodeCharacter{2203}{\ensuremath{\exists}}
\DeclareUnicodeCharacter{2208}{\ensuremath{\in}}
\DeclareUnicodeCharacter{2209}{\ensuremath{\notin}}
\DeclareUnicodeCharacter{2205}{\ensuremath{\emptyset}}
\DeclareUnicodeCharacter{222A}{\ensuremath{\cup}}
\DeclareUnicodeCharacter{2229}{\ensuremath{\cap}}
\DeclareUnicodeCharacter{2282}{\ensuremath{\subset}}
\DeclareUnicodeCharacter{2286}{\ensuremath{\subseteq}}
\DeclareUnicodeCharacter{2190}{\ensuremath{\leftarrow}}
\DeclareUnicodeCharacter{2192}{\ensuremath{\rightarrow}}
\DeclareUnicodeCharacter{2194}{\ensuremath{\leftrightarrow}}
\DeclareUnicodeCharacter{21D0}{\ensuremath{\Leftarrow}}
\DeclareUnicodeCharacter{21D2}{\ensuremath{\Rightarrow}}
\DeclareUnicodeCharacter{21D4}{\ensuremath{\Leftrightarrow}}
% Greek lowercase
\DeclareUnicodeCharacter{03B1}{\ensuremath{\alpha}}
\DeclareUnicodeCharacter{03B2}{\ensuremath{\beta}}
\DeclareUnicodeCharacter{03B3}{\ensuremath{\gamma}}
\DeclareUnicodeCharacter{03B4}{\ensuremath{\delta}}
\DeclareUnicodeCharacter{03B5}{\ensuremath{\varepsilon}}
\DeclareUnicodeCharacter{03B6}{\ensuremath{\zeta}}
\DeclareUnicodeCharacter{03B7}{\ensuremath{\eta}}
\DeclareUnicodeCharacter{03B8}{\ensuremath{\theta}}
\DeclareUnicodeCharacter{03B9}{\ensuremath{\iota}}
\DeclareUnicodeCharacter{03BA}{\ensuremath{\kappa}}
\DeclareUnicodeCharacter{03BB}{\ensuremath{\lambda}}
\DeclareUnicodeCharacter{03BC}{\ensuremath{\mu}}
\DeclareUnicodeCharacter{03BD}{\ensuremath{\nu}}
\DeclareUnicodeCharacter{03BE}{\ensuremath{\xi}}
\DeclareUnicodeCharacter{03C0}{\ensuremath{\pi}}
\DeclareUnicodeCharacter{03C1}{\ensuremath{\rho}}
\DeclareUnicodeCharacter{03C3}{\ensuremath{\sigma}}
\DeclareUnicodeCharacter{03C4}{\ensuremath{\tau}}
\DeclareUnicodeCharacter{03C5}{\ensuremath{\upsilon}}
\DeclareUnicodeCharacter{03C6}{\ensuremath{\varphi}}
\DeclareUnicodeCharacter{03C7}{\ensuremath{\chi}}
\DeclareUnicodeCharacter{03C8}{\ensuremath{\psi}}
\DeclareUnicodeCharacter{03C9}{\ensuremath{\omega}}
% Greek uppercase
\DeclareUnicodeCharacter{0393}{\ensuremath{\Gamma}}
\DeclareUnicodeCharacter{0394}{\ensuremath{\Delta}}
\DeclareUnicodeCharacter{0398}{\ensuremath{\Theta}}
\DeclareUnicodeCharacter{039B}{\ensuremath{\Lambda}}
\DeclareUnicodeCharacter{039E}{\ensuremath{\Xi}}
\DeclareUnicodeCharacter{03A0}{\ensuremath{\Pi}}
\DeclareUnicodeCharacter{03A3}{\ensuremath{\Sigma}}
\DeclareUnicodeCharacter{03A6}{\ensuremath{\Phi}}
\DeclareUnicodeCharacter{03A8}{\ensuremath{\Psi}}
\DeclareUnicodeCharacter{03A9}{\ensuremath{\Omega}}
% Subscripts
\DeclareUnicodeCharacter{2080}{\textsubscript{0}}
\DeclareUnicodeCharacter{2081}{\textsubscript{1}}
\DeclareUnicodeCharacter{2082}{\textsubscript{2}}
\DeclareUnicodeCharacter{2083}{\textsubscript{3}}
\DeclareUnicodeCharacter{2084}{\textsubscript{4}}
\DeclareUnicodeCharacter{2085}{\textsubscript{5}}
\DeclareUnicodeCharacter{2086}{\textsubscript{6}}
\DeclareUnicodeCharacter{2087}{\textsubscript{7}}
\DeclareUnicodeCharacter{2088}{\textsubscript{8}}
\DeclareUnicodeCharacter{2089}{\textsubscript{9}}
\DeclareUnicodeCharacter{208A}{\textsubscript{+}}
\DeclareUnicodeCharacter{208B}{\textsubscript{-}}
\DeclareUnicodeCharacter{2099}{\textsubscript{n}}
% Superscripts (1,2,3 already provided by textcomp)
\DeclareUnicodeCharacter{2070}{\textsuperscript{0}}
\DeclareUnicodeCharacter{2074}{\textsuperscript{4}}
\DeclareUnicodeCharacter{2075}{\textsuperscript{5}}
\DeclareUnicodeCharacter{2076}{\textsuperscript{6}}
\DeclareUnicodeCharacter{2077}{\textsuperscript{7}}
\DeclareUnicodeCharacter{2078}{\textsuperscript{8}}
\DeclareUnicodeCharacter{2079}{\textsuperscript{9}}

% Callouts (callouts.lua → awesomebox) and highlights (==text== → soul \hl).
\usepackage{awesomebox}
\usepackage{soul}
\usepackage{soulutf8}

% SVG logos/images.
\usepackage{svg}

% Theorem-family environments (latex-env: theorem/lemma/...). Own counter per
% type so \autoref prints the right name instead of always "Theorem".
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{corollary}{Corollary}[section]
\newtheorem{proposition}{Proposition}[section]
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\newtheorem{example}{Example}[section]
\theoremstyle{remark}
\newtheorem*{remark}{Remark}
\newtheorem*{note}{Note}

% Fallback \autoref names if hyperref's \newtheorem hook didn't set them.
\providecommand{\theoremautorefname}{Theorem}
\providecommand{\lemmaautorefname}{Lemma}
\providecommand{\corollaryautorefname}{Corollary}
\providecommand{\propositionautorefname}{Proposition}
\providecommand{\definitionautorefname}{Definition}
\providecommand{\exampleautorefname}{Example}

% Glossary + acronyms (gls-* notes). Must precede the injected entries.
\usepackage[acronym, toc, nonumberlist]{glossaries}
\makeglossaries

% Language-aware \autoref names (figure/table/equation/... per babel language).
\AtBeginDocument{%
  \IfPackageLoadedTF{babel}{%
    \iflanguage{ngerman}{%
      \renewcommand{\figureautorefname}{Abbildung}%
      \renewcommand{\tableautorefname}{Tabelle}%
      \renewcommand{\equationautorefname}{Gleichung}%
      \renewcommand{\sectionautorefname}{Abschnitt}%
      \renewcommand{\subsectionautorefname}{Unterabschnitt}%
      \renewcommand{\subsubsectionautorefname}{Unterunterabschnitt}%
      \renewcommand{\paragraphautorefname}{Absatz}%
      \renewcommand{\itemautorefname}{Punkt}%
      \renewcommand{\footnoteautorefname}{Fu\ss note}%
      \renewcommand{\contentsname}{Inhaltsverzeichnis}%
      \renewcommand{\listfigurename}{Abbildungsverzeichnis}%
      \renewcommand{\listtablename}{Tabellenverzeichnis}%
    }{}%
    \iflanguage{english}{%
      \renewcommand{\figureautorefname}{Figure}%
      \renewcommand{\tableautorefname}{Table}%
      \renewcommand{\equationautorefname}{Equation}%
      \renewcommand{\sectionautorefname}{Section}%
      \renewcommand{\subsectionautorefname}{Subsection}%
      \renewcommand{\subsubsectionautorefname}{Subsubsection}%
      \renewcommand{\paragraphautorefname}{Paragraph}%
      \renewcommand{\itemautorefname}{Item}%
      \renewcommand{\footnoteautorefname}{Footnote}%
      \renewcommand{\contentsname}{Table of Contents}%
      \renewcommand{\listfigurename}{List of Figures}%
      \renewcommand{\listtablename}{List of Tables}%
    }{}%
    % --- Add further \iflanguage{<lang>}{...} blocks below if needed ---
  }{}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% END NOPE-IMPORTS                                                        %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

$for(header-includes)$
$header-includes$
$endfor$

\title{$title$}
$if(author)$\author{$author$}$endif$
$if(date)$\date{$date$}$endif$

\begin{document}

$if(title)$\maketitle$endif$
$if(toc)$\tableofcontents\newpage$endif$
$if(lof)$\listoffigures$endif$
$if(lot)$\listoftables$endif$

$body$

$if(has-glossary)$
\clearpage
\printglossary[type=\acronymtype, title={Acronyms}]
\printglossary[title={Glossary}]
$endif$

\end{document}