forked from andre-lehnert/latex-letter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtfbrief.cls
372 lines (329 loc) · 15.2 KB
/
tfbrief.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
% tfbrief is a LaTeX class for letters written in German.
% This class is written by Thomas Fischer <fischer@unix-ag.uni-kl.de>
% and licensed by the Creative Commons Attribution-Share Alike 3.0 License
% http://creativecommons.org/licenses/by-sa/3.0/
%
% Additional translations provided by Martin van Driel <Martin@vandriel.de>
% (Spanish)
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tfbrief}[2011/10/03 TF-Brief]
\DeclareOption{german}{%
\PassOptionsToClass{ngerman}{babel}%
}
\newcommand{\labelphone}{Telefon}
\newcommand{\labelfax}{Fax}
\newcommand{\labelmobile}{Mobil}
\newcommand{\labelemail}{E-Mail}
\newcommand{\labelwww}{WWW}
\newcommand{\labelourref}{Unser Zeichen}
\newcommand{\labelyourref}{Ihr Zeichen}
\newcommand{\labelviafaxto}[1]{per FAX an #1}
\newcommand{\labelviaemailto}[1]{per E-MAIL an #1}
\newcommand{\labelfromanddate}[2]{#1, den #2}
\newcommand{\labelgreeting}{Sehr geehrte Damen und Herren}
\newcommand{\labelleave}{Mit freundlichen Gr{\"u}{\ss}en}
\newcommand{\labelattachment}{Anlagen}
% Replace German text fragments with English text fragments
\DeclareOption{english}{%
\PassOptionsToClass{english}{babel}%
\renewcommand{\labelphone}{phone}%
\renewcommand{\labelfax}{fax}
\renewcommand{\labelmobile}{mobile}%
\renewcommand{\labelemail}{email}%
\renewcommand{\labelwww}{www}%
\renewcommand{\labelourref}{our reference}
\renewcommand{\labelyourref}{your reference}
\renewcommand{\labelviafaxto}[1]{sent via FAX to #1}%
\renewcommand{\labelviaemailto}[1]{sent via EMAIL to #1}%
\renewcommand{\labelfromanddate}[2]{#2}% no location for English letters
\renewcommand{\labelgreeting}{Dear Sir/Madam}
\renewcommand{\labelleave}{Sincerely,}
\renewcommand{\labelattachment}{Attachments}
}
% Replace German text fragments with Spanish text fragments
\DeclareOption{spanish}{%
\PassOptionsToClass{spanish}{babel}%
\renewcommand{\labelphone}{Tel.}%
\renewcommand{\labelmobile}{Cel.}%
\renewcommand{\labelemail}{E-mail}%
\renewcommand{\labelwww}{www}%
\renewcommand{\labelourref}{nuestro acta Nr.}
\renewcommand{\labelyourref}{su acta Nr.}
\renewcommand{\labelviafaxto}[1]{FAX #1}%
\renewcommand{\labelviaemailto}[1]{EMAIL #1}%
\renewcommand{\labelfromanddate}[2]{#1, #2}%
\renewcommand{\labelgreeting}{A quien le corresponda}
\renewcommand{\labelleave}{Attentamente}
\renewcommand{\labelattachment}{Anexo}
}
% Replace German text fragments with Swedish text fragments
\DeclareOption{swedish}{%
\PassOptionsToClass{swedish}{babel}%
\renewcommand{\labelphone}{telefon}%
\renewcommand{\labelfax}{fax}
\renewcommand{\labelmobile}{mobil}%
\renewcommand{\labelemail}{e-post}%
\renewcommand{\labelwww}{www}%
\renewcommand{\labelourref}{v{\aa}r referens}
\renewcommand{\labelyourref}{er referens}
\renewcommand{\labelviafaxto}[1]{via fax till #1}%
\renewcommand{\labelviaemailto}[1]{via e-post till #1}%
\renewcommand{\labelfromanddate}[2]{#2}%
\renewcommand{\labelgreeting}{Hej}
\renewcommand{\labelleave}{Med v{\"a}nliga h{\"a}lsningar}
\renewcommand{\labelattachment}{Bilagor}
}
\newcommand{\flagfromheadernarrow}{}
\DeclareOption{fromheadernarrow}{%
\renewcommand{\flagfromheadernarrow}{yes}
}
\newcommand{\flagnofoldingmark}{}
\DeclareOption{nofoldingmark}{%
\renewcommand{\flagnofoldingmark}{yes}
}
% use right-ragged (left-justified) text by default
\newcommand{\textbodyalignment}{\RaggedRight}
\DeclareOption{justify}{%
% using option "justify" switch to center-justified (i.e. no justification)
\renewcommand{\textbodyalignment}{}
}
\ProcessOptions
\LoadClass[12pt,a4paper]{scrartcl}
\RequirePackage{vmargin}
\RequirePackage{ifthen}
\RequirePackage{textcase}
% The "microtype" package provides a LaTeX interface to pdfTeXs
% micro-typographic extensions: character protrusion and font
% expansion.
% http://tug.ctan.org/info?id=microtype
\RequirePackage{microtype}
% Implements a workaround for the LaTeX bug that marginpars will
% sometimes come out at the wrong margin.
% http://tug.ctan.org/info?id=mparhack
\RequirePackage{mparhack}
% Alternative versions of "ragged"-type commands
% http://tug.ctan.org/info?id=ragged2e
\RequirePackage{ragged2e}
\newlength{\fromwidth}
\newlength{\fromwidthinternal}
\newlength{\dummylength}
\setlength{\fromwidthinternal}{1cm}
\setlength{\fromwidth}{20cm}
\newlength{\footerheight}
\newcommand{\TheFooter}{}
\newcommand{\footer}[2][1cm]{\setlength{\footerheight}{#1}\AtBeginDocument{\renewcommand{\TheFooter}{#2}}}
\newcommand{\TheFromNameShort}{}
\newcommand{\fromnameshort}[1]{\AtBeginDocument{\renewcommand{\TheFromNameShort}{#1}}}
\newcommand{\TheFromName}{}
\newcommand{\fromname}[2][]{\AtBeginDocument{\renewcommand{\TheFromName}{#2}\ifthenelse{\equal{#1}{}}{}{\renewcommand{\TheFromNameShort}{#1}}}}
\newcommand{\TheFromDegreePre}{}
\newcommand{\TheFromDegreePreSig}{}
\newcommand{\fromdegreepre}[2][]{\AtBeginDocument{\renewcommand{\TheFromDegreePre}{#2}\ifthenelse{\equal{#1}{}}{}{\renewcommand{\TheFromDegreePreSig}{#1}}}}
\newcommand{\TheFromDegreePost}{}
\newcommand{\TheFromDegreePostSig}{}
\newcommand{\fromdegreepost}[2][]{\AtBeginDocument{\renewcommand{\TheFromDegreePost}{#2}\ifthenelse{\equal{#1}{}}{}{\renewcommand{\TheFromDegreePostSig}{#1}}}}
\newcommand{\TheFromTitle}{}
\newcommand{\TheFromTitleSig}{}
\newcommand{\fromtitle}[2][]{\AtBeginDocument{\renewcommand{\TheFromTitle}{#2}\ifthenelse{\equal{#1}{}}{}{\renewcommand{\TheFromTitleSig}{#1}}}}
\newcommand{\TheFromStreetShort}{}
\newcommand{\fromstreetshort}[1]{\AtBeginDocument{\renewcommand{\TheFromStreetShort}{#1}}}
\newcommand{\TheFromStreet}{}
\newcommand{\fromstreet}[2][]{\AtBeginDocument{\renewcommand{\TheFromStreet}{#2}\ifthenelse{\equal{#1}{}}{}{\renewcommand{\TheFromStreetShort}{#1}}}}
\newcommand{\TheFromCityCC}{}
\newcommand{\fromcitycc}[1]{\AtBeginDocument{\renewcommand{\TheFromCityCC}{#1}}}
\newcommand{\TheFromCityShort}{}
\newcommand{\fromcityshort}[1]{\AtBeginDocument{\renewcommand{\TheFromCityShort}{#1}}}
\newcommand{\TheFromCity}{}
\newcommand{\fromcity}[2][]{\AtBeginDocument{\renewcommand{\TheFromCity}{#2}\ifthenelse{\equal{#1}{}}{}{\renewcommand{\TheFromCityShort}{#1}}}}
\newcommand{\TheFromCityCode}{}
\newcommand{\fromcitycode}[1]{\AtBeginDocument{\renewcommand{\TheFromCityCode}{#1}}}
\newcommand{\TheFromCountry}{}
\newcommand{\fromcountry}[1]{\AtBeginDocument{\renewcommand{\TheFromCountry}{#1}}}
\newcommand{\TheFromPhone}{}
\newcommand{\TheFromPhoneLabel}{}
\newcommand{\fromphone}[2][\labelphone]{\AtBeginDocument{\renewcommand{\TheFromPhoneLabel}{#1}\renewcommand{\TheFromPhone}{#2}}}
\newcommand{\TheFromFax}{}
\newcommand{\TheFromFaxLabel}{}
\newcommand{\fromfax}[2][\labelfax]{\AtBeginDocument{\renewcommand{\TheFromFaxLabel}{#1}\renewcommand{\TheFromFax}{#2}}}
\newcommand{\TheFromMobile}{}
\newcommand{\TheFromMobileLabel}{}
\newcommand{\frommobile}[2][\labelmobile]{\AtBeginDocument{\renewcommand{\TheFromMobileLabel}{#1}\renewcommand{\TheFromMobile}{#2}}}
\newcommand{\TheFromEMail}{}
\newcommand{\TheFromEMailLabel}{}
\newcommand{\fromemail}[2][\labelemail]{\AtBeginDocument{\renewcommand{\TheFromEMailLabel}{#1}\renewcommand{\TheFromEMail}{#2}}}
\newcommand{\TheFromWWW}{}
\newcommand{\TheFromWWWLabel}{}
\newcommand{\fromwww}[2][\labelwww]{\AtBeginDocument{\renewcommand{\TheFromWWWLabel}{#1}\renewcommand{\TheFromWWW}{#2}}}
\newcommand{\TheYourRef}{}
\newcommand{\TheYourRefLabel}{}
\newcommand{\yourref}[2][\labelyourref]{\AtBeginDocument{\renewcommand{\TheYourRefLabel}{#1}\renewcommand{\TheYourRef}{#2}}}
\newcommand{\TheOurRef}{}
\newcommand{\TheOurRefLabel}{}
\newcommand{\ourref}[2][\labelourref]{\AtBeginDocument{\renewcommand{\TheOurRefLabel}{#1}\renewcommand{\TheOurRef}{#2}}}
\newcommand{\TheToName}{}
\newcommand{\toname}[1]{\AtBeginDocument{\renewcommand{\TheToName}{#1}}}
\newcommand{\TheToStreet}{}
\newcommand{\tostreet}[1]{\AtBeginDocument{\renewcommand{\TheToStreet}{#1}}}
\newcommand{\TheToCityCC}{}
\newcommand{\tocitycc}[1]{\AtBeginDocument{\renewcommand{\TheToCityCC}{#1}}}
\newcommand{\TheToCity}{}
\newcommand{\tocity}[1]{\AtBeginDocument{\renewcommand{\TheToCity}{#1}}}
\newcommand{\TheToCityCode}{}
\newcommand{\tocitycode}[1]{\AtBeginDocument{\renewcommand{\TheToCityCode}{#1}}}
\newcommand{\TheToCountry}{}
\newcommand{\tocountry}[1]{\AtBeginDocument{\renewcommand{\TheToCountry}{#1}}}
\newcommand{\TheToFax}{}
\newcommand{\tofax}[1]{\AtBeginDocument{\renewcommand{\TheToFax}{#1}}}
\newcommand{\TheToEMail}{}
\newcommand{\toemail}[1]{\AtBeginDocument{\renewcommand{\TheToEMail}{#1}}}
\newcommand{\TheSubject}{Betreff}
\renewcommand{\subject}[1]{\AtBeginDocument{\renewcommand{\TheSubject}{#1}}}
\newcommand{\TheDate}{\today}
\renewcommand{\date}[1]{\AtBeginDocument{\renewcommand{\TheDate}{#1}}}
\newcommand{\TheGreeting}{\labelgreeting,}
\newcommand{\greeting}[1]{\AtBeginDocument{\renewcommand{\TheGreeting}{#1}}}
\newcommand{\TheLeave}{\labelleave}
\newcommand{\leave}[1]{\AtBeginDocument{\renewcommand{\TheLeave}{#1}}}
\newcommand{\TheSignature}{\vspace{1cm}}
\newcommand{\signature}[1]{\AtBeginDocument{\renewcommand{\TheSignature}{#1}}}
\newcommand{\TheLogo}{}
\newcommand{\logo}[1]{\AtBeginDocument{\renewcommand{\TheLogo}{#1}}}
\newcommand{\fromheaderentry}[2][]{%
\ifthenelse{\equal{\flagfromheadernarrow}{}}{%
\ifthenelse{\equal{#1}{}}{}{\hspace*{-2cm}\makebox[2cm][r]{\itshape\footnotesize{}#1\hspace{1em}}#2\\}%
}{%
\ifthenelse{\equal{#1}{}}{}{{\itshape\footnotesize\vspace*{-0.25em}#1}\\#2\\}%
}
}
\setmarginsrb{2.5cm}{2cm}{2.5cm}{2cm}{0cm}{0cm}{2cm}{2cm}
\setlength{\parindent}{0cm}
\setlength{\parskip}{1.75ex plus 0.75ex minus 0.75ex}
\newenvironment{letter}{
\thispagestyle{empty}
%
\setlength{\unitlength}{1mm}%
\ifthenelse{\equal{\flagnofoldingmark}{}}{% FIXME switching folding mark on and off causes x-shift in the next LaTeX element
\begin{picture}(0,0)%
%% y-offset of 25 is required
\put(-25,-81){\line(1,0){5}}%
\put(-25,-124.5){\line(1,0){7}}%
\put(-25,-186.5){\line(1,0){5}}%
\end{picture}%
}{}%
%
\ifthenelse{\equal{\TheFooter}{}}{}{%
\enlargethispage{-\footerheight}
\enlargethispage{0.5cm}% FIXME should be a page-specific variable
\begin{picture}(0,0)%
\put(-1,-250){\begin{minipage}[b][\footerheight]{\linewidth}%
\vfill%
\fontfamily{phv}\fontseries{mc}\selectfont\footnotesize%
\TheFooter
\end{minipage}}%
\end{picture}%
}%
%
\begin{minipage}[t]{8cm}\vspace*{-0.1pt}
% Alternate position for the logo
%\begin{minipage}[t][2.5cm]{\linewidth}
%\vspace{-0.001mm}\TheLogo
%\end{minipage}\\
\vspace*{2.5cm}
\begin{minipage}[t]{\linewidth}\vspace*{-0.1pt}
{\fontfamily{phv}\fontseries{mc}\selectfont \scriptsize \ifthenelse{\equal{\TheFromNameShort}{}}{\TheFromName}{\TheFromNameShort} $\cdot$ \ifthenelse{\equal{\TheFromStreetShort}{}}{\TheFromStreet}{\TheFromStreetShort} $\cdot$ \ifthenelse{\equal{\TheFromCityCC}{}}{\TheFromCityCode}{\TheFromCityCC --\TheFromCityCode} \ifthenelse{\equal{\TheFromCityShort}{}}{\TheFromCity}{\TheFromCityShort} \ifthenelse{\equal{\TheFromCountry}{}}{}{$\cdot$ \TheFromCountry} \vspace{-1ex} \rule{0cm}{0cm}\\\hrule\rule{0cm}{0cm}}
\TheToName \\
\ifthenelse{\equal{\TheToStreet}{}}{\vspace*{0.75ex}\\}{\TheToStreet\vspace*{0.6ex}\\}
{\bfseries \ifthenelse{\equal{\TheToCityCC}{}}{\TheToCityCode}{\TheToCityCC --\TheToCityCode} \TheToCity}
\ifthenelse{\equal{\TheToCountry}{}}{}{\vspace*{0.6ex}\\\textbf{\MakeTextUppercase{\TheToCountry}}}
\ifthenelse{\equal{\TheToFax}{}}{}{
\vspace{0.5em}
\fbox{\footnotesize\labelviafaxto{\TheToFax}}}
\ifthenelse{\equal{\TheToEMail}{}}{}{
\vspace{0.5em}
\fbox{\footnotesize\labelviaemailto{\TheToEMail}}}
\end{minipage}
\end{minipage}
%
\hfill
%
\settowidth{\dummylength}{\TheFromDegreePre{} \TheFromName, \TheFromDegreePost}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\TheFromTitle}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\TheFromStreet}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\ifthenelse{\equal{\TheFromCityCC}{}}{\TheFromCityCode}{\TheFromCityCC{}--\TheFromCityCode} \TheFromCity}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\TheFromPhone}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\TheFromFax}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\TheFromMobile}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\TheFromEMail}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\TheFromWWW}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\TheOurRef}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\settowidth{\dummylength}{\TheYourRef}%
\ifthenelse{\dummylength>\fromwidthinternal}{\setlength{\fromwidthinternal}{\dummylength}}{}%
\ifthenelse{\fromwidth>\fromwidthinternal}{\setlength{\fromwidth}{\fromwidthinternal}}{}
\begin{minipage}[t]{\fromwidth}\vspace*{-0.1pt}%
\begin{minipage}[t]{\linewidth}\vspace*{-0.1pt}%
\TheLogo%
\end{minipage}\par%
\ifthenelse{\equal{\TheFromDegreePre}{}}{}{\TheFromDegreePre{} }%
\TheFromName%
\ifthenelse{\equal{\TheFromDegreePost}{}}{}{, \TheFromDegreePost}%
\\%
\ifthenelse{\equal{\TheFromTitle}{}}{}{\TheFromTitle\\}%
\TheFromStreet\\%
\ifthenelse{\equal{\TheFromCityCC}{}}{\TheFromCityCode}{\TheFromCityCC{}--\TheFromCityCode}
\TheFromCity\\%
\ifthenelse{\equal{\TheFromCountry}{}}{}{\TheFromCountry\\}%
\fromheaderentry[\TheFromPhoneLabel]{\TheFromPhone}%
\fromheaderentry[\TheFromFaxLabel]{\TheFromFax}%
\fromheaderentry[\TheFromMobileLabel]{\TheFromMobile}%
\fromheaderentry[\TheFromEMailLabel]{\TheFromEMail}%
\fromheaderentry[\TheFromWWWLabel]{\TheFromWWW}%
\fromheaderentry[\TheOurRefLabel]{\TheOurRef}%
\ifthenelse{\equal{\TheYourRef}{}}{}{\\}%
\fromheaderentry[\TheYourRefLabel]{\TheYourRef}%
\end{minipage}
\vspace{2cm plus 3.5cm minus 1.75cm}
\begin{flushright}
\labelfromanddate{\TheFromCity\ifthenelse{\equal{\TheFromCountry}{\TheToCountry}}{}{\ifthenelse{\equal{\TheFromCountry}{}}{}{, \TheFromCountry}}}{\TheDate}
\end{flushright}
\vspace{2cm plus 3.5cm minus 1.75cm}
{\bfseries \sffamily \TheSubject}
\vspace{1cm plus 1cm minus 0.75cm}
\TheGreeting%
\textbodyalignment
\renewcommand{\baselinestretch}{1.2}\normalsize%
}%
{%
% empty line required, as otherwise the baselinestretch
% of the letter's last paragraph will be set to 1.0, too.
\renewcommand{\baselinestretch}{1.0}\normalsize
\ifthenelse{\equal{\TheLeave}{}}{}{
\vspace{1.5em plus 0.75em minus 0.75em}
\TheLeave
}
\vspace{0.25cm plus 0.25cm minus 0.25cm}
\TheSignature
\ifthenelse{\equal{\TheFromDegreePreSig}{}}{\TheFromDegreePre}{\TheFromDegreePreSig}
\TheFromName%
\ifthenelse{\equal{\TheFromDegreePostSig}{}}{\ifthenelse{\equal{\TheFromDegreePost}{}}{}{, \TheFromDegreePost}}{, \TheFromDegreePostSig}%
\ifthenelse{\equal{\TheFromTitleSig}{}}{\ifthenelse{\equal{\TheFromTitle}{}}{}{\\\TheFromTitle}}{\\\TheFromTitleSig}%
}
\newenvironment{attachment}[1][\labelattachment]{
\newcommand{\TheAttachmentLabel}{#1}
%\enlargethispage{2cm}
%\vspace{2cm plus 2fil minus 1cm}
\vspace{2cm plus 2cm minus 1cm}\vfill
\TheAttachmentLabel
\begin{itemize}
\setlength{\itemsep}{0cm}
}
{\end{itemize}}