1

I have a standardized LaTex document that contains two letters and several pages of documentation. This is to be sent to each and every customer we have, for every order we deliver. The document stays consistently the same, but the adresses, customer name, project names, contact person etc. may vary.

All of the elements that vary are referenced string variables throughout the document, so to change their respective values you just change them in the preamble of the main.tex document (I'm using the standalone package and have the two letters and the documentation in three separate tex files.) where they are defined. Works like a charm, all good and well.

main.tex:

\Documentclass{article}
\usepackage{filehook}
\usepackage{currfile}
\usepackage[subpreambles=true]{standalone}
\usepackage{import}

\newcommand{\Customer}{WeBoughtYourStuff Inc.} \newcommand{\ContactPerson}{Whoever} \newcommand{\Adress}{Whereever}

\begin{document} \import{./Letters/}{Letter1.tex} \newpage \import{./Doc/}{Documentation.tex} \newpage \import{./Letters/}{Letter2.tex} \end{document}

the sub documents:

\documentclass[float=false, crop=false, class=letter]{standalone}
\usepackage[subpreambles=true]{standalone}
\usepackage{import}

\begin{document} \vspace*{26mm} \hspace{2.5cm} \parbox{0.25\textwidth}{\ContactPerson \ \Customer \ \Adress}\

Blahblahblah

Best regards\\
The People you bought the stuff from

\end{document}

What I need now is a simple program/frontend that essensially is a small window with five text fields and an OK-button that feeds the text fields to each respective string variable and compiles the tex-document without the user ever opening it. You just fill out the fields, click the button, and out comes the pdf.

How do I make this happen? Is there any existing solution available for these scenarios? I suppose a simple batch file or script that queries the user for the value of each variable, and then compiles the document also could work, but the finished product needs to be simple enough for any unexperienced idiot to be able to use it, or I'm stuck with this particular task forever...

  • 2
    Welcome to tex.sx. I know this is possible, since I did it, long ago, based on plain TeX. I believe this has already been answered here, but haven't been able to find it, searching for "form letter", but there are probably better search terms I haven't thought of. – barbara beeton Dec 07 '22 at 15:50
  • Windows? PowerShell provides quite easy GUI programming features and should be enough to write three \newcommand to a file. But PowerShell GUI programming is off-topic here … LaTeX itself has \typein but this is not very comfortable and nothing I would recommend. – cabohah Dec 07 '22 at 15:52
  • Probably related: https://tex.stackexchange.com/questions/646338/writing-to-and-compiling-tex-document-from-another-gui – Zxcvasdf Dec 08 '22 at 05:46

0 Answers0