0

I'm trying to use the mailmerge package with the KOMA scrlttr2 letter class, but it is failing with a There's no line here to end. message, presumably because the address field is rendering as blank. I expect I am making some elementary mistake. Sample code follows:

\documentclass[foldmarks=false,backaddress=false,
fromalign=false,version=last]{scrlttr2}
\usepackage{fouriernc}
\usepackage[T1]{fontenc}
\usepackage{mailmerge}
\begin{document}
\setkomavar{fromname}{H. G. Wells}
\setkomavar{fromaddress}{Spade House\\ 5281 Radnor Cliff Crescent (West Side)\\ Sandgate, Kent}
\mailfields{address}
\def\today{1st January, 1895}
\begin{letter}{
    % George Bernard Shaw,\\
    % Shaw's Corner,\\
    % Bibbs Hall Lane,\\
    % Ayot St. Lawrence, Hertfordshire\\
    \mailrepeat{\field{address}}
  }

\opening{Dear Shaw,}

You suck!

\closing{Sincerely}
\end{letter}

\mailentry{GBS}

\end{document}
5
  • Are you bound to the mailmerge package? If not, you may want to try the datatoolpackage instead. Please see this sample code (tex.stackexchange.com/questions/203918/…) from Nicola Talbot. It works like a charm with scrlttr2. Commented Jun 12, 2015 at 5:39
  • @blue_tiger300 I use datatool, yes. But mailmerge seems nice and simple, and ideally customized for this purpose. datatool, dunno. Not so much. Commented Jun 12, 2015 at 5:44
  • @FaheemMitha also textmerg is nice and simple. Please see tex.stackexchange.com/a/89803/11604
    – Fran
    Commented Jun 12, 2015 at 6:30
  • @Fran thanks for the tip. Do you have any thoughts on the differences between mailmerge and textmerg? Commented Jun 12, 2015 at 6:40
  • @FaheemMitha Sorry, beside that I used one or two times textmerg but never mailmerge, I have not comparative thoughts about these packages.
    – Fran
    Commented Jun 12, 2015 at 22:01

1 Answer 1

1

You aren't using \mailrepeat correctly. Its argument should be the text that you want to repeat, which is not the address but the whole letter:

\documentclass[foldmarks=false,backaddress=false,
fromalign=false,version=last]{scrlttr2}
\usepackage{fouriernc}
\usepackage[T1]{fontenc}
\usepackage{mailmerge}
\begin{document}
\setkomavar{fromname}{H. G. Wells}
\setkomavar{fromaddress}{Spade House\\ 5281 Radnor Cliff Crescent (West Side)\\ Sandgate, Kent}
\mailfields{address}
\def\today{1st January, 1895}

\mailrepeat{
  \begin{letter}{
    % George Bernard Shaw,\\
    % Shaw's Corner,\\
    % Bibbs Hall Lane,\\
    % Ayot St. Lawrence, Hertfordshire\\
    \field{address}
  }

  \opening{Dear Shaw,}

  You suck!

  \closing{Sincerely}
  \end{letter}}

\mailentry{GBS}

\end{document}
1
  • Thank you for the explanation, Ulrike. Indeed, it was a foolish mistake, as I thought. Commented Jun 14, 2015 at 3:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .