I am trying to create a more complicated template but created this short example to document what I really want to do.
I want to create a form letter where the user will not see any complicated stuff which could be confusing. For this I want to hide all the datatool stuff
\documentclass{scrlttr2}
\usepackage{datatool}
\newcommand{\myDatabase}[1]{
\DTLloaddb{test}{#1}%
}
%This is not working:
%\AtBeginDocument{
% \DTLloaddb{test}{test.csv}%
% \DTLforeach{test}{\name=Name, \age=Age}{%
% \begin{letter}
%}
%
%\AtEndDocument{
% \end{letter}}
%}
\myDatabase{test.csv}
\begin{document}
\DTLforeach{test}{\name=Name, \age=Age}{% I want to remove this!
\begin{letter}% I want to remove this!
Dear Mr. \name
\end{letter}}% I want to remove this!
\end{document}
My database test.csv looks just like this:
Name, Age
Alfred, 42
Brian, 23
Conrad, 66
My main problem is that splitting the \DTLForeach
to appear at the beginning and conclude at the end of the document doesn't work. I tried already \bgroup
and \egroup
instead of using the bracket but this didn't change anything.
\begin{myletter} ... \end{myletter}
, then you should probably not be expecting them to use LaTeX. What happens when they want to include quotation marks or emphasise something? Don't force LaTeX on them if the whole idea of mark-up is alien. That's cruel and unusual typesetting in my book.myletter
and notletter
.