Placeholders¶
Define a value once in the frontmatter and reuse it in the running text. Write \projekt in your prose and it expands to the frontmatter value everywhere. The same value also feeds the title page. One source of truth, no copy-paste.
Needs a custom template
Placeholders only work with a custom LaTeX template. The template mirrors each frontmatter key as a macro. See Custom LaTeX templates.
The template defines one macro per value with:
\newcommand{\projekt}{$if(projekt)$$projekt$$else$[Projekt]$endif$\xspace}
Then $projekt$ feeds the title page and \projekt feeds the body. A bracketed [Projekt] shows up if the key is unset. A new placeholder costs one frontmatter key plus one \newcommand line. The template stays project-independent, so the same .tex serves any number of documents.
Source notes
---
author: MrIwan
title: "Feature: Placeholders"
projekt: "Projekt Alpha"
kunde: "Nordwind GmbH"
nope-template: "[[nope_placeholders.tex]]"
toc: false
---
# Placeholders
This document sets `projekt` and `kunde` once in the frontmatter. The custom template mirrors each as a LaTeX macro.
Write the macro in the body and it expands: \projekt is delivered for \kunde. The bare command reads the same value every time.
The same frontmatter value feeds the title page through the `$projekt$` template variable. One source, two outputs. A new placeholder costs one frontmatter key plus one `\newcommand` line in the template.
% nope_placeholders.tex — custom template demonstrating document placeholders.
% Built on nope_minimal.tex. Each \newcommand below mirrors a frontmatter key
% so the same value feeds both the title page and the body text.
%
% 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$
% --- Document placeholders (single source of truth) --------------------------
% Each value is set once in the document frontmatter and mirrored here as a
% macro. Write the macro in the body text. The matching template variable
% feeds the title page. Bracketed fallback shows if a key is unset.
\usepackage{xspace}
\newcommand{\projekt}{$if(projekt)$$projekt$$else$[Projekt]$endif$\xspace}
\newcommand{\kunde}{$if(kunde)$$kunde$$else$[Kunde]$endif$\xspace}
% -----------------------------------------------------------------------------
\title{$title$}
\author{$if(author)$$author$$endif$$if(projekt)$\\ Projekt: $projekt$$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}