I'm writing a bunch of cover letters that are roughly 90% boilerplate and 10% customization. However, the boilerplate contains variables that I need to change each time. Similar to a function, I want to pass arguments to the boilerplate. Unlike previous posts about automation that seek to pass parameters to document structure, my goal is to pass parameters to document content. (My working assumption is that this is a different problem.)
To fix thoughts, here is a MWE of my template cover letter:
\documentclass[letterpaper,10pt]{article}
\begin{document}
Dear So and So,
\input{boilerplate}
\end{document}
where boilerplate.tex
is text with variables:
I am excited to apply for the position of [POSITION] at [PLACE]. Your
organization's reputation for rigorous, high-quality programming on topics in
align perfectly with my ambitions. I would relish
the opportunity to collaborate with top coders on our shared
interests in [INTERESTS]. I am committed to excellence in programming and supporting the Chicago Cubs.
and the idea is to pass arguments to [POSITION]
, [PLACE]
, and [INTERESTS]
.
Is it possible to pass parameters to input{}
, or can this only be done on the command line?
Best Answer
Using the
listofitems
package, here is a homemade key-value interface that can handle an arbitrary number of specified values in the\input
file. If that is overkill, one of the original approaches that follow should suffice.ORIGINAL APPROACHES
And if one really wanted to use bracketed delimiters in the input file, then this works (EDITED to allow arbitrary number of comma separated arguments in
#2
):