Serienbrief mit Latex

Hallo allerseits,
ich möchte mit Latex einen Serienbrief erstellen. Bin auch recht weit gekommen (siehe Quelltext am Ende des Foreneintrags). Aber ich komm einfach nicht hinter eine Fehlermeldung. Latex hängt in der Zeile \begin{letter}{\if #1m Herrn \fi \if #1f Frau \fi \ #2 #3 \ #4 \par #5}.

Kann mir bitte jemand helfen?

Viele Grüße

Michael

**********************
Quelltext:
**********************

\documentclass[a4paper,11pt]{dinbrief}
\usepackage{german}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}

\begin{document}
\subject{Betrefftext***}
\signature{Heiner Müller}
\Datum{Dittersdorf, \today}
\address{Heiner Müller \ Dietenbachstraße 5 \ 77777 Dittersdorf}

\newcommand\brief[5]{
\begin{letter}{\if #1m Herrn \fi \if #1f Frau \fi \ #2 #3 \ #4 \par #5}
\backaddress{\textbf{Heiner Müller} Dietenbachstraße 5 77777 Dittersdorf}

\opening{Sehr \if #1m{geehrter Herr #3,} \fi \if #1f{geehrte Frau #3,}}

hier kommt der Text!***

\closing{Mit freundlichen Grüßen}
\end{letter}
}
\brief{m}{Vorname1}{Nachname1}{Straße Hausnummer1}{PLZ Stadt1}
\brief{f}{Vorname2}{Nachname2}{Straße Hausnummer2}{PLZ Stadt2}

\end{document}

Hallo Mik81,

mit dem dinbrief-Paket kenne ich mich leider nicht aus. :-/ Ich bin eher ein Fachmann für Satz und Layouts.

Trotzdem die Nachfrage: welche Fehlermeldung wird denn ausgegeben? Und kannst du bitte die *.log-Datei posten?

Viele Grüße,
fbmd

Hallo fbmd,

vielen Dank für Deine Nachricht.

Die Fehlermeldung ist in der folgenden *.log-Datei enthalten. Nebenbei: Kann solche Sachen eigentlich hier im Forum auch irgendwie an die Nachricht als Datei anhängen?

Viele Grüße

Michael

***********************
Die *.log-Datei
***********************

This is pdfTeX, Version 3.141592-1.40.7 (MiKTeX 2.7) (preloaded format=pdflatex 2008.4.21) 28 MAY 2010 18:01
entering extended mode
**Z:/Briefe/Vorlage-Serienbrief.tex
(Z:/Briefe/Vorlage-Serienbrief.tex
LaTeX2e
Babel and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, french, loaded.
(„C:\Programme\MiKTeX 2.7\tex\latex\dinbrief\dinbrief.cls“

Document Class/Style ‚dinbrief‘ - Version 1.73
University of Karlsruhe - 2000/03/02 12:49:21

*** dinbrief: Running in LaTeX 2e mode!
*** dinbrief: NFSS 2!
Document Class: dinbrief 2000/03/02 LaTeX2e class
\ka@db@tmpdima=\dimen102
\ka@db@tmpdimb=\dimen103
@mainlbl=\write3
\GZA=\dimen104
\ltf@headheight=\dimen105
\lts@headheight=\dimen106
\ltf@headsep=\dimen107
\lts@headsep=\dimen108
\ltf@textheight=\dimen109
\lts@textheight=\dimen110
\ka@db@txtlmarg=\dimen111
\addrhpos=\dimen112
\addrvpos=\dimen113
\addrwd=\dimen114
\addrht=\dimen115
\addroffset=\dimen116
\ka@db@addrhoffs=\dimen117
\backaddrht=\dimen118
\reflinevpos=\dimen119
\ufldmarkvpos=\dimen120
\lfldmarkvpos=\dimen121
\perfmarkvpos=\dimen122
\ka@db@foldmarkhoffs=\dimen123
\ka@db@perfmarkhoffs=\dimen124
\ka@db@foldmarklen=\dimen125
\ka@db@perfmarklen=\dimen126
\bottomtextvpos=\dimen127
\ka@db@headup=\dimen128
\ka@db@vfuzz=\dimen129
\ka@db@stdskip=\dimen130
\ka@db@fieldwd=\dimen131
\ka@db@fldskip=\dimen132
\ka@db@shfldwd=\dimen133
\ka@db@indadr=\dimen134
\dlabelheight=\dimen135
\dlabeltopmargin=\dimen136
\dlabelwidth=\dimen137
\clabelnumber=\count79
\cspare=\count80
\c@lt@state=\count81
\c@letter=\count82
\labelcount=\count83
\c@labelgen=\count84
\yearcnt=\count85
@betr=\box26
(„C:\Programme\MiKTeX 2.7\tex\latex\dinbrief\dinbrief.cfg“))
(„C:\Programme\MiKTeX 2.7\tex\latex\german\german.sty“ v2.5e 1998-07-08
Package: german 1998/07/08 v2.5e Support for writing german texts (br)
\grmnU@D=\dimen138
german – \language number for Austrian undefined, default 3 used.
)
(„C:\Programme\MiKTeX 2.7\tex\latex\base\fontenc.sty“
Package: fontenc 2005/09/27 v1.99g Standard LaTeX package

(„C:\Programme\MiKTeX 2.7\tex\latex\base\t1enc.def“
File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file
LaTeX Font Info: Redeclaring font encoding T1 on input line 43.
))
(„C:\Programme\MiKTeX 2.7\tex\latex\base\inputenc.sty“
Package: inputenc 2006/05/05 v1.1b Input encoding file
\inpenc@prehook=\toks14
\inpenc@posthook=\toks15

(„C:\Programme\MiKTeX 2.7\tex\latex\base\latin1.def“
File: latin1.def 2006/05/05 v1.1b Input encoding file
))
(„C:\Programme\MiKTeX 2.7\tex\latex\base\textcomp.sty“
Package: textcomp 2005/09/27 v1.99g Standard LaTeX package
Package textcomp Info: Sub-encoding information:
(textcomp) 5 = only ISO-Adobe without \textcurrency
(textcomp) 4 = 5 + \texteuro
(textcomp) 3 = 4 + \textohm
(textcomp) 2 = 3 + \textestimated + \textcurrency
(textcomp) 1 = TS1 - \textcircled - \t
(textcomp) 0 = TS1 (full)
(textcomp) Font families with sub-encoding setting implement
(textcomp) only a restricted character set as indicated.
(textcomp) Family ‚?‘ is the default used for unknown fonts.
(textcomp) See the documentation for details.
Package textcomp Info: Setting ? sub-encoding to TS1/1 on input line 71.

(„C:\Programme\MiKTeX 2.7\tex\latex\base\ts1enc.def“
File: ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
)
LaTeX Info: Redefining \oldstylenums on input line 266.
Package textcomp Info: Setting cmr sub-encoding to TS1/0 on input line 281.
Package textcomp Info: Setting cmss sub-encoding to TS1/0 on input line 282.
Package textcomp Info: Setting cmtt sub-encoding to TS1/0 on input line 283.
Package textcomp Info: Setting cmvtt sub-encoding to TS1/0 on input line 284.
Package textcomp Info: Setting cmbr sub-encoding to TS1/0 on input line 285.
Package textcomp Info: Setting cmtl sub-encoding to TS1/0 on input line 286.
Package textcomp Info: Setting ccr sub-encoding to TS1/0 on input line 287.
Package textcomp Info: Setting ptm sub-encoding to TS1/4 on input line 288.
Package textcomp Info: Setting pcr sub-encoding to TS1/4 on input line 289.
Package textcomp Info: Setting phv sub-encoding to TS1/4 on input line 290.
Package textcomp Info: Setting ppl sub-encoding to TS1/3 on input line 291.
Package textcomp Info: Setting pag sub-encoding to TS1/4 on input line 292.
Package textcomp Info: Setting pbk sub-encoding to TS1/4 on input line 293.
Package textcomp Info: Setting pnc sub-encoding to TS1/4 on input line 294.
Package textcomp Info: Setting pzc sub-encoding to TS1/4 on input line 295.
Package textcomp Info: Setting bch sub-encoding to TS1/4 on input line 296.
Package textcomp Info: Setting put sub-encoding to TS1/5 on input line 297.
Package textcomp Info: Setting uag sub-encoding to TS1/5 on input line 298.
Package textcomp Info: Setting ugq sub-encoding to TS1/5 on input line 299.
Package textcomp Info: Setting ul8 sub-encoding to TS1/4 on input line 300.
Package textcomp Info: Setting ul9 sub-encoding to TS1/4 on input line 301.
Package textcomp Info: Setting augie sub-encoding to TS1/5 on input line 302.
Package textcomp Info: Setting dayrom sub-encoding to TS1/3 on input line 303.
Package textcomp Info: Setting dayroms sub-encoding to TS1/3 on input line 304.

Package textcomp Info: Setting pxr sub-encoding to TS1/0 on input line 305.
Package textcomp Info: Setting pxss sub-encoding to TS1/0 on input line 306.
Package textcomp Info: Setting pxtt sub-encoding to TS1/0 on input line 307.
Package textcomp Info: Setting txr sub-encoding to TS1/0 on input line 308.
Package textcomp Info: Setting txss sub-encoding to TS1/0 on input line 309.
Package textcomp Info: Setting txtt sub-encoding to TS1/0 on input line 310.
Package textcomp Info: Setting futs sub-encoding to TS1/4 on input line 311.
Package textcomp Info: Setting futx sub-encoding to TS1/4 on input line 312.
Package textcomp Info: Setting futj sub-encoding to TS1/4 on input line 313.
Package textcomp Info: Setting hlh sub-encoding to TS1/3 on input line 314.
Package textcomp Info: Setting hls sub-encoding to TS1/3 on input line 315.
Package textcomp Info: Setting hlst sub-encoding to TS1/3 on input line 316.
Package textcomp Info: Setting hlct sub-encoding to TS1/5 on input line 317.
Package textcomp Info: Setting hlx sub-encoding to TS1/5 on input line 318.
Package textcomp Info: Setting hlce sub-encoding to TS1/5 on input line 319.
Package textcomp Info: Setting hlcn sub-encoding to TS1/5 on input line 320.
Package textcomp Info: Setting hlcw sub-encoding to TS1/5 on input line 321.
Package textcomp Info: Setting hlcf sub-encoding to TS1/5 on input line 322.
Package textcomp Info: Setting pplx sub-encoding to TS1/3 on input line 323.
Package textcomp Info: Setting pplj sub-encoding to TS1/3 on input line 324.
Package textcomp Info: Setting ptmx sub-encoding to TS1/4 on input line 325.
Package textcomp Info: Setting ptmj sub-encoding to TS1/4 on input line 326.
) (Vorlage-Serienbrief.aux)
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 10.
LaTeX Font Info: … okay on input line 10.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 10.
LaTeX Font Info: … okay on input line 10.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 10.
LaTeX Font Info: … okay on input line 10.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 10.
LaTeX Font Info: … okay on input line 10.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 10.
LaTeX Font Info: … okay on input line 10.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 10.
LaTeX Font Info: … okay on input line 10.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 10.
LaTeX Font Info: Try loading font information for TS1+cmr on input line 10.
(„C:\Programme\MiKTeX 2.7\tex\latex\base\ts1cmr.fd“
File: ts1cmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
)
LaTeX Font Info: … okay on input line 10.

! Extra \else.
@splitoncrlist …relax \let \next =\relax \else
@rgjob {#1}\let \next =@…
\if mm Herrn \fi \if mf Frau \fi \
Vorname1 Nachname1 \ Straße …

@splitoncr …gjob ##1{#2{##1}}@splitoncrlist #1
\\stop \ \endgroup
@splitaddress@addressbase }{@checkformark }
\gdef \toname {@addressna

\letter …let \vspace =\relax @splitaddress {#1}
\egroup
\brief …\if #1f Frau \fi \ #2 #3 \ #4 \par #5}
\backaddress {\textbf {Mi…
l.33 …Nachname1}{Straße Hausnummer1}{PLZ Stadt1}

I’m ignoring this; it doesn’t match any \if.

! Extra \fi.
@splitoncrlist …let \next =@splitoncrlist \fi
\next
\if mm Herrn \fi \if mf Frau \fi \
Vorname1 Nachname1 \ Straße …

@splitoncr …gjob ##1{#2{##1}}@splitoncrlist #1
\\stop \ \endgroup
@splitaddress@addressbase }{@checkformark }
\gdef \toname {@addressna

\letter …let \vspace =\relax @splitaddress {#1}
\egroup
\brief …\if #1f Frau \fi \ #2 #3 \ #4 \par #5}
\backaddress {\textbf {Mi…
l.33 …Nachname1}{Straße Hausnummer1}{PLZ Stadt1}

I’m ignoring this; it doesn’t match any \if.

LaTeX Font Info: External font cmex10' loaded for size (Font) on input line 33. LaTeX Font Info: External font cmex10’ loaded for size
(Font) on input line 33.
LaTeX Font Info: External font `cmex10’ loaded for size
(Font) on input line 33.
[1

{C:/Dokumente und Einstellungen/All Users/Anwendungsdaten/MiKTeX/2.7/pdftex/con
fig/pdftex.map}]
! Extra \else.
@splitoncrlist …relax \let \next =\relax \else
@rgjob {#1}\let \next =@…
\if fm Herrn \fi \if ff Frau \fi \
Vorname2 Nachname2 \ Straße …

@splitoncr …gjob ##1{#2{##1}}@splitoncrlist #1
\\stop \ \endgroup
@splitaddress@addressbase }{@checkformark }
\gdef \toname {@addressna

\letter …let \vspace =\relax @splitaddress {#1}
\egroup
\brief …\if #1f Frau \fi \ #2 #3 \ #4 \par #5}
\backaddress {\textbf {Mi…
l.34 …Nachname2}{Straße Hausnummer2}{PLZ Stadt2}

I’m ignoring this; it doesn’t match any \if.

[1

] )
(\end occurred when \iffalse on line 34 was incomplete)
Here is how much of TeX’s memory you used:
1308 strings out of 95337
15919 string characters out of 1184201
59217 words of memory out of 1500000
4547 multiletter control sequences out of 110000
8855 words of font info for 25 fonts, out of 1200000 for 2000
14 hyphenation exceptions out of 8191
23i,5n,19p,168b,164s stack positions out of 5000i,500n,10000p,200000b,5000s
{C:/Programme/MiKTeX 2.7
/dvips/cm-super/cm-super-t1.enc}
Output written on Vorlage-Serienbrief.pdf (2 pages, 89044 bytes).
PDF statistics:
30 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 131072)
1 words of extra memory for PDF output out of 10000 (max. 10000000)

Hi Michael,

also es sieht ganz so aus, als ob TeX sich an deiner \if \fi-Konstruktion verschluckt. Das ist nicht unwahrscheinlich, da der letter-Befehl sicher selbst if-Schleifen verwendet, die sich dann möglicherweise mit deinen verschachteln.

Ich würde erstmal versuchen, mir etwas mehr Arbeit zu machen und dafür auf die \ifs zu verzichten. In http://www.cam.ctan.org/tex-archive/macros/latex/con… findest du auf Seite 17 eine etwas weniger ausgefeilte, aber einfachere Möglichkeit für Serienbriefe.

Viele Grüße,
Florian

Vielen Dank Florian,
ich mach mich mal ran, das durch zu lesen.
VG Michael

Das sieht sehr komisch aus, insbesondere weil kein else drin steht.
Evtl. in den if bereichen leere „else“ Abschnitte einfügen?

Das sieht sehr komisch aus, insbesondere weil kein else drin
steht.
Evtl. in den if bereichen leere „else“ Abschnitte einfügen?

Hallo Carsten,
mit \else habe ich es auch schon probiert. Das scheint das selbe nur in grün zu sein. \if \fi hat den Vorteil, dass später noch weitere Bedingungen angehängt werden kann.
Vielen Dank
Michael.

Hallo,

das Problem scheint daran zu liegen, dass \if schon als Parameter der letter-Umgebung übergeben wird; die letter-Umgebung scheint selber intern bei der Verarbeitung der Parameter schon mit \if … \else … \fi zu arbeiten, daher gibt es die Fehlermeldung „!Extra \else“. Darum kann man aus meiner Sicht in den Parametern der Umgebung keine Fallunterscheidung vornehmen. In der Anrede hingegen funktioniert es sehr gut.

Außerdem empfehle ich, unter LaTeX nicht direkt mit \if… \fi zu arbeiten; das ist TeX-Syntax. Stattdessen würde ich das Paket „ifthen“ einbinden (im Header: „\usepackage{ifthen}“, und dann folgenden Befehl nutzen:
\ifthenelse{Bedingung}{Dann}{Sonst}

Zusätzlich empfehle ich, das neue Kommando im Header zu definieren, nicht im eigentlichen Dokument.

Mit den Änderungen würde das Beispiel so aussehen:

**********************
Quelltext:
**********************

\documentclass[a4paper,11pt]{dinbrief}
\usepackage{german}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{ifthen}

\newcommand\brief[5]{
\begin{letter}{An\ #2 #3 \ #4 \par #5}
\backaddress{\textbf{Heiner Müller} Dietenbachstraße 5 77777 Dittersdorf}

\opening{Sehr \ifthenelse{\equal{#1}{m}}{geehrter Herr #3,}{geehrte Frau #3,}}

hier kommt der Text!***

\closing{Mit freundlichen Grüßen}
\end{letter}
}

\begin{document}
\subject{Betrefftext***}
\signature{Heiner Müller}
\Datum{Dittersdorf, \today}
\address{Heiner Müller \ Dietenbachstraße 5 \ 77777 Dittersdorf}

\brief{m}{Vorname1}{Nachname1}{Strasse Hausnummer1}{PLZ Stadt1}
\brief{f}{Vorname2}{Nachname2}{Strasse Hausnummer2}{PLZ Stadt2}

\end{document}

Ich hoffe geholfen zu haben. Sollte jemand anders eine Lösung für die Fallunterscheidung im Parameter der Umgebung finden, wäre ich auch daran interessiert.

Viele Grüße,
Christoph

Vielen Dank Christoph,
so komme ich weiter.
Beste Grüße
Michael.