Skip to content

Expansion Const

Fabian Wenzelmann edited this page Oct 9, 2018 · 5 revisions

This example explains how to use gummibaum to replace placeholders with constant values. Save the following text in template.tex:

\documentclass[a4paper]{scrartcl}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\title{Template File}

\begin{document}

\maketitle

Hello REPL-NAME,

this is a gummibaum template that replaces some constants, like REPL-FOO.
\end{document}

Then run ./gummibaum expand --file template.tex --const "REPL-NAME=John" --const REPL-FOO=bar The output is:

\documentclass[a4paper]{scrartcl}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\title{Template File}

\begin{document}

\maketitle

Hello John,

this is a gummibaum template that replaces some constants, like \textbackslash bar.
\end{document}

The constants should be something that does not contain LaTeX code. As you can see LaTeX special characters are escaped. To suppress this behavior globally append --no-escape like so: ./gummibaum expand --file template.tex --const "REPL-NAME=John" --const "REPL-FOO=\textit{bar}" --no-escape Which yields to

\documentclass[a4paper]{scrartcl}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\title{Template File}

\begin{document}

\maketitle

Hello John,

this is a gummibaum template that replaces some constants, like \textit{bar}.
\end{document}

Saving to a File

By default the result is printed to the standard output. To write to a file directly just add --out file: ./gummibaum expand --file template.tex --const "REPL-NAME=John" --const REPL-FOO=bar --out out.tex

Clone this wiki locally